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.
This commit is contained in:
parent
854c8c0153
commit
5a04e2cca8
4
tests/micropython/native_check.py
Normal file
4
tests/micropython/native_check.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# this test for the availability of native emitter
|
||||||
|
@micropython.native
|
||||||
|
def f():
|
||||||
|
pass
|
0
tests/micropython/native_check.py.exp
Normal file
0
tests/micropython/native_check.py.exp
Normal file
@ -21,6 +21,24 @@ def rm_f(fname):
|
|||||||
if os.path.exists(fname):
|
if os.path.exists(fname):
|
||||||
os.remove(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):
|
def run_tests(pyb, tests, args):
|
||||||
test_count = 0
|
test_count = 0
|
||||||
testcase_count = 0
|
testcase_count = 0
|
||||||
@ -30,6 +48,12 @@ def run_tests(pyb, tests, args):
|
|||||||
|
|
||||||
skip_tests = set()
|
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
|
# Some tests shouldn't be run under Travis CI
|
||||||
if os.getenv('TRAVIS') == 'true':
|
if os.getenv('TRAVIS') == 'true':
|
||||||
skip_tests.add('basics/memoryerror.py')
|
skip_tests.add('basics/memoryerror.py')
|
||||||
@ -44,7 +68,6 @@ def run_tests(pyb, tests, args):
|
|||||||
|
|
||||||
# Some tests use unsupported features on Windows
|
# Some tests use unsupported features on Windows
|
||||||
if os.name == 'nt':
|
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('import\\import_file.py') #works but CPython prints forward slashes
|
||||||
skip_tests.add('unix\\ffi_float.py')
|
skip_tests.add('unix\\ffi_float.py')
|
||||||
|
|
||||||
@ -91,19 +114,7 @@ def run_tests(pyb, tests, args):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# run Micro Python
|
# run Micro Python
|
||||||
if pyb is None:
|
output_mupy = run_micropython(pyb, args, test_file)
|
||||||
# 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'
|
|
||||||
|
|
||||||
if output_mupy == b'SKIP\n':
|
if output_mupy == b'SKIP\n':
|
||||||
print("skip ", test_file)
|
print("skip ", test_file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user