diff options
| author | Damien George <damien@micropython.org> | 2022-05-23 11:10:37 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-05-23 15:45:21 +1000 |
| commit | 7d3204783a3550ab8a5a848901e0e512d54a4163 (patch) | |
| tree | 4e82ec6915455ec4e874a1401f522cbc5241d5fd /tests/run-tests.py | |
| parent | a8492253c126be9bef69110c6a6862872868dfbc (diff) | |
tests/run-tests.py: Handle case where mpy-cross fails to compile script.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/run-tests.py')
| -rwxr-xr-x | tests/run-tests.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/run-tests.py b/tests/run-tests.py index 35e28aac9..1fc857601 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -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() |
