summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-xtests/run-tests29
1 files changed, 24 insertions, 5 deletions
diff --git a/tests/run-tests b/tests/run-tests
index e69e537230..cb920c0946 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -18,6 +18,9 @@ else:
CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3')
MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../unix/micropython')
+# mpy-cross is only needed if --via-mpy command-line arg is passed
+MPYCROSS = os.getenv('MICROPY_MPYCROSS', '../mpy-cross/mpy-cross')
+
# Set PYTHONIOENCODING so that CPython will use utf-8 on systems which set another encoding in the locale
os.environ['PYTHONIOENCODING'] = 'utf-8'
os.environ['MICROPYPATH'] = ''
@@ -105,15 +108,30 @@ def run_micropython(pyb, args, test_file):
return b'CRASH'
else:
- # a standard test
- try:
- cmdlist = [MICROPYTHON, '-X', 'emit=' + args.emit]
- if args.heapsize is not None:
- cmdlist.extend(['-X', 'heapsize=' + args.heapsize])
+ # a standard test run on PC
+
+ # create system command
+ cmdlist = [MICROPYTHON, '-X', 'emit=' + args.emit]
+ if args.heapsize is not None:
+ cmdlist.extend(['-X', 'heapsize=' + args.heapsize])
+
+ # if running via .mpy, first compile the .py file
+ if args.via_mpy:
+ subprocess.check_output([MPYCROSS, '-mcache-lookup-bc', '-o', 'mpytest.mpy', test_file])
+ cmdlist.extend(['-m', 'mpytest'])
+ else:
cmdlist.append(test_file)
+
+ # run the actual test
+ try:
output_mupy = subprocess.check_output(cmdlist)
except subprocess.CalledProcessError:
output_mupy = b'CRASH'
+
+ # clean up if we had an intermediate .mpy file
+ if args.via_mpy:
+ rm_f('mpytest.mpy')
+
else:
# run on pyboard
import pyboard
@@ -360,6 +378,7 @@ def main():
cmd_parser.add_argument('--write-exp', action='store_true', help='save .exp files to run tests w/o CPython')
cmd_parser.add_argument('--emit', default='bytecode', help='MicroPython emitter to use (bytecode or native)')
cmd_parser.add_argument('--heapsize', help='heapsize to use (use default if not specified)')
+ cmd_parser.add_argument('--via-mpy', action='store_true', help='compile .py files to .mpy first')
cmd_parser.add_argument('files', nargs='*', help='input test files')
args = cmd_parser.parse_args()