← Back to team overview

curtin-dev team mailing list archive

[Merge] ~raharper/curtin:fix/makefile-drop-nosetest-command into curtin:master

 

Ryan Harper has proposed merging ~raharper/curtin:fix/makefile-drop-nosetest-command into curtin:master.

Commit message:
Makefile: make adjustments to call lint/style tools via python module

- Drop nosetest invocation
- Drop tools/run-pyflakes*
- Add pylint targets
- Add pylintopts and target_dirs
- Fix style and lint issues

Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~raharper/curtin/+git/curtin/+merge/383563
-- 
Your team curtin developers is requested to review the proposed merge of ~raharper/curtin:fix/makefile-drop-nosetest-command into curtin:master.
diff --git a/Makefile b/Makefile
index 827102c..68a3ad3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 TOP := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
 CWD := $(shell pwd)
-PYTHON ?= python3
+PYTHON2 ?= python2
+PYTHON3 ?= python3
 COVERAGE ?= 1
 DEFAULT_COVERAGEOPTS = --with-coverage --cover-erase --cover-branches --cover-package=curtin --cover-inclusive 
 ifeq ($(COVERAGE), 1)
@@ -9,6 +10,8 @@ endif
 CURTIN_VMTEST_IMAGE_SYNC ?= False
 export CURTIN_VMTEST_IMAGE_SYNC
 noseopts ?= -vv --nologcapture
+pylintopts ?= --rcfile=pylintrc --errors-only
+target_dirs ?= curtin tests tools
 
 build:
 
@@ -26,16 +29,22 @@ pep8:
 	@$(CWD)/tools/run-pep8
 
 pyflakes:
-	@$(CWD)/tools/run-pyflakes
+	$(PYTHON2) -m pyflakes $(target_dirs)
 
 pyflakes3:
-	@$(CWD)/tools/run-pyflakes3
+	$(PYTHON3) -m pyflakes $(target_dirs)
+
+pylint:
+	$(PYTHON2) -m pylint $(pylintopts) $(target_dirs)
+
+pylint3:
+	$(PYTHON3) -m pylint $(pylintopts) $(target_dirs)
 
 unittest2:
-	nosetests $(coverageopts) $(noseopts) tests/unittests
+	$(PYTHON2) -m nose $(coverageopts) $(noseopts) tests/unittests
 
 unittest3:
-	nosetests3 $(coverageopts) $(noseopts) tests/unittests
+	$(PYTHON3) -m nose $(coverageopts) $(noseopts) tests/unittests
 
 unittest: unittest2 unittest3
 
@@ -53,7 +62,7 @@ check-doc-deps:
 
 # By default don't sync images when running all tests.
 vmtest: schema-validate
-	nosetests3 $(noseopts) tests/vmtests
+	$(PYTHON3) -m nose $(noseopts) tests/vmtests
 
 vmtest-deps:
 	@$(CWD)/tools/vmtest-system-setup
diff --git a/tests/vmtests/__init__.py b/tests/vmtests/__init__.py
index b93043e..222adcc 100644
--- a/tests/vmtests/__init__.py
+++ b/tests/vmtests/__init__.py
@@ -1943,7 +1943,7 @@ class VMBaseClass(TestCase):
         '''check if test used storage config'''
         try:
             return len(self.get_storage_config()) > 0
-        except FileNotFoundError:
+        except util.FileMissingError:
             return False
 
     @skip_if_flag('expected_failure')
diff --git a/tools/block-discover-to-config b/tools/block-discover-to-config
index e77eb07..03c7ba7 100755
--- a/tools/block-discover-to-config
+++ b/tools/block-discover-to-config
@@ -28,7 +28,7 @@ def main():
 if __name__ == "__main__":
     try:
         ret = main()
-    except:
+    except Exception:
         traceback.print_exc()
         pdb.post_mortem()
         ret = 1
diff --git a/tools/run-pyflakes b/tools/run-pyflakes
deleted file mode 100755
index 86eb3cc..0000000
--- a/tools/run-pyflakes
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-# This file is part of curtin. See LICENSE file for copyright and license info.
-
-PYTHON_VERSION=${PYTHON_VERSION:-2}
-CR="
-"
-vmtests=""
-if [ "$PYTHON_VERSION" = "3" ]; then
-    vmtests="tests/vmtests/"
-fi
-pycheck_dirs=(
-    "curtin/"
-    "tests/unittests/"
-    $vmtests
-    "tools/curtin-log-print"
-    "tools/report_webhook_logger"
-    "tools/block-discover-to-config"
-    "tools/curtin-log-print"
-    "tools/noproxy"
-    "tools/remove-vmtest-release"
-    "tools/schema-validate-storage"
-    "tools/ssh-keys-list"
-    "tools/vmtest-filter"
-    "tools/vmtest-sync-images"
-    "tools/webserv"
-    "tools/write-curtin"
-)
-
-set -f
-if [ $# -eq 0 ]; then
-   files=( "${pycheck_dirs[@]}" )
-else
-   files=( "$@" )
-fi
-
-cmd=( "python${PYTHON_VERSION}" -m "pyflakes" "${files[@]}" )
-
-echo "Running: " "${cmd[@]}" 1>&2
-exec "${cmd[@]}"
-
-# vi: ts=4 expandtab syntax=sh
diff --git a/tools/run-pyflakes3 b/tools/run-pyflakes3
deleted file mode 100755
index 2b12e07..0000000
--- a/tools/run-pyflakes3
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-# This file is part of curtin. See LICENSE file for copyright and license info.
-
-PYTHON_VERSION=3 exec "${0%/*}/run-pyflakes" "$@"
-
-# vi: ts=4 expandtab syntax=sh
diff --git a/tools/schema-validate-storage b/tools/schema-validate-storage
index 771ee5b..e07f860 100755
--- a/tools/schema-validate-storage
+++ b/tools/schema-validate-storage
@@ -20,6 +20,7 @@ def get_configs(conf_input):
                        for f in os.listdir(conf_input)])
     return [conf_input]
 
+
 errors = []
 for conf in get_configs(conf_input):
     # validate entire config
diff --git a/tools/vmtest-filter b/tools/vmtest-filter
index ae427c3..2d7f0a9 100755
--- a/tools/vmtest-filter
+++ b/tools/vmtest-filter
@@ -56,10 +56,11 @@ def main():
     for tc in find_testcases_by_attr(**kwargs):
         print(tc)
 
+
 if __name__ == '__main__':
     try:
         ret = main()
-    except:
+    except Exception:
         traceback.print_exc()
         pdb.post_mortem()
         ret = 1
diff --git a/tools/vmtest-sync-images b/tools/vmtest-sync-images
index 5ee7f9c..f6b8e1d 100755
--- a/tools/vmtest-sync-images
+++ b/tools/vmtest-sync-images
@@ -22,6 +22,7 @@ from tests.vmtests.helpers import (
 def _fmt_list_filter(filter_name, matches):
     return '~'.join((filter_name, '|'.join(matches)))
 
+
 if __name__ == '__main__':
     # Acquire an exclusive lock on IMAGE_DIR. This will prevent jenkins-runner
     # from running while vmtest-sync-images is working.

Follow ups