From a8422439ab5e86eeaceae09c4655101225fe5fce Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 3 Dec 2024 12:31:50 +1100 Subject: [PATCH] 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 --- tests/run-tests.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/run-tests.py b/tests/run-tests.py index 0e491ccd6..6fe45707b 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -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)