Skip to content

Commit ff6491d

Browse files
committed
tests/run-natmodtests.py: Automatically skip tests that are too large.
This follows a similar change made for `run-tests.py` in commit 2291045. The change here uses the same logic to detect if a natmod test is too big for the target (eg overflows (I)RAM loading the native .mpy), by printing "START TEST" at the start of the test. Typical output is now something like this: ... pass extmod/random_basic.py pass extmod/random_extra_float.py pass extmod/random_extra.py SKIP extmod/random_seed_default.py LRGE extmod/re1.py SKIP extmod/re_debug.py pass extmod/re_error.py pass extmod/re_group.py pass extmod/re_groups.py ... and the tests that are too large are reported at the end, and written to the `_result.json` file. Signed-off-by: Damien George <[email protected]>
1 parent a9b038a commit ff6491d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/run-natmodtests.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,26 @@ def run_tests(target_truth, target, args, resolved_arch):
170170
print("skip {} - mpy file not compiled".format(test_file))
171171
continue
172172
test_script += bytes(injected_import_hook_code.format(test_module), "ascii")
173+
test_script += b"print('START TEST')\n"
173174
test_script += test_file_data
174175

175176
# Run test under MicroPython
176177
result_out, error = target.run_script(test_script)
177178

178179
# Work out result of test
179180
extra = ""
181+
result_out = result_out.removeprefix(b"START TEST\n")
180182
if error is None and result_out == b"SKIP\n":
181183
result = "SKIP"
184+
elif (
185+
error is not None
186+
and error.args[0] == "exception"
187+
and error.args[1] == b""
188+
and b"MemoryError" in error.args[2]
189+
):
190+
# Test had a MemoryError before anything (should be at least "START TEST")
191+
# was printed, so the test is too big for the target.
192+
result = "LRGE"
182193
elif error is not None:
183194
result = "FAIL"
184195
extra = " - " + str(error)
@@ -203,6 +214,8 @@ def run_tests(target_truth, target, args, resolved_arch):
203214
test_results.append((test_file, "pass", ""))
204215
elif result == "SKIP":
205216
test_results.append((test_file, "skip", ""))
217+
elif result == "LRGE":
218+
test_results.append((test_file, "skip", "too large"))
206219
else:
207220
test_results.append((test_file, "fail", ""))
208221

0 commit comments

Comments
 (0)