Skip to content

Commit be85a49

Browse files
pbalcerPetr Vesely
andcommitted
[test] improve match file error output
When a test fails a match, cmakes print both the input file and the match file, so that it's easy to see why the failure happened and how to fix it. Unfortunately, cmake was inserting 3 newlines between every line of both input and match files, making things hard to read. This patch fixes this by moving match and input files printing to the python script. Co-authored-by: Petr Vesely <petr.vesely@codeplay.com>
1 parent 4c6d556 commit be85a49

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cmake/match.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ execute_process(
7171
)
7272

7373
if(TEST_RESULT)
74-
file(READ ${OUT_FILE} OUTPUT)
75-
file(READ ${MATCH_FILE} MATCH_STRING)
76-
message(FATAL_ERROR "Failed: The output of ${OUT_FILE}:\n ${OUTPUT}\n does not match ${MATCH_FILE}:\n ${MATCH_STRING} (${TEST_RESULT})")
74+
message(FATAL_ERROR "Failed (${TEST_RESULT}): The output of ${OUT_FILE} does not match ${MATCH_FILE}")
7775
elseif()
7876
message("Passed: The output ${OUT_FILE} matches ${MATCH_FILE}")
7977
endif()

cmake/match.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
print("Line " + str(i+1) + " does not match")
6161
print("is: " + input_line)
6262
print("expected: " + match_line.strip())
63+
print("--- Input Lines " + "-" * 64)
64+
print("".join(input_lines).strip())
65+
print("--- Match Lines " + "-" * 64)
66+
print("".join(match_lines).strip())
67+
print("-" * 80)
6368
sys.exit(1)
6469
else:
6570
if (input_idx == len(input_lines) - 1):

0 commit comments

Comments
 (0)