diff options
| author | Damien George <damien@micropython.org> | 2025-08-18 11:02:04 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-08-28 23:11:30 +1000 |
| commit | 7a8ae72640bf15971e0dc87727a639281ffbcc02 (patch) | |
| tree | a0447bdbcad3b4d1d78c3577e93ae4ac14348f17 /tests/run-tests.py | |
| parent | b6cd577cf6ea1de28092a7abe58613c66debd412 (diff) | |
tests/run-tests.py: Factor code for device shortcuts to a function.
So it can be reused by other test runners.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/run-tests.py')
| -rwxr-xr-x | tests/run-tests.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/run-tests.py b/tests/run-tests.py index 7a0042819..2d02e6b23 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -246,6 +246,17 @@ def platform_to_port(platform): return platform_to_port_map.get(platform, platform) +def convert_device_shortcut_to_real_device(device): + if device.startswith("a") and device[1:].isdigit(): + return "/dev/ttyACM" + device[1:] + elif device.startswith("u") and device[1:].isdigit(): + return "/dev/ttyUSB" + device[1:] + elif device.startswith("c") and device[1:].isdigit(): + return "COM" + device[1:] + else: + return device + + def get_test_instance(test_instance, baudrate, user, password): if test_instance.startswith("port:"): _, port = test_instance.split(":", 1) @@ -253,15 +264,9 @@ def get_test_instance(test_instance, baudrate, user, password): return None elif test_instance == "webassembly": return PyboardNodeRunner() - elif test_instance.startswith("a") and test_instance[1:].isdigit(): - port = "/dev/ttyACM" + test_instance[1:] - elif test_instance.startswith("u") and test_instance[1:].isdigit(): - port = "/dev/ttyUSB" + test_instance[1:] - elif test_instance.startswith("c") and test_instance[1:].isdigit(): - port = "COM" + test_instance[1:] else: # Assume it's a device path. - port = test_instance + port = convert_device_shortcut_to_real_device(test_instance) global pyboard sys.path.append(base_path("../tools")) |
