tests/run-tests.py: Handle case where mpy-cross fails to compile script.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-05-23 11:10:37 +10:00
parent a8492253c1
commit 7d3204783a
2 changed files with 20 additions and 8 deletions

View File

@ -120,7 +120,10 @@ def run_benchmarks(args, target, param_n, param_m, n_average, test_list):
# Process script through mpy-cross if needed
if isinstance(target, pyboard.Pyboard) or args.via_mpy:
test_script_target = prepare_script_for_target(args, script_text=test_script)
crash, test_script_target = prepare_script_for_target(args, script_text=test_script)
if crash:
print("CRASH:", test_script_target)
continue
else:
test_script_target = test_script

View File

@ -122,11 +122,15 @@ def prepare_script_for_target(args, *, script_filename=None, script_text=None, f
else:
cleanup_script_filename = False
subprocess.check_output(
[MPYCROSS]
+ args.mpy_cross_flags.split()
+ ["-o", mpy_filename, "-X", "emit=" + args.emit, script_filename]
)
try:
subprocess.check_output(
[MPYCROSS]
+ args.mpy_cross_flags.split()
+ ["-o", mpy_filename, "-X", "emit=" + args.emit, script_filename],
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError as er:
return True, b"mpy-cross crash\n" + er.output
with open(mpy_filename, "rb") as f:
script_text = b"__buf=" + bytes(repr(f.read()), "ascii") + b"\n"
@ -140,11 +144,16 @@ def prepare_script_for_target(args, *, script_filename=None, script_text=None, f
print("error: using emit={} must go via .mpy".format(args.emit))
sys.exit(1)
return script_text
return False, script_text
def run_script_on_remote_target(pyb, args, test_file, is_special):
script = prepare_script_for_target(args, script_filename=test_file, force_plain=is_special)
had_crash, script = prepare_script_for_target(
args, script_filename=test_file, force_plain=is_special
)
if had_crash:
return True, script
try:
had_crash = False
pyb.enter_raw_repl()