From 8459f538eb45fd8e1e4d614298449cf18de84d75 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 15 Apr 2021 00:47:24 +1000 Subject: [PATCH] tests/feature_check: Check for lack of pass result rather than failure. Commit cb68a5741aba5d4935428674234a9d643f97405f broke automatic Python feature detection when running tests, because some detection relied on a crash of a feature script returning exactly b"CRASH". This commit fixes this and improves the situation by testing for the lack of a known pass result, rather than an exact failure result. Signed-off-by: Damien George --- tests/feature_check/async_check.py | 3 +++ tests/feature_check/const.py | 1 + tests/feature_check/native_check.py | 4 ++++ tests/feature_check/set_check.py | 2 +- tests/run-tests.py | 14 +++++++------- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/feature_check/async_check.py b/tests/feature_check/async_check.py index 0f6361cd12..727b7136a5 100644 --- a/tests/feature_check/async_check.py +++ b/tests/feature_check/async_check.py @@ -1,3 +1,6 @@ # check if async/await keywords are supported async def foo(): await 1 + + +print("async") diff --git a/tests/feature_check/const.py b/tests/feature_check/const.py index db32e8c69b..e5928f6d76 100644 --- a/tests/feature_check/const.py +++ b/tests/feature_check/const.py @@ -1 +1,2 @@ x = const(1) +print(x) diff --git a/tests/feature_check/native_check.py b/tests/feature_check/native_check.py index 3971d1355f..4dc9754d0c 100644 --- a/tests/feature_check/native_check.py +++ b/tests/feature_check/native_check.py @@ -2,3 +2,7 @@ @micropython.native def f(): pass + + +f() +print("native") diff --git a/tests/feature_check/set_check.py b/tests/feature_check/set_check.py index ec186cc5b9..0c7612843a 100644 --- a/tests/feature_check/set_check.py +++ b/tests/feature_check/set_check.py @@ -1,2 +1,2 @@ # check if set literal syntax is supported -{1} +print({1}) diff --git a/tests/run-tests.py b/tests/run-tests.py index ae63f9a29a..a5a9b60637 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -279,7 +279,7 @@ def run_tests(pyb, tests, args, result_dir): # Check if micropython.native is supported, and skip such tests if it's not output = run_feature_check(pyb, args, base_path, "native_check.py") - if output == b"CRASH": + if output != b"native\n": skip_native = True # Check if arbitrary-precision integers are supported, and skip such tests if it's not @@ -294,7 +294,7 @@ def run_tests(pyb, tests, args, result_dir): # Check if set type (and set literals) is supported, and skip such tests if it's not output = run_feature_check(pyb, args, base_path, "set_check.py") - if output == b"CRASH": + if output != b"{1}\n": skip_set_type = True # Check if slice is supported, and skip such tests if it's not @@ -304,12 +304,12 @@ def run_tests(pyb, tests, args, result_dir): # Check if async/await keywords are supported, and skip such tests if it's not output = run_feature_check(pyb, args, base_path, "async_check.py") - if output == b"CRASH": + if output != b"async\n": skip_async = True # Check if const keyword (MicroPython extension) is supported, and skip such tests if it's not output = run_feature_check(pyb, args, base_path, "const.py") - if output == b"CRASH": + if output != b"1\n": skip_const = True # Check if __rOP__ special methods are supported, and skip such tests if it's not @@ -334,10 +334,10 @@ def run_tests(pyb, tests, args, result_dir): upy_byteorder = run_feature_check(pyb, args, base_path, "byteorder.py") upy_float_precision = run_feature_check(pyb, args, base_path, "float.py") - if upy_float_precision == b"CRASH": - upy_float_precision = 0 - else: + try: upy_float_precision = int(upy_float_precision) + except ValueError: + upy_float_precision = 0 has_complex = run_feature_check(pyb, args, base_path, "complex.py") == b"complex\n" has_coverage = run_feature_check(pyb, args, base_path, "coverage.py") == b"coverage\n" cpy_byteorder = subprocess.check_output(