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 22import os 23import shlex 24import subprocess 25import sys 26 27here = os.path.abspath(os.path.dirname(__file__)) 28 29mypy = ['mypy', '--package=runners'] 30pytest = ['pytest'] + sys.argv[1:] 31 32for cmd in [mypy, pytest]: 33 command = [sys.executable, '-m'] + cmd 34 print(f"Running {cmd[0]} in cwd '{here}':\n\t" + 35 ' '.join(shlex.quote(s) for s in command), 36 flush=True) 37 subprocess.run(command, check=True, cwd=here) 38