Skip to content

Commit 0f5f648

Browse files
committed
tests/run-tests.py: Add support for .native.exp expected output files.
There are currently a few tests that are excluded when using the native emitter because they test printing of exception tracebacks, which includes line numbers. And the native emitter doesn't store line numbers, so gets these tests wrong. But we'd still like to run these tests using the native emitter, because they test useful things even if the line number info is not in the traceback (eg that threads which crash print out their exception). This commit adds support for native-specific .exp files, which are of the form `<test>.py.native.exp`. If such an .exp file exists then it take precedence over any normal `<test>.py.exp` file. (Actually, the implementation here is general enough that it also supports `<test>.py.bytecode.exp` as well, if bytecode ever needs a specific exp file.) Signed-off-by: Damien George <damien@micropython.org>
1 parent 0cb2c69 commit 0f5f648

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/run-tests.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,11 @@ def run_one_test(test_file):
994994
# Expected output is result of running unittest.
995995
output_expected = None
996996
else:
997-
test_file_expected = test_file + ".exp"
997+
# Prefer emitter-specific expected output.
998+
test_file_expected = test_file + "." + args.emit + ".exp"
999+
if not os.path.isfile(test_file_expected):
1000+
# Fall back to generic expected output.
1001+
test_file_expected = test_file + ".exp"
9981002
if os.path.isfile(test_file_expected):
9991003
# Expected output given by a file, so read that in.
10001004
with open(test_file_expected, "rb") as f:
@@ -1202,8 +1206,8 @@ def main():
12021206
{test_directory_description}
12031207
12041208
When running tests, run-tests.py compares the MicroPython output of the test with the output
1205-
produced by running the test through CPython unless a <test>.exp file is found, in which
1206-
case it is used as comparison.
1209+
produced by running the test through CPython unless a <test>.exp file is found (or a
1210+
<test>.native.exp file when using the native emitter), in which case it is used as comparison.
12071211
12081212
If a test fails, run-tests.py produces a pair of <test>.out and <test>.exp files in the result
12091213
directory with the MicroPython output and the expectations, respectively.

0 commit comments

Comments
 (0)