diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-05 22:27:12 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-05 22:27:12 +0100 |
commit | 5a04e2cca8255c2d4a1218d6ac0b38e67306206b (patch) | |
tree | b70ec6a20f17b7282828268725eb4faf915493e6 | |
parent | 854c8c015303d709d3b33f5897dbeff0c10bee9d (diff) | |
download | micropython-5a04e2cca8255c2d4a1218d6ac0b38e67306206b.tar.gz micropython-5a04e2cca8255c2d4a1218d6ac0b38e67306206b.zip |
tests: Add check for micropython.native and then skip relevant tests.
If micropython.native decorator doesn't compile, then we skill all
native/viper tests.
This patch also re-enables the ujson_loads test on NT.
Addresses issue #861, and partially addresses issue #856.
-rw-r--r-- | tests/micropython/native_check.py | 4 | ||||
-rw-r--r-- | tests/micropython/native_check.py.exp | 0 | ||||
-rw-r--r-- | tests/micropython/native_misc.py (renamed from tests/micropython/native.py) | 0 | ||||
-rw-r--r-- | tests/micropython/native_misc.py.exp (renamed from tests/micropython/native.py.exp) | 0 | ||||
-rw-r--r-- | tests/micropython/viper_misc.py (renamed from tests/micropython/viper.py) | 0 | ||||
-rw-r--r-- | tests/micropython/viper_misc.py.exp (renamed from tests/micropython/viper.py.exp) | 0 | ||||
-rwxr-xr-x | tests/run-tests | 39 |
7 files changed, 29 insertions, 14 deletions
diff --git a/tests/micropython/native_check.py b/tests/micropython/native_check.py new file mode 100644 index 0000000000..3971d1355f --- /dev/null +++ b/tests/micropython/native_check.py @@ -0,0 +1,4 @@ +# this test for the availability of native emitter +@micropython.native +def f(): + pass diff --git a/tests/micropython/native_check.py.exp b/tests/micropython/native_check.py.exp new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/micropython/native_check.py.exp diff --git a/tests/micropython/native.py b/tests/micropython/native_misc.py index 8f087c4949..8f087c4949 100644 --- a/tests/micropython/native.py +++ b/tests/micropython/native_misc.py diff --git a/tests/micropython/native.py.exp b/tests/micropython/native_misc.py.exp index e1413fd79f..e1413fd79f 100644 --- a/tests/micropython/native.py.exp +++ b/tests/micropython/native_misc.py.exp diff --git a/tests/micropython/viper.py b/tests/micropython/viper_misc.py index 7e6ed67d44..7e6ed67d44 100644 --- a/tests/micropython/viper.py +++ b/tests/micropython/viper_misc.py diff --git a/tests/micropython/viper.py.exp b/tests/micropython/viper_misc.py.exp index 2ea26ce990..2ea26ce990 100644 --- a/tests/micropython/viper.py.exp +++ b/tests/micropython/viper_misc.py.exp diff --git a/tests/run-tests b/tests/run-tests index cc1020e60a..ca2c376659 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -21,6 +21,24 @@ def rm_f(fname): if os.path.exists(fname): os.remove(fname) +def run_micropython(pyb, args, test_file): + if pyb is None: + # run on PC + try: + output_mupy = subprocess.check_output([MICROPYTHON, '-X', 'emit=' + args.emit, test_file]) + except subprocess.CalledProcessError: + output_mupy = b'CRASH' + else: + # run on pyboard + import pyboard + pyb.enter_raw_repl() + try: + output_mupy = pyb.execfile(test_file).replace(b'\r\n', b'\n') + except pyboard.PyboardError: + output_mupy = b'CRASH' + + return output_mupy + def run_tests(pyb, tests, args): test_count = 0 testcase_count = 0 @@ -30,6 +48,12 @@ def run_tests(pyb, tests, args): skip_tests = set() + # Check if micropython.native is supported, and skip such tests if it's not + native = run_micropython(pyb, args, 'micropython/native_check.py') + if native == b'CRASH': + skip_tests.update({'micropython/native_%s.py' % t for t in 'check misc'.split()}) + skip_tests.update({'micropython/viper_%s.py' % t for t in 'binop_arith binop_comp cond ptr16_store ptr8_store misc'.split()}) + # Some tests shouldn't be run under Travis CI if os.getenv('TRAVIS') == 'true': skip_tests.add('basics/memoryerror.py') @@ -44,7 +68,6 @@ def run_tests(pyb, tests, args): # Some tests use unsupported features on Windows if os.name == 'nt': - skip_tests.add('extmod\\ujson_loads.py') #works but -2e-3 is printed as -0.002000000000000001 except for mingw-w64 skip_tests.add('import\\import_file.py') #works but CPython prints forward slashes skip_tests.add('unix\\ffi_float.py') @@ -91,19 +114,7 @@ def run_tests(pyb, tests, args): continue # run Micro Python - if pyb is None: - # run on PC - try: - output_mupy = subprocess.check_output([MICROPYTHON, '-X', 'emit=' + args.emit, test_file]) - except subprocess.CalledProcessError: - output_mupy = b'CRASH' - else: - # run on pyboard - pyb.enter_raw_repl() - try: - output_mupy = pyb.execfile(test_file).replace(b'\r\n', b'\n') - except pyboard.PyboardError: - output_mupy = b'CRASH' + output_mupy = run_micropython(pyb, args, test_file) if output_mupy == b'SKIP\n': print("skip ", test_file) |