tests/run-tests.py: Print .out file when there is no .exp file.

So that a failing unittest-based test has its entire log printed when using
`run-tests.py --print-failures`.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-12-03 12:31:50 +11:00
parent a2554f0957
commit a8422439ab

View File

@@ -1154,11 +1154,18 @@ the last matching regex is used:
args = cmd_parser.parse_args()
if args.print_failures:
for exp in glob(os.path.join(args.result_dir, "*.exp")):
testbase = exp[:-4]
for out in glob(os.path.join(args.result_dir, "*.out")):
testbase = out[:-4]
print()
print("FAILURE {0}".format(testbase))
os.system("{0} {1}.exp {1}.out".format(DIFF, testbase))
if os.path.exists(testbase + ".exp"):
# Show diff of expected and actual output.
os.system("{0} {1}.exp {1}.out".format(DIFF, testbase))
else:
# No expected output, just show the actual output (eg from a unittest).
with open(out) as f:
for line in f:
print(line, end="")
sys.exit(0)