@@ -91,32 +91,44 @@ def cleanup(out):
91
91
92
92
clang_cmd = ['clang' ]
93
93
clang_cmd .extend (cmd .split (' ' ))
94
- p = subprocess .Popen (clang_cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
95
- comm = p .communicate ()
96
- clang_output = cleanup (comm [0 ])
94
+ with subprocess .Popen (clang_cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE ) as p :
95
+ stdout , _ = p .communicate ()
96
+ clang_ec = p .returncode
97
+ clang_output = cleanup (stdout )
97
98
98
99
gcc_cmd = ['gcc' ]
99
100
gcc_cmd .extend (cmd .split (' ' ))
100
- p = subprocess .Popen (gcc_cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
101
- comm = p .communicate ()
102
- gcc_output = cleanup (comm [0 ])
101
+ with subprocess .Popen (gcc_cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE ) as p :
102
+ stdout , _ = p .communicate ()
103
+ gcc_ec = p .returncode
104
+ gcc_output = cleanup (stdout )
103
105
104
106
simplecpp_cmd = ['./simplecpp' ]
105
107
# -E is not supported and we bail out on unknown options
106
108
simplecpp_cmd .extend (cmd .replace ('-E ' , '' , 1 ).split (' ' ))
107
- p = subprocess .Popen (simplecpp_cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
108
- comm = p .communicate ()
109
- simplecpp_ec = p .returncode
110
- simplecpp_output = cleanup (comm [0 ])
111
- simplecpp_err = comm [0 ].decode ('utf-8' ).strip ()
112
-
113
- if simplecpp_output != clang_output and simplecpp_output != gcc_output :
109
+ with subprocess .Popen (simplecpp_cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE ) as p :
110
+ stdout , _ = p .communicate ()
111
+ simplecpp_ec = p .returncode
112
+ simplecpp_output = cleanup (stdout )
113
+ simplecpp_err = stdout .decode ('utf-8' ).strip ()
114
+
115
+ clang_fail = simplecpp_output != clang_output
116
+ gcc_fail = simplecpp_output != gcc_output
117
+ if clang_fail or gcc_fail :
114
118
filename = cmd [cmd .rfind ('/' )+ 1 :]
115
119
if filename in todo :
116
120
print ('TODO ' + cmd )
117
121
usedTodos .append (filename )
118
122
else :
119
- print ('FAILED ' + cmd )
123
+ if clang_fail :
124
+ print ('FAILED (clang) ' + cmd )
125
+ print ('expected:' )
126
+ print (clang_output )
127
+ if gcc_fail :
128
+ print ('FAILED (gcc) ' + cmd )
129
+ print ('expected:' )
130
+ print (gcc_output )
131
+ print ('actual:' )
120
132
if simplecpp_ec :
121
133
print ('simplecpp failed - ' + simplecpp_err )
122
134
numberOfFailed = numberOfFailed + 1
0 commit comments