Skip to content

Commit 33786b6

Browse files
authored
Make update_any_test_check.py script accepting @ListFile CL argument. (#86800)
Usage: `update_any_test_check.py @my_list_of_tests` where my_list_of_tests is a file containing list of tests to update.
1 parent 992413d commit 33786b6

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

llvm/utils/update_any_test_checks.py

Lines changed: 24 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
@@ -40,6 +41,25 @@ def run_utc_tool(utc_name, utc_tool, testname):
4041
return (result.returncode, result.stdout, result.stderr)
4142

4243

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

@@ -72,10 +92,12 @@ def main():
7292
utc_tools = {}
7393
have_error = False
7494

95+
tests = expand_listfile_args(config.tests)
96+
7597
with ThreadPoolExecutor(max_workers=config.jobs) as executor:
7698
jobs = []
7799

78-
for testname in config.tests:
100+
for testname in tests:
79101
with open(testname, "r") as f:
80102
header = f.readline().strip()
81103
m = RE_ASSERTIONS.search(header)

0 commit comments

Comments
 (0)