Skip to content

Commit 353d195

Browse files
committed
run-tests.py: improved output when test failed
1 parent 0fbcc04 commit 353d195

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

run-tests.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def cleanup(out):
88
ret = ''
9-
for s in out.decode('utf-8').split('\n'):
9+
for s in out.decode('utf-8').splitlines():
1010
if len(s) > 1 and s[0] == '#':
1111
continue
1212
s = "".join(s.split())
@@ -93,30 +93,45 @@ def cleanup(out):
9393
clang_cmd.extend(cmd.split(' '))
9494
p = subprocess.Popen(clang_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
9595
comm = p.communicate()
96-
clang_output = cleanup(comm[0])
96+
clang_output = comm[0]
97+
clang_output_c = cleanup(comm[0])
9798

9899
gcc_cmd = ['gcc']
99100
gcc_cmd.extend(cmd.split(' '))
100101
p = subprocess.Popen(gcc_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
101102
comm = p.communicate()
102-
gcc_output = cleanup(comm[0])
103+
gcc_output = comm[0]
104+
gcc_output_c = cleanup(comm[0])
103105

104106
simplecpp_cmd = ['./simplecpp']
105107
# -E is not supported and we bail out on unknown options
106108
simplecpp_cmd.extend(cmd.replace('-E ', '', 1).split(' '))
107109
p = subprocess.Popen(simplecpp_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
108110
comm = p.communicate()
109111
simplecpp_ec = p.returncode
110-
simplecpp_output = cleanup(comm[0])
112+
simplecpp_output = comm[0]
113+
simplecpp_output_c = cleanup(comm[0])
111114
simplecpp_err = comm[0].decode('utf-8').strip()
112115

113-
if simplecpp_output != clang_output and simplecpp_output != gcc_output:
116+
if simplecpp_output_c != clang_output_c and simplecpp_output_c != gcc_output_c:
114117
filename = cmd[cmd.rfind('/')+1:]
115118
if filename in todo:
116119
print('TODO ' + cmd)
117120
usedTodos.append(filename)
118121
else:
119122
print('FAILED ' + cmd)
123+
print('---expected (clang):')
124+
print(clang_output_c)
125+
print('---expected (gcc):')
126+
print(gcc_output_c)
127+
print('---actual:')
128+
print(simplecpp_output_c)
129+
print('---actual:')
130+
print(simplecpp_output)
131+
print('---original (clang):')
132+
print(clang_output)
133+
print('---original (gcc):')
134+
print(gcc_output)
120135
if simplecpp_ec:
121136
print('simplecpp failed - ' + simplecpp_err)
122137
numberOfFailed = numberOfFailed + 1

0 commit comments

Comments
 (0)