@@ -91,32 +91,44 @@ def cleanup(out):
9191
9292 clang_cmd = ['clang' ]
9393 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 )
9798
9899 gcc_cmd = ['gcc' ]
99100 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 )
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 (' ' ))
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 :
114118 filename = cmd [cmd .rfind ('/' )+ 1 :]
115119 if filename in todo :
116120 print ('TODO ' + cmd )
117121 usedTodos .append (filename )
118122 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:' )
120132 if simplecpp_ec :
121133 print ('simplecpp failed - ' + simplecpp_err )
122134 numberOfFailed = numberOfFailed + 1
0 commit comments