Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dist/tools/compile_and_test_for_board: add basic checks for script #10837

Merged
merged 3 commits into from Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions dist/tools/compile_and_test_for_board/.gitignore
@@ -0,0 +1,2 @@
# tox envs directory
.tox
16 changes: 15 additions & 1 deletion dist/tools/compile_and_test_for_board/README.md
Expand Up @@ -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
-------------------
Expand All @@ -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
Expand Up @@ -79,7 +79,7 @@
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
Expand Down Expand Up @@ -264,7 +264,7 @@ def run_compilation_and_test(self, **test_kwargs):
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)

Expand All @@ -283,7 +283,7 @@ def compilation_and_test(self, clean_after=False, runtest=True,
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
Expand All @@ -301,7 +301,7 @@ def compilation_and_test(self, clean_after=False, runtest=True,
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:
Expand Down Expand Up @@ -415,7 +415,7 @@ def _make_handle_error(self, name, err):

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`.
Expand Down
27 changes: 27 additions & 0 deletions 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}