[OpenACC] Enable 'attach' clause for combined constructs
[llvm-project.git] / llvm / utils / update_test_prefix.py
blob434dc84fa4fc0326a0f0f52a56f148d444acd4f9
1 #!/usr/bin/env python3
3 import os
4 import re
5 import sys
6 from concurrent.futures import ThreadPoolExecutor, as_completed
9 def remove_prefix(i, d=0):
10 if d == 100:
11 return 2
12 s = os.popen("llvm-lit -a " + i).read()
13 r = re.search("no check strings found with (?:prefix|prefixes) '([^:]+)", s)
14 with open(i, "r+") as f:
15 s = f.read()
16 if r:
17 p = r.group(1)
18 s = re.sub("=" + p + ",", "=", s)
19 s = re.sub("," + p + "([, \n])", "\\1", s)
20 s = re.sub("\s+-?-check-prefix=" + p + "([ \n])", "\\1", s)
21 else:
22 s = re.sub(
23 "-?-check-prefixes=([\w-]+)(\Z|[ \t\n])", "--check-prefix=\\1\\2", s
25 t = re.search(
26 "-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)",
29 while t:
30 s = re.sub(
31 t.group(), "--check-prefixes=" + t.group(1) + "," + t.group(2), s
33 t = re.search(
34 "-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)",
37 s = re.sub("\s+-?-check-prefix=CHECK[ \t]*\n", "\n", s)
38 f.truncate(0)
39 f.seek(0)
40 f.write(s)
41 if not r:
42 t = re.search("Assertions have been autogenerated by (.*)", s)
43 if t:
44 s = os.popen("llvm/" + t.group(1) + " " + i + " 2>&1").read()
45 if "had conflicting output from different RUN lines for all functions" in s:
46 return -1
47 s = os.popen("git diff " + i).read()
48 if re.search("\n(?:-+)\n", s) or re.search("\n[+-].*(?<!RUN):", s):
49 return 1
50 return 0
51 return remove_prefix(i, d + 1)
54 with ThreadPoolExecutor(max_workers=32) as e:
55 f = []
56 c = []
57 a = []
58 t = {e.submit(remove_prefix, i): i for i in sys.argv[1:]}
59 for i in as_completed(t):
60 if i.result() == 0:
61 print("DONE:", end=" ")
62 elif i.result() == -1:
63 print("FAIL:", end=" ")
64 f.append(t[i])
65 elif i.result() == 1:
66 print("CHANGE:", end=" ")
67 c.append(t[i])
68 else:
69 print("ABORT:", end=" ")
70 a.append(t[i])
71 print(t[i])
72 for i in [(f, "Failed"), (c, "Changed"), (a, "Aborted")]:
73 if i[0]:
74 print("********************\n%s Tests (%d):" % (i[1], len(i[0])))
75 for j in i[0]:
76 print(" " + j)