6 from concurrent
.futures
import ThreadPoolExecutor
, as_completed
8 def remove_prefix(i
, d
=0):
11 s
= os
.popen('llvm-lit -a ' + i
).read()
12 r
= re
.search('no check strings found with (?:prefix|prefixes) \'([^:]+)', s
)
13 with
open(i
, 'r+') as f
:
17 s
= re
.sub('=' + p
+ ',', '=', s
)
18 s
= re
.sub(',' + p
+ '([, \n])', '\\1', s
)
19 s
= re
.sub('\s+-?-check-prefix=' + p
+ '([ \n])', '\\1', s
)
21 s
= re
.sub('-?-check-prefixes=([\w-]+)(\Z|[ \t\n])', '--check-prefix=\\1\\2', s
)
22 t
= re
.search('-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)', s
)
24 s
= re
.sub(t
.group(), '--check-prefixes=' + t
.group(1) + ',' + t
.group(2), s
)
25 t
= re
.search('-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)', s
)
26 s
= re
.sub('\s+-?-check-prefix=CHECK[ \t]*\n', '\n', s
)
31 t
= re
.search('Assertions have been autogenerated by (.*)', s
)
33 s
= os
.popen('llvm/' + t
.group(1) + ' ' + i
+ ' 2>&1').read()
34 if 'had conflicting output from different RUN lines for all functions' in s
:
36 s
= os
.popen('git diff ' + i
).read()
37 if re
.search('\n(?:-+)\n', s
) or re
.search('\n[+-].*(?<!RUN):', s
):
40 return remove_prefix(i
, d
+1)
42 with
ThreadPoolExecutor(max_workers
=32) as e
:
46 t
= { e
.submit(remove_prefix
, i
): i
for i
in sys
.argv
[1:] }
47 for i
in as_completed(t
):
49 print('DONE:', end
=' ')
50 elif i
.result() == -1:
51 print('FAIL:', end
=' ')
54 print('CHANGE:', end
=' ')
57 print('ABORT:', end
=' ')
60 for i
in [ (f
, 'Failed'), (c
, 'Changed'), (a
, 'Aborted') ]:
62 print('********************\n%s Tests (%d):' % (i
[1], len(i
[0])))