Skip to content

Commit 187633a

Browse files
authored
Merge pull request #904 from lukaszstolarczuk/fix-match.py
[UR][Tests] Update match scripts
2 parents 00c7edb + 19597b2 commit 187633a

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

cmake/match.cmake

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ elseif(${MODE} STREQUAL "file")
6161
endif()
6262

6363
if(TEST_RESULT)
64-
message(FATAL_ERROR "Failed: Test ${TEST_FILE} ${TEST_ARGS} returned non-zero (${TEST_RESULT}).")
64+
message(FATAL_ERROR "Failed: Test command '${TEST_FILE} ${TEST_ARGS}' returned non-zero (${TEST_RESULT}).")
6565
endif()
6666

6767
# Compare the output file contents with a match file contents
@@ -71,11 +71,7 @@ execute_process(
7171
)
7272

7373
if(TEST_RESULT)
74-
message(FATAL_ERROR "Failed (${TEST_RESULT}): The output of ${OUT_FILE} does not match ${MATCH_FILE}")
75-
elseif()
76-
message("Passed: The output ${OUT_FILE} matches ${MATCH_FILE}")
77-
endif()
78-
79-
if(EXISTS ${OUT_FILE})
80-
file(REMOVE ${OUT_FILE})
74+
message(FATAL_ERROR "Failed (${TEST_RESULT}): The output of test command '${TEST_FILE} ${TEST_ARGS}' (stored in ${CMAKE_CURRENT_BINARY_DIR}/${OUT_FILE}) does not match '${MATCH_FILE}'")
75+
else()
76+
message("Passed: The output of test command '${TEST_FILE} ${TEST_ARGS}' (stored in ${CMAKE_CURRENT_BINARY_DIR}/${OUT_FILE}) matches '${MATCH_FILE}'")
8177
endif()

cmake/match.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
import sys
1212
import re
1313

14+
15+
## @brief print the whole content of input and match files
16+
def print_content(input_lines, match_lines):
17+
print("--- Input Lines " + "-" * 64)
18+
print("".join(input_lines).strip())
19+
print("--- Match Lines " + "-" * 64)
20+
print("".join(match_lines).strip())
21+
print("-" * 80)
22+
23+
1424
if len(sys.argv) != 3:
1525
print("Usage: python match.py <input_file> <match_file>")
1626
sys.exit(1)
@@ -23,7 +33,9 @@
2333
match_lines = match.readlines()
2434

2535
if len(match_lines) < len(input_lines):
26-
sys.exit(f"Match length < input length (input: {len(input_lines)}, match: {len(match_lines)})")
36+
print(f"Match length < input length (input: {len(input_lines)}, match: {len(match_lines)})")
37+
print_content(input_lines, match_lines)
38+
sys.exit(1)
2739

2840
input_idx = 0
2941
opt = "{{OPT}}"
@@ -60,11 +72,7 @@
6072
print("Line " + str(i+1) + " does not match")
6173
print("is: " + input_line)
6274
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)
75+
print_content(input_lines, match_lines)
6876
sys.exit(1)
6977
else:
7078
if (input_idx == len(input_lines) - 1):

0 commit comments

Comments
 (0)