Skip to content

Commit 1db71f9

Browse files
committed
tests/run-tests.py: Generalise addition of port specific test directory.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 6565827 commit 1db71f9

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

tests/run-tests.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ def open(self, path, mode):
102102
# Platforms associated with the unix port, values of `sys.platform`.
103103
PC_PLATFORMS = ("darwin", "linux", "win32")
104104

105+
# Mapping from `sys.platform` to the port name, for special cases.
106+
# See `platform_to_port()` function.
107+
platform_to_port_map = {"pyboard": "stm32", "WiPy": "cc3200"}
108+
platform_to_port_map.update({p: "unix" for p in PC_PLATFORMS})
109+
105110
# Tests to skip for specific emitters.
106111
emitter_tests_to_skip = {
107112
# Some tests are known to fail with native emitter.
@@ -252,6 +257,10 @@ def convert_regex_escapes(line):
252257
return bytes("".join(cs), "utf8")
253258

254259

260+
def platform_to_port(platform):
261+
return platform_to_port_map.get(platform, platform)
262+
263+
255264
def get_test_instance(test_instance, baudrate, user, password):
256265
if test_instance.startswith("port:"):
257266
_, port = test_instance.split(":", 1)
@@ -1348,31 +1357,17 @@ def main():
13481357
test_dirs += ("thread",)
13491358
if args.float_prec > 0:
13501359
test_dirs += ("float",)
1351-
if args.platform == "pyboard":
1352-
# run pyboard tests
1353-
test_dirs += ("ports/stm32",)
1354-
elif args.platform == "renesas-ra":
1355-
test_dirs += ("ports/renesas-ra")
1356-
elif args.platform == "rp2":
1357-
test_dirs += ("ports/rp2",)
1358-
elif args.platform == "WiPy":
1359-
# run WiPy tests
1360-
test_dirs += ("ports/cc3200",)
1361-
elif args.platform in PC_PLATFORMS:
1360+
port_specific_test_dir = "ports/{}".format(platform_to_port(args.platform))
1361+
if os.path.isdir(port_specific_test_dir):
1362+
test_dirs += (port_specific_test_dir,)
1363+
if args.platform in PC_PLATFORMS:
13621364
# run PC tests
13631365
test_dirs += (
13641366
"import",
13651367
"io",
13661368
"unicode",
13671369
"cmdline",
1368-
"ports/unix",
1369-
)
1370-
elif args.platform == "qemu":
1371-
test_dirs += (
1372-
"ports/qemu",
13731370
)
1374-
elif args.platform == "webassembly":
1375-
test_dirs += ("ports/webassembly",)
13761371
else:
13771372
# run tests from these directories
13781373
test_dirs = args.test_dirs

0 commit comments

Comments
 (0)