1515
1616mc_LIKE_TOOLS = [
1717 "llvm-mc" ,
18- "not llvm-mc" ,
1918]
2019ERROR_RE = re .compile (r":\d+: (warning|error): .*" )
2120ERROR_CHECK_RE = re .compile (r"# COM: .*" )
2221OUTPUT_SKIPPED_RE = re .compile (r"(.text)" )
2322COMMENT = {"asm" : "//" , "dasm" : "#" }
2423
2524
26- def invoke_tool (exe , cmd_args , testline , verbose = False ):
25+ def invoke_tool (exe , prefix_not , cmd_args , testline , verbose = False ):
2726 if isinstance (cmd_args , list ):
2827 args = [applySubstitutions (a , substitutions ) for a in cmd_args ]
2928 else :
@@ -32,7 +31,20 @@ def invoke_tool(exe, cmd_args, testline, verbose=False):
3231 cmd = 'echo "' + testline + '" | ' + exe + " " + args
3332 if verbose :
3433 print ("Command: " , cmd )
35- out = subprocess .check_output (cmd , shell = True )
34+
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 )
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 )
45+ else :
46+ raise Exception ("Command '{}' return non-zero value" .format (cmd ))
47+
3648 # Fix line endings to unix CR style.
3749 return out .decode ().replace ("\r \n " , "\n " )
3850
@@ -151,11 +163,16 @@ def main():
151163 assert len (commands ) >= 2
152164 mc_cmd = " | " .join (commands [:- 1 ])
153165 filecheck_cmd = commands [- 1 ]
154- mc_tool = mc_cmd .split (" " )[0 ]
155166
156167 # special handling for negating exit status
157- if mc_tool == "not" :
158- mc_tool = mc_tool + " " + mc_cmd .split (" " )[1 ]
168+ prefix_not = ""
169+ mc_cmd_args = mc_cmd .split (" " )
170+ if mc_cmd_args [0 ] == "not" :
171+ prefix_not = mc_cmd_args [0 ]
172+ mc_tool = mc_cmd_args [1 ]
173+ mc_cmd = mc_cmd [len (mc_cmd_args [0 ]) :].strip ()
174+ else :
175+ mc_tool = mc_cmd_args [0 ]
159176
160177 triple_in_cmd = None
161178 m = common .TRIPLE_ARG_RE .search (mc_cmd )
@@ -188,6 +205,7 @@ def main():
188205 (
189206 check_prefixes ,
190207 mc_tool ,
208+ prefix_not ,
191209 mc_cmd_args ,
192210 triple_in_cmd ,
193211 march_in_cmd ,
@@ -204,6 +222,7 @@ def main():
204222 for (
205223 prefixes ,
206224 mc_tool ,
225+ prefix_not ,
207226 mc_args ,
208227 triple_in_cmd ,
209228 march_in_cmd ,
@@ -222,6 +241,7 @@ def main():
222241 # get output for each testline
223242 out = invoke_tool (
224243 ti .args .llvm_mc_binary or mc_tool ,
244+ prefix_not ,
225245 mc_args ,
226246 line ,
227247 verbose = ti .args .verbose ,
0 commit comments