From 26f00ff154e68f623bd312a78f92051fea2f6d4e Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 5 Jan 2017 00:16:29 +0300 Subject: tests/run-tests: Allow to skip set tests. If sets are not enabled, set literals lead to SyntaxError during parsing, so it requires feature_check. Set tests are skipped based on set_*.py pattern. --- tests/basics/set1.py | 17 ----------------- tests/basics/set_basic.py | 17 +++++++++++++++++ tests/feature_check/set_check.py | 2 ++ tests/feature_check/set_check.py.exp | 0 tests/run-tests | 14 +++++++++++++- 5 files changed, 32 insertions(+), 18 deletions(-) delete mode 100644 tests/basics/set1.py create mode 100644 tests/basics/set_basic.py create mode 100644 tests/feature_check/set_check.py create mode 100644 tests/feature_check/set_check.py.exp (limited to 'tests') diff --git a/tests/basics/set1.py b/tests/basics/set1.py deleted file mode 100644 index 6ea69e4f0..000000000 --- a/tests/basics/set1.py +++ /dev/null @@ -1,17 +0,0 @@ -# basic sets - -s = {1} -print(s) - -s = {3, 4, 3, 1} -print(sorted(s)) - -# expression in constructor -s = {1 + len(s)} -print(s) - -# Sets are not hashable -try: - {s: 1} -except TypeError: - print("TypeError") diff --git a/tests/basics/set_basic.py b/tests/basics/set_basic.py new file mode 100644 index 000000000..6ea69e4f0 --- /dev/null +++ b/tests/basics/set_basic.py @@ -0,0 +1,17 @@ +# basic sets + +s = {1} +print(s) + +s = {3, 4, 3, 1} +print(sorted(s)) + +# expression in constructor +s = {1 + len(s)} +print(s) + +# Sets are not hashable +try: + {s: 1} +except TypeError: + print("TypeError") diff --git a/tests/feature_check/set_check.py b/tests/feature_check/set_check.py new file mode 100644 index 000000000..ec186cc5b --- /dev/null +++ b/tests/feature_check/set_check.py @@ -0,0 +1,2 @@ +# check if set literal syntax is supported +{1} diff --git a/tests/feature_check/set_check.py.exp b/tests/feature_check/set_check.py.exp new file mode 100644 index 000000000..e69de29bb diff --git a/tests/run-tests b/tests/run-tests index 3bfa73e04..91282667d 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -195,12 +195,18 @@ def run_tests(pyb, tests, args): skip_tests = set() skip_native = False + skip_set_type = False # Check if micropython.native is supported, and skip such tests if it's not native = run_micropython(pyb, args, 'feature_check/native_check.py') if native == b'CRASH': skip_native = True + # Check if set type (and set literals) is supported, and skip such tests if it's not + native = run_micropython(pyb, args, 'feature_check/set_check.py') + if native == b'CRASH': + skip_set_type = True + # Check if emacs repl is supported, and skip such tests if it's not t = run_micropython(pyb, args, 'feature_check/repl_emacs_check.py') if not 'True' in str(t, 'ascii'): @@ -304,8 +310,14 @@ def run_tests(pyb, tests, args): test_name = os.path.splitext(test_basename)[0] is_native = test_name.startswith("native_") or test_name.startswith("viper_") is_endian = test_name.endswith("_endian") + is_set_type = test_name.startswith("set_") + + skip_it = test_file in skip_tests + skip_it |= skip_native and is_native + skip_it |= skip_endian and is_endian + skip_it |= skip_set_type and is_set_type - if test_file in skip_tests or (skip_native and is_native) or (skip_endian and is_endian): + if skip_it: print("skip ", test_file) skipped_tests.append(test_name) continue -- cgit v1.2.3