Skip to content

Make update_any_test_check.py script accepting @listfile CL argument. #86800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions llvm/utils/update_any_test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

Given a list of test files, this script will invoke the correct
update_test_checks-style script, skipping any tests which have not previously
had assertions autogenerated.
had assertions autogenerated. If test name starts with '@' it's treated as
a name of file containing test list.
"""

from __future__ import print_function
Expand Down Expand Up @@ -40,6 +41,25 @@ def run_utc_tool(utc_name, utc_tool, testname):
return (result.returncode, result.stdout, result.stderr)


def read_arguments_from_file(filename):
try:
with open(filename, "r") as file:
return [line.rstrip() for line in file.readlines()]
except FileNotFoundError:
print(f"Error: File '{filename}' not found.")
sys.exit(1)


def expand_listfile_args(arg_list):
exp_arg_list = []
for arg in arg_list:
if arg.startswith("@"):
exp_arg_list += read_arguments_from_file(arg[1:])
else:
exp_arg_list.append(arg)
return exp_arg_list


def main():
from argparse import RawTextHelpFormatter

Expand Down Expand Up @@ -72,10 +92,12 @@ def main():
utc_tools = {}
have_error = False

tests = expand_listfile_args(config.tests)

with ThreadPoolExecutor(max_workers=config.jobs) as executor:
jobs = []

for testname in config.tests:
for testname in tests:
with open(testname, "r") as f:
header = f.readline().strip()
m = RE_ASSERTIONS.search(header)
Expand Down