Martí Bolívar | bd82705 | 2020-08-21 15:47:22 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | # Copyright (c) 2020 Nordic Semiconductor ASA |
| 4 | # |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | |
| 7 | # A convenience script provided for running tests on the runners |
| 8 | # package. Runs mypy and pytest. Any extra arguments in sys.argv are |
| 9 | # passed along to pytest. |
| 10 | # |
| 11 | # Using tox was considered, but rejected as overkill for now. |
| 12 | # |
| 13 | # We would have to configure tox to create the test virtualenv with |
| 14 | # all of zephyr's scripts/requirements.txt, which seems like too much |
| 15 | # effort for now. We just run in the same Python environment as the |
| 16 | # user for developer testing and trust CI to set that environment up |
| 17 | # properly for integration testing. |
| 18 | # |
| 19 | # If this file starts to reimplement too many features that are |
| 20 | # already available in tox, we can revisit this decision. |
| 21 | |
| 22 | import os |
| 23 | import shlex |
| 24 | import subprocess |
| 25 | import sys |
| 26 | |
| 27 | here = os.path.abspath(os.path.dirname(__file__)) |
| 28 | |
| 29 | mypy = [sys.executable, '-m', 'mypy', f'--config-file={here}/mypy.ini', |
| 30 | '--package', 'runners'] |
| 31 | pytest = [sys.executable, '-m', 'pytest'] + sys.argv[1:] |
| 32 | |
| 33 | print(f'Running mypy from {here}:\n\t' + |
| 34 | ' '.join(shlex.quote(s) for s in mypy), |
| 35 | flush=True) |
| 36 | subprocess.run(mypy, check=True, cwd=here) |
| 37 | print(f'Running pytest from {here}:\n\t' + |
| 38 | ' '.join(shlex.quote(s) for s in pytest), |
| 39 | flush=True) |
| 40 | subprocess.run(pytest, check=True, cwd=here) |