Skip to content

Commit 9ecdeb6

Browse files
committed
tests/run-tests.py: Skip tests depending on error reporting capability.
Detect the target's error reporting capabilities, and skip tests as appropriate. For example, all samd boards are configured with `MICROPY_ERROR_REPORTING_TERSE` so need to skip these four tests. Signed-off-by: Damien George <damien@micropython.org>
1 parent 98c76a9 commit 9ecdeb6

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

tests/feature_check/target_info.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@
3636
except NameError:
3737
float_prec = 0
3838

39-
print(platform, arch, arch_flags, build, thread, float_prec, len("α") == 1)
39+
# Detect the error reporting level (based on the length of the raised exception message).
40+
try:
41+
(lambda: 0)(0)
42+
except TypeError as er:
43+
error_reporting = {0: "none", 27: "terse", 54: "normal", 56: "detailed"}[len(er.value)]
44+
45+
print(platform, arch, arch_flags, build, thread, float_prec, len("α") == 1, error_reporting)

tests/run-tests.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,19 @@
198198
),
199199
}
200200

201+
# Tests to skip when MICROPY_ERROR_REPORTING is at a certain level.
202+
error_reporting_tests_to_skip = {
203+
# Skip at level MICROPY_ERROR_REPORTING_NONE.
204+
"none": (
205+
"micropython/heapalloc_exc_compressed.py",
206+
"micropython/heapalloc_exc_compressed_emg_exc.py",
207+
"micropython/opt_level_lineno.py",
208+
"misc/print_exception.py",
209+
),
210+
}
211+
# Skip at level MICROPY_ERROR_REPORTING_TERSE.
212+
error_reporting_tests_to_skip["terse"] = error_reporting_tests_to_skip["none"]
213+
201214
# Tests with known intermittent failures. These tests still run, but failures
202215
# are reclassified as "ignored" instead of "fail" so they don't affect the CI
203216
# exit code. Paths are relative to the tests/ directory (must match test_file
@@ -353,7 +366,7 @@ def detect_test_platform(pyb, args):
353366
output = run_feature_check(pyb, args, "target_info.py")
354367
if output.endswith(b"CRASH"):
355368
raise ValueError("cannot detect platform: {}".format(output))
356-
platform, arch, arch_flags, build, thread, float_prec, unicode = (
369+
platform, arch, arch_flags, build, thread, float_prec, unicode, error_reporting = (
357370
str(output, "ascii").strip().split()
358371
)
359372
if arch == "None":
@@ -380,6 +393,7 @@ def detect_test_platform(pyb, args):
380393
args.thread = thread
381394
args.float_prec = float_prec
382395
args.unicode = unicode
396+
args.error_reporting = error_reporting
383397

384398
# Print the detected information about the target.
385399
print("platform={}".format(platform), end="")
@@ -922,6 +936,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
922936
# Skip platform-specific tests.
923937
skip_tests.update(platform_tests_to_skip.get(args.platform, ()))
924938

939+
# Skip error-reporting-specific tests.
940+
skip_tests.update(error_reporting_tests_to_skip.get(args.error_reporting, ()))
941+
925942
# Some tests are known to fail on 64-bit machines
926943
if pyb is None and platform.architecture()[0] == "64bit":
927944
pass

0 commit comments

Comments
 (0)