forked from llvm/llvm-project
- Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathupdate_test_prefix.py
executable file
·64 lines (61 loc) · 2.32 KB
/
update_test_prefix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
importos
importre
importsys
fromconcurrent.futuresimportThreadPoolExecutor, as_completed
defremove_prefix(i, d=0):
ifd==100:
return2
s=os.popen('llvm-lit -a '+i).read()
r=re.search('no check strings found with (?:prefix|prefixes) \'([^:]+)', s)
withopen(i, 'r+') asf:
s=f.read()
ifr:
p=r.group(1)
s=re.sub('='+p+',', '=', s)
s=re.sub(','+p+'([, \n])', '\\1', s)
s=re.sub('\s+-?-check-prefix='+p+'([ \n])', '\\1', s)
else:
s=re.sub('-?-check-prefixes=([\w-]+)(\Z|[ \t\n])', '--check-prefix=\\1\\2', s)
t=re.search('-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)', s)
whilet:
s=re.sub(t.group(), '--check-prefixes='+t.group(1) +','+t.group(2), s)
t=re.search('-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)', s)
s=re.sub('\s+-?-check-prefix=CHECK[ \t]*\n', '\n', s)
f.truncate(0)
f.seek(0)
f.write(s)
ifnotr:
t=re.search('Assertions have been autogenerated by (.*)', s)
ift:
s=os.popen('llvm/'+t.group(1) +' '+i+' 2>&1').read()
if'had conflicting output from different RUN lines for all functions'ins:
return-1
s=os.popen('git diff '+i).read()
ifre.search('\n(?:-+)\n', s) orre.search('\n[+-].*(?<!RUN):', s):
return1
return0
returnremove_prefix(i, d+1)
withThreadPoolExecutor(max_workers=32) ase:
f= []
c= []
a= []
t= { e.submit(remove_prefix, i): iforiinsys.argv[1:] }
foriinas_completed(t):
ifi.result() ==0:
print('DONE:', end=' ')
elifi.result() ==-1:
print('FAIL:', end=' ')
f.append(t[i])
elifi.result() ==1:
print('CHANGE:', end=' ')
c.append(t[i])
else:
print('ABORT:', end=' ')
a.append(t[i])
print(t[i])
foriin [ (f, 'Failed'), (c, 'Changed'), (a, 'Aborted') ]:
ifi[0]:
print('********************\n%s Tests (%d):'% (i[1], len(i[0])))
forjini[0]:
print(' '+j)