[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 12 10:11:15 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r c1c42518c1356e78a10bf252a4a5a643b2bb9efd...5e0817746633736adc7e135160777c8ae39e0e45 clang/utils/UpdateVerifyTests/__init__.py clang/utils/UpdateVerifyTests/core.py clang/utils/UpdateVerifyTests/litplugin.py clang/utils/update-verify-tests.py clang/test/lit.cfg.py llvm/test/lit.cfg.py llvm/utils/lit/lit/LitConfig.py llvm/utils/lit/lit/TestRunner.py llvm/utils/lit/lit/cl_arguments.py llvm/utils/lit/lit/llvm/config.py llvm/utils/lit/lit/main.py llvm/utils/update_any_test_checks.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- clang/test/lit.cfg.py	2024-09-12 16:52:28.000000 +0000
+++ clang/test/lit.cfg.py	2024-09-12 17:10:32.336905 +0000
@@ -368,6 +368,7 @@
     import os
 
     utilspath = os.path.join(config.llvm_src_root, "utils")
     sys.path.append(utilspath)
     from update_any_test_checks import utc_lit_plugin
+
     lit_config.test_updaters.append(utc_lit_plugin)
--- clang/utils/UpdateVerifyTests/litplugin.py	2024-09-12 16:52:28.000000 +0000
+++ clang/utils/UpdateVerifyTests/litplugin.py	2024-09-12 17:10:32.448516 +0000
@@ -2,10 +2,11 @@
 from lit.formats import ShTest
 from UpdateVerifyTests.core import check_expectations
 import re
 
 verify_r = re.compile(r"-verify(?:=(\w+))?")
+
 
 def get_verify_prefixes(command):
     def get_default(prefix):
         if prefix:
             return prefix
@@ -19,17 +20,17 @@
         prefix = m[1]
         if not prefix:
             prefix = "expected"
         prefixes.add(prefix)
     return prefixes
-    
+
+
 def verify_test_updater(result, test):
     if not result.stderr:
         return None
     prefixes = get_verify_prefixes(result.command)
     if not prefixes:
         return None
     if len(prefixes) > 1:
         return f"update-verify-test: not updating because of multiple prefixes - {prefixes}"
     [prefix] = prefixes
     return check_expectations(result.stderr.splitlines(), prefix)
-
--- llvm/test/lit.cfg.py	2024-09-12 16:52:28.000000 +0000
+++ llvm/test/lit.cfg.py	2024-09-12 17:10:32.629371 +0000
@@ -628,6 +628,7 @@
     import os
 
     utilspath = os.path.join(config.llvm_src_root, "utils")
     sys.path.append(utilspath)
     from update_any_test_checks import utc_lit_plugin
+
     lit_config.test_updaters.append(utc_lit_plugin)
--- llvm/utils/update_any_test_checks.py	2024-09-12 16:52:28.000000 +0000
+++ llvm/utils/update_any_test_checks.py	2024-09-12 17:10:33.884475 +0000
@@ -34,11 +34,14 @@
     return None
 
 
 def run_utc_tool(utc_name, utc_tool, testname, environment):
     result = subprocess.run(
-        [utc_tool, testname], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environment
+        [utc_tool, testname],
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+        env=environment,
     )
     return (result.returncode, result.stdout, result.stderr)
 
 
 def read_arguments_from_file(filename):
@@ -78,11 +81,13 @@
     utc_name = m.group(1)
     utc_tool = find_utc_tool([utc_search_path], utc_name)
     if not utc_tool:
         return f"update-utc-tests: {utc_name} not found"
 
-    return_code, stdout, stderr = run_utc_tool(utc_name, utc_tool, testname, test.config.environment)
+    return_code, stdout, stderr = run_utc_tool(
+        utc_name, utc_tool, testname, test.config.environment
+    )
 
     stderr = stderr.decode(errors="replace")
     if return_code != 0:
         if stderr:
             return f"update-utc-tests: {utc_name} exited with return code {return_code}\n{stderr.rstrip()}"

``````````

</details>


https://github.com/llvm/llvm-project/pull/108425


More information about the cfe-commits mailing list