[llvm] [lit] Add support to print relative paths when outputting test names (PR #154317)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 19 05:13:23 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/tests/print-relative-path.py llvm/utils/lit/lit/Test.py llvm/utils/lit/lit/cl_arguments.py llvm/utils/lit/lit/display.py llvm/utils/lit/lit/main.py
``````````

</details>

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

``````````diff
--- lit/Test.py	2025-08-19 12:06:21.000000 +0000
+++ lit/Test.py	2025-08-19 12:12:55.963460 +0000
@@ -307,12 +307,11 @@
     def getFullName(self):
         return self.suite.config.name + " :: " + "/".join(self.path_in_suite)
 
     def getFullNameRelPath(self, printRelativePaths):
         if printRelativePaths:
-            return (self.suite.config.name + " :: " +
-                    os.path.relpath(self.getFilePath()))
+            return self.suite.config.name + " :: " + os.path.relpath(self.getFilePath())
         return self.getFullName()
 
     def getFilePath(self):
         if self.file_path:
             return self.file_path
--- lit/display.py	2025-08-19 12:06:21.000000 +0000
+++ lit/display.py	2025-08-19 12:12:56.088968 +0000
@@ -134,13 +134,11 @@
         )
 
         # Show the test failure output, if requested.
         if (test.isFailure() and self.opts.showOutput) or self.opts.showAllOutput:
             if test.isFailure():
-                print(
-                    "%s TEST '%s' FAILED %s" % ("*" * 20, test_name, "*" * 20)
-                )
+                print("%s TEST '%s' FAILED %s" % ("*" * 20, test_name, "*" * 20))
             out = test.result.output
             # Encode/decode so that, when using Python 3.6.5 in Windows 10,
             # print(out) doesn't raise UnicodeEncodeError if out contains
             # special characters.  However, Python 2 might try to decode
             # as part of the encode call if out is already encoded, so skip
--- lit/main.py	2025-08-19 12:06:21.000000 +0000
+++ lit/main.py	2025-08-19 12:12:56.202263 +0000
@@ -327,11 +327,11 @@
     for code in lit.Test.ResultCode.all_codes():
         print_group(
             sorted(tests_by_code[code], key=lambda t: t.getFullName()),
             code,
             opts.shown_codes,
-            opts.printRelativePaths
+            opts.printRelativePaths,
         )
 
     print_summary(total_tests, tests_by_code, opts.quiet, elapsed)
 
 

``````````

</details>


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


More information about the llvm-commits mailing list