[llvm] Make update_any_test_check.py script accepting @listfile CL argument. (PR #86800)
Valery Pykhtin via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 02:16:42 PDT 2024
https://github.com/vpykhtin updated https://github.com/llvm/llvm-project/pull/86800
>From 0d0658687bf7170fec4f2b046685092d2ec650da Mon Sep 17 00:00:00 2001
From: Valery Pykhtin <valery.pykhtin at gmail.com>
Date: Tue, 26 Mar 2024 18:24:58 +0100
Subject: [PATCH] Make update_any_test_check.py script accepting @listfile CL
argument.
---
llvm/utils/update_any_test_checks.py | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/llvm/utils/update_any_test_checks.py b/llvm/utils/update_any_test_checks.py
index 2ad852d710c07a..e8eef1a46c504f 100755
--- a/llvm/utils/update_any_test_checks.py
+++ b/llvm/utils/update_any_test_checks.py
@@ -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
@@ -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
@@ -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)
More information about the llvm-commits
mailing list