diff --git a/dist/tools/compile_and_test_for_board/.gitignore b/dist/tools/compile_and_test_for_board/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..92f3a8ec561361a85e4830f99ed477cbf5b9e437 --- /dev/null +++ b/dist/tools/compile_and_test_for_board/.gitignore @@ -0,0 +1,2 @@ +# tox envs directory +.tox diff --git a/dist/tools/compile_and_test_for_board/README.md b/dist/tools/compile_and_test_for_board/README.md index c62e56ba571ac912b342e235959a1bf549a44bcf..4155f1b70721e47d582528b6cb8e514a7c5962b3 100644 --- a/dist/tools/compile_and_test_for_board/README.md +++ b/dist/tools/compile_and_test_for_board/README.md @@ -20,6 +20,20 @@ They can be checked with: find results/ -name '*.failed' find results/ -name 'test.success' +Script checks +------------- + +Use [tox](https://tox.readthedocs.io/en/latest/) to run basic checks on the +script: + + $ tox + +This runs doctest (via pytest), pylint and flake8 checks in a row. +Use `-e` to run each check independently: + + $ tox -e test + $ tox -e lint + $ tox -e flake8 Implementation TODO ------------------- @@ -31,6 +45,6 @@ simply adapt to be used from within RIOT. * Provide a RIOT/Makefile integration * Save output files into `${BUILD_DIR}/output/compile_and_test` directory by default -* tox file to run `doctests/pylint/flake8`. Add tests. +* Add tests. * Implement the `board_is_supported`/`board_has_enough_memory`/`has_tests` to make targets instead of fiddling to get the value diff --git a/dist/tools/compile_and_test_for_board/compile_and_test_for_board.py b/dist/tools/compile_and_test_for_board/compile_and_test_for_board.py index f6adc1f0ba5112bc58e52e35746c52138646cebb..68f5bf17158b0c4e0f1ccd47acafdde25cd71b84 100755 --- a/dist/tools/compile_and_test_for_board/compile_and_test_for_board.py +++ b/dist/tools/compile_and_test_for_board/compile_and_test_for_board.py @@ -79,7 +79,7 @@ LOG_HANDLER.setFormatter(logging.Formatter(logging.BASIC_FORMAT)) LOG_LEVELS = ('debug', 'info', 'warning', 'error', 'fatal', 'critical') -class TestError(Exception): +class ErrorInTest(Exception): """Custom exception for a failed test. It contains the step that failed in 'message', the 'application' and the @@ -264,7 +264,7 @@ class RIOTApplication(): try: self.compilation_and_test(**test_kwargs) return None - except TestError as err: + except ErrorInTest as err: self.logger.error('Failed during: %s', err) return (str(err), err.application.appdir, err.errorfile) @@ -283,7 +283,7 @@ class RIOTApplication(): succeeds. :param incremental: Do not rerun successful compilation and tests - :raises TestError: on execution failed during one step + :raises ErrorInTest: on execution failed during one step """ # Ignore incompatible APPS @@ -301,7 +301,7 @@ class RIOTApplication(): create_directory(self.resultdir, clean=not incremental) # Run compilation and flash+test - # It raises TestError on error which is handled outside + # It raises ErrorInTest on error which is handled outside compilation_cmd = list(self.COMPILE_TARGETS) if jobs is not None: @@ -415,7 +415,7 @@ class RIOTApplication(): self.logger.warning(output) self.logger.error('Error during %s, writing to %s', name, outfile) - raise TestError(name, self, outfile) + raise ErrorInTest(name, self, outfile) def _write_resultfile(self, name, status, body=''): """Write `body` to result file `name.status`. diff --git a/dist/tools/compile_and_test_for_board/tox.ini b/dist/tools/compile_and_test_for_board/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..b3c89b9cac68330d9f5e30fa04d2eee8dda1267e --- /dev/null +++ b/dist/tools/compile_and_test_for_board/tox.ini @@ -0,0 +1,27 @@ +[tox] +envlist = test,lint,flake8 +skipsdist = True + +[testenv] +basepython = python3 +setenv = + script = compile_and_test_for_board.py +commands = + test: {[testenv:test]commands} + lint: {[testenv:lint]commands} + flake8: {[testenv:flake8]commands} + +[testenv:test] +deps = pytest +commands = + pytest -v --doctest-modules {env:script} + +[testenv:lint] +deps = pylint +commands = + pylint {env:script} + +[testenv:flake8] +deps = flake8 +commands = + flake8 {env:script}