Skip to content

Commit 8459f53

Browse files
committed
tests/feature_check: Check for lack of pass result rather than failure.
Commit cb68a57 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 <[email protected]>
1 parent 7f366a2 commit 8459f53

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

tests/feature_check/async_check.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# check if async/await keywords are supported
22
async def foo():
33
await 1
4+
5+
6+
print("async")

tests/feature_check/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
x = const(1)
2+
print(x)

tests/feature_check/native_check.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
@micropython.native
33
def f():
44
pass
5+
6+
7+
f()
8+
print("native")

tests/feature_check/set_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# check if set literal syntax is supported
2-
{1}
2+
print({1})

tests/run-tests.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def run_tests(pyb, tests, args, result_dir):
279279

280280
# Check if micropython.native is supported, and skip such tests if it's not
281281
output = run_feature_check(pyb, args, base_path, "native_check.py")
282-
if output == b"CRASH":
282+
if output != b"native\n":
283283
skip_native = True
284284

285285
# 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):
294294

295295
# Check if set type (and set literals) is supported, and skip such tests if it's not
296296
output = run_feature_check(pyb, args, base_path, "set_check.py")
297-
if output == b"CRASH":
297+
if output != b"{1}\n":
298298
skip_set_type = True
299299

300300
# 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):
304304

305305
# Check if async/await keywords are supported, and skip such tests if it's not
306306
output = run_feature_check(pyb, args, base_path, "async_check.py")
307-
if output == b"CRASH":
307+
if output != b"async\n":
308308
skip_async = True
309309

310310
# Check if const keyword (MicroPython extension) is supported, and skip such tests if it's not
311311
output = run_feature_check(pyb, args, base_path, "const.py")
312-
if output == b"CRASH":
312+
if output != b"1\n":
313313
skip_const = True
314314

315315
# 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):
334334

335335
upy_byteorder = run_feature_check(pyb, args, base_path, "byteorder.py")
336336
upy_float_precision = run_feature_check(pyb, args, base_path, "float.py")
337-
if upy_float_precision == b"CRASH":
338-
upy_float_precision = 0
339-
else:
337+
try:
340338
upy_float_precision = int(upy_float_precision)
339+
except ValueError:
340+
upy_float_precision = 0
341341
has_complex = run_feature_check(pyb, args, base_path, "complex.py") == b"complex\n"
342342
has_coverage = run_feature_check(pyb, args, base_path, "coverage.py") == b"coverage\n"
343343
cpy_byteorder = subprocess.check_output(

0 commit comments

Comments
 (0)