Skip to content

Commit 76653ab

Browse files
committed
Make update_any_test_check.py script accepting @ListFile CL argument.
1 parent e82765b commit 76653ab

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

llvm/utils/update_any_test_checks.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
55
Given a list of test files, this script will invoke the correct
66
update_test_checks-style script, skipping any tests which have not previously
7-
had assertions autogenerated.
7+
had assertions autogenerated. If test name starts with '@' it's treated as
8+
a name of file containing test list.
89
"""
910

1011
from __future__ import print_function
@@ -39,6 +40,22 @@ def run_utc_tool(utc_name, utc_tool, testname):
3940
)
4041
return (result.returncode, result.stdout, result.stderr)
4142

43+
def read_arguments_from_file(filename):
44+
try:
45+
with open(filename, 'r') as file:
46+
return [line.rstrip() for line in file.readlines()]
47+
except FileNotFoundError:
48+
print(f"Error: File '{filename}' not found.")
49+
sys.exit(1)
50+
51+
def expand_listfile_args(arg_list):
52+
exp_arg_list = []
53+
for arg in arg_list:
54+
if arg.startswith('@'):
55+
exp_arg_list += read_arguments_from_file(arg[1:])
56+
else:
57+
exp_arg_list.append(testname)
58+
return exp_arg_list
4259

4360
def main():
4461
from argparse import RawTextHelpFormatter
@@ -72,10 +89,12 @@ def main():
7289
utc_tools = {}
7390
have_error = False
7491

92+
tests = expand_listfile_args(config.tests)
93+
7594
with ThreadPoolExecutor(max_workers=config.jobs) as executor:
7695
jobs = []
7796

78-
for testname in config.tests:
97+
for testname in tests:
7998
with open(testname, "r") as f:
8099
header = f.readline().strip()
81100
m = RE_ASSERTIONS.search(header)

0 commit comments

Comments
 (0)