[llvm] [lit] introduce --show-attempts-count (PR #142413)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 08:31:03 PDT 2025


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 HEAD~1...HEAD llvm/utils/lit/lit/Test.py llvm/utils/lit/lit/TestRunner.py llvm/utils/lit/lit/cl_arguments.py llvm/utils/lit/lit/display.py llvm/utils/lit/tests/Inputs/max-retries-per-test/allow-retries-no-test_retry_attempts/test.py llvm/utils/lit/tests/Inputs/max-retries-per-test/allow-retries-test_retry_attempts/test.py llvm/utils/lit/tests/allow-retries.py
``````````

</details>

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

``````````diff
--- lit/Test.py	2025-06-02 15:23:26.000000 +0000
+++ lit/Test.py	2025-06-02 15:30:34.168582 +0000
@@ -149,11 +149,13 @@
 
 
 class Result(object):
     """Wrapper for the results of executing an individual test."""
 
-    def __init__(self, code, output="", elapsed=None, attempts=None, max_allowed_attempts=None):
+    def __init__(
+        self, code, output="", elapsed=None, attempts=None, max_allowed_attempts=None
+    ):
         # The result code.
         self.code = code
         # The test output.
         self.output = output
         # The wall timing to execute the test, if timing.
--- lit/TestRunner.py	2025-06-02 15:23:26.000000 +0000
+++ lit/TestRunner.py	2025-06-02 15:30:34.818788 +0000
@@ -2290,11 +2290,13 @@
     if out:
         output += """Command Output (stdout):\n--\n%s\n--\n""" % (out,)
     if err:
         output += """Command Output (stderr):\n--\n%s\n--\n""" % (err,)
 
-    return lit.Test.Result(status, output, attempts=i+1, max_allowed_attempts=attempts)
+    return lit.Test.Result(
+        status, output, attempts=i + 1, max_allowed_attempts=attempts
+    )
 
 
 def executeShTest(
     test, litConfig, useExternalSh, extra_substitutions=[], preamble_commands=[]
 ):
--- lit/display.py	2025-06-02 15:23:26.000000 +0000
+++ lit/display.py	2025-06-02 15:30:34.969835 +0000
@@ -120,22 +120,32 @@
 
         extra_info = ""
         extra_attrs = []
 
         if self.opts.showAttemptsCount:
-            if test.result.max_allowed_attempts is not None and test.result.max_allowed_attempts > 1:
+            if (
+                test.result.max_allowed_attempts is not None
+                and test.result.max_allowed_attempts > 1
+            ):
                 extra_attrs.append(f"attempts={test.result.attempts}")
-                extra_attrs.append(f"max_allowed_attempts={test.result.max_allowed_attempts}")
+                extra_attrs.append(
+                    f"max_allowed_attempts={test.result.max_allowed_attempts}"
+                )
 
         if len(extra_attrs) > 0:
             extra_info = " [" + ",".join(extra_attrs) + "]"
 
         print(
             "%s: %s (%d of %d)%s"
-            % (test.result.code.name, test_name, self.completed, self.num_tests, extra_info)
+            % (
+                test.result.code.name,
+                test_name,
+                self.completed,
+                self.num_tests,
+                extra_info,
+            )
         )
-        
 
         # Show the test failure output, if requested.
         if (test.isFailure() and self.opts.showOutput) or self.opts.showAllOutput:
             if test.isFailure():
                 print(
--- tests/allow-retries.py	2025-06-02 15:23:26.000000 +0000
+++ tests/allow-retries.py	2025-06-02 15:30:35.004016 +0000
@@ -124,6 +124,5 @@
 # RUN:   -Dcounter=%t.counter \
 # RUN:   -Dpython=%{python} \
 # RUN: | FileCheck --check-prefix=CHECK-TEST11 %s
 # CHECK-TEST11: FLAKYPASS: allow-retries-test_retry_attempts :: test.py (1 of 1) [attempts=4,max_allowed_attempts=11]
 # CHECK-TEST11: Passed With Retry: 1
-

``````````

</details>


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


More information about the llvm-commits mailing list