[llvm] [lit] Add readfile substitution (PR #158441)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 13 14:49:04 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 origin/main...HEAD llvm/utils/lit/tests/shtest-readfile.py llvm/utils/lit/lit/TestRunner.py
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
--- lit/TestRunner.py	2025-09-13 21:44:58.000000 +0000
+++ lit/TestRunner.py	2025-09-13 21:48:41.650195 +0000
@@ -717,23 +717,25 @@
         opened_files.append((filename, mode, fd) + (redir_filename,))
         std_fds[index] = fd
 
     return std_fds
 
+
 def _expandLateSubstitutions(arguments, cwd):
     for i, arg in enumerate(arguments):
         if not isinstance(arg, str):
             continue
+
         def _replaceReadFile(match):
             filePath = match.group(1)
             if not os.path.isabs(filePath):
                 filePath = os.path.join(cwd, filePath)
             with open(filePath) as fileHandle:
                 return fileHandle.read()
-        
+
         arguments[i] = re.sub(r"%{readfile:([^}]*)}", _replaceReadFile, arg)
-    
+
     return arguments
 
 def _executeShCmd(cmd, shenv, results, timeoutHelper):
     if timeoutHelper.timeoutReached():
         # Prevent further recursion if the timeout has been hit

``````````

</details>


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


More information about the llvm-commits mailing list