tests/run-multitests: Make paths more deterministic.

Allows running from a different directory, etc.

This work was funded by Planet Innovation.
This commit is contained in:
Andrew Leech 2022-09-20 08:54:58 +10:00 committed by Damien George
parent 7589d86b6b
commit 13c4470fd0
1 changed files with 13 additions and 4 deletions

View File

@ -15,15 +15,24 @@ import itertools
import subprocess
import tempfile
sys.path.append("../tools")
test_dir = os.path.abspath(os.path.dirname(__file__))
if os.path.abspath(sys.path[0]) == test_dir:
# remove the micropython/tests dir from path to avoid
# accidentally importing tests like micropython/const.py
sys.path.pop(0)
sys.path.insert(0, test_dir + "/../tools")
import pyboard
if os.name == "nt":
CPYTHON3 = os.getenv("MICROPY_CPYTHON3", "python3.exe")
MICROPYTHON = os.getenv("MICROPY_MICROPYTHON", "../ports/windows/micropython.exe")
MICROPYTHON = os.getenv("MICROPY_MICROPYTHON", test_dir + "/../ports/windows/micropython.exe")
else:
CPYTHON3 = os.getenv("MICROPY_CPYTHON3", "python3")
MICROPYTHON = os.getenv("MICROPY_MICROPYTHON", "../ports/unix/build-standard/micropython")
MICROPYTHON = os.getenv(
"MICROPY_MICROPYTHON", test_dir + "/../ports/unix/build-standard/micropython"
)
# For diff'ing test output
DIFF = os.getenv("MICROPY_DIFF", "diff -u")
@ -508,7 +517,7 @@ def main():
cmd_args = cmd_parser.parse_args()
# clear search path to make sure tests use only builtin modules and those in extmod
os.environ["MICROPYPATH"] = os.pathsep + "../extmod"
os.environ["MICROPYPATH"] = os.pathsep.join(("", ".frozen", "../extmod"))
test_files = prepare_test_file_list(cmd_args.files)
max_instances = max(t[1] for t in test_files)