Skip to content

Commit ce6c58d

Browse files
committed
run-tests.py: improved output when test failed
1 parent 6e6e1e8 commit ce6c58d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

run-tests.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def cleanup(out: str) -> str:
9292
]
9393

9494

95-
def run(compiler_executable: str, compiler_args: list[str]) -> tuple[int, str, str]:
95+
def run(compiler_executable: str, compiler_args: list[str]) -> tuple[int, str, str, str]:
9696
"""Execute a compiler command and capture its exit code, stdout, and stderr."""
9797
compiler_cmd = [compiler_executable]
9898
compiler_cmd.extend(compiler_args)
@@ -103,7 +103,7 @@ def run(compiler_executable: str, compiler_args: list[str]) -> tuple[int, str, s
103103

104104
output = cleanup(stdout)
105105
error = (stderr or "").strip()
106-
return (exit_code, output, error)
106+
return (exit_code, output, stdout, error)
107107

108108

109109
numberOfSkipped = 0
@@ -117,20 +117,32 @@ def run(compiler_executable: str, compiler_args: list[str]) -> tuple[int, str, s
117117
numberOfSkipped = numberOfSkipped + 1
118118
continue
119119

120-
_, clang_output, _ = run(CLANG_EXE, cmd.split(' '))
120+
_, clang_output_c, clang_output, _ = run(CLANG_EXE, cmd.split(' '))
121121

122-
_, gcc_output, _ = run(GCC_EXE, cmd.split(' '))
122+
_, gcc_output_c, gcc_output, _ = run(GCC_EXE, cmd.split(' '))
123123

124124
# -E is not supported and we bail out on unknown options
125-
simplecpp_ec, simplecpp_output, simplecpp_err = run(SIMPLECPP_EXE, cmd.replace('-E ', '', 1).split(' '))
125+
simplecpp_ec, simplecpp_output_c, simplecpp_output, simplecpp_err = run(SIMPLECPP_EXE, cmd.replace('-E ', '', 1).split(' '))
126126

127-
if simplecpp_output != clang_output and simplecpp_output != gcc_output:
127+
if simplecpp_output_c != clang_output_c and simplecpp_output_c != gcc_output_c:
128128
filename = cmd[cmd.rfind('/')+1:]
129129
if filename in todo:
130130
print('TODO ' + cmd)
131131
usedTodos.append(filename)
132132
else:
133133
print('FAILED ' + cmd)
134+
print('---expected (clang):')
135+
print(clang_output_c)
136+
print('---expected (gcc):')
137+
print(gcc_output_c)
138+
print('---actual:')
139+
print(simplecpp_output_c)
140+
print('---output (clang):')
141+
print(clang_output)
142+
print('---output (gcc):')
143+
print(gcc_output)
144+
print('---output (simplecpp):')
145+
print(simplecpp_output)
134146
if simplecpp_ec:
135147
print('simplecpp failed - ' + simplecpp_err)
136148
numberOfFailed = numberOfFailed + 1

0 commit comments

Comments
 (0)