2222COMMENT = {"asm" : "//" , "dasm" : "#" }
2323
2424
25- def invoke_tool (exe , prefix_not , cmd_args , testline , verbose = False ):
25+ def invoke_tool (exe , checkRC , cmd_args , testline , verbose = False ):
2626 if isinstance (cmd_args , list ):
2727 args = [applySubstitutions (a , substitutions ) for a in cmd_args ]
2828 else :
@@ -32,18 +32,13 @@ def invoke_tool(exe, prefix_not, cmd_args, testline, verbose=False):
3232 if verbose :
3333 print ("Command: " , cmd )
3434
35- # if not is used in runline, the command might or might not
36- # return non-zero code on a single line run
37- try :
38- out = subprocess .check_output (cmd , shell = True , stderr = subprocess .DEVNULL )
39- except :
40- if prefix_not :
41- cmd = 'echo "' + testline + '" | ' + "not " + exe + " " + args
42- if verbose :
43- print ("Command: " , cmd )
44- out = subprocess .check_output (cmd , shell = True , stderr = subprocess .DEVNULL )
45- else :
46- raise Exception ("Command '{}' return non-zero value" .format (cmd ))
35+ out = subprocess .run (
36+ cmd ,
37+ shell = True ,
38+ check = checkRC ,
39+ stdout = subprocess .PIPE ,
40+ stderr = subprocess .DEVNULL ,
41+ ).stdout
4742
4843 # Fix line endings to unix CR style.
4944 return out .decode ().replace ("\r \n " , "\n " )
@@ -173,10 +168,13 @@ def main():
173168 filecheck_cmd = commands [- 1 ]
174169
175170 # special handling for negating exit status
176- prefix_not = ""
177- mc_cmd_args = mc_cmd .split (" " )
171+ # if not is used in runline, disable rc check, since
172+ # the command might or might not
173+ # return non-zero code on a single line run
174+ checkRC = True
175+ mc_cmd_args = mc_cmd .strip ().split ()
178176 if mc_cmd_args [0 ] == "not" :
179- prefix_not = mc_cmd_args [ 0 ]
177+ checkRC = False
180178 mc_tool = mc_cmd_args [1 ]
181179 mc_cmd = mc_cmd [len (mc_cmd_args [0 ]) :].strip ()
182180 else :
@@ -213,7 +211,7 @@ def main():
213211 (
214212 check_prefixes ,
215213 mc_tool ,
216- prefix_not ,
214+ checkRC ,
217215 mc_cmd_args ,
218216 triple_in_cmd ,
219217 march_in_cmd ,
@@ -230,7 +228,7 @@ def main():
230228 for (
231229 prefixes ,
232230 mc_tool ,
233- prefix_not ,
231+ checkRC ,
234232 mc_args ,
235233 triple_in_cmd ,
236234 march_in_cmd ,
@@ -249,7 +247,7 @@ def main():
249247 # get output for each testline
250248 out = invoke_tool (
251249 ti .args .llvm_mc_binary or mc_tool ,
252- prefix_not ,
250+ checkRC ,
253251 mc_args ,
254252 line ,
255253 verbose = ti .args .verbose ,
0 commit comments