Skip to content

Commit 49e0dd5

Browse files
committed
tests/run-tests: Capture any output from a crashed uPy execution.
Instead of putting just 'CRASH' in the .py.out file, this patch makes it so any output from uPy that led to the crash is stored in the .py.out file, as well as the 'CRASH' message at the end.
1 parent 04c55f5 commit 49e0dd5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tests/run-tests

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def run_micropython(pyb, args, test_file, is_special=False):
5454
'micropython/meminfo.py', 'basics/bytes_compare3.py',
5555
'basics/builtin_help.py', 'thread/thread_exc2.py',
5656
)
57+
had_crash = False
5758
if pyb is None:
5859
# run on PC
5960
if test_file.startswith(('cmdline/', 'feature_check/')) or test_file in special_tests:
@@ -128,8 +129,9 @@ def run_micropython(pyb, args, test_file, is_special=False):
128129
# run the actual test
129130
try:
130131
output_mupy = subprocess.check_output(cmdlist, stderr=subprocess.STDOUT)
131-
except subprocess.CalledProcessError:
132-
output_mupy = b'CRASH'
132+
except subprocess.CalledProcessError as er:
133+
had_crash = True
134+
output_mupy = er.output + b'CRASH'
133135

134136
# clean up if we had an intermediate .mpy file
135137
if args.via_mpy:
@@ -142,13 +144,14 @@ def run_micropython(pyb, args, test_file, is_special=False):
142144
try:
143145
output_mupy = pyb.execfile(test_file)
144146
except pyboard.PyboardError:
147+
had_crash = True
145148
output_mupy = b'CRASH'
146149

147150
# canonical form for all ports/platforms is to use \n for end-of-line
148151
output_mupy = output_mupy.replace(b'\r\n', b'\n')
149152

150153
# don't try to convert the output if we should skip this test
151-
if output_mupy in (b'SKIP\n', b'CRASH'):
154+
if had_crash or output_mupy in (b'SKIP\n', b'CRASH'):
152155
return output_mupy
153156

154157
if is_special or test_file in special_tests:

0 commit comments

Comments
 (0)