[llvm] [lit] Fix missing command for external Windows shell (PR #116603)
Sven van Haastregt via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 03:29:03 PST 2024
https://github.com/svenvh created https://github.com/llvm/llvm-project/pull/116603
On Windows, when using the external shell (.bat) the command to be executed is not generated. This is a regression introduced by https://reviews.llvm.org/D122569.
A command of the form `RUN: mycmd` is internally transformed into `dbg(line XX) mycmd`. Previously `dbg()` was substituted by `echo \\1 && `, with `\\1` matching the content of `dbg()`, in the string containing the command to be executed. The new code relies on `str.expand()` which correctly expands `\\1`, but as the template does not reference the command at all, it is lost. The generated .bat file is invalid as there is nothing after the last `&&`.
Fix by appending the command as is done for the common case further down (line 1257).
>From 1867a6356a8e686e05799ec884c99fd3d1065cc2 Mon Sep 17 00:00:00 2001
From: Sven van Haastregt <sven.vanhaastregt at arm.com>
Date: Mon, 18 Nov 2024 11:24:08 +0000
Subject: [PATCH] [lit] Fix missing command for external Windows shell
On Windows, when using the external shell (.bat) the command to
be executed is not generated. This is a regression introduced by
https://reviews.llvm.org/D122569.
A command of the form `RUN: mycmd` is internally transformed into
`dbg(line XX) mycmd`. Previously `dbg()` was substituted by
`echo \\1 && `, with `\\1` matching the content of `dbg()`, in the
string containing the command to be executed. The new code relies on
`str.expand()` which correctly expands `\\1`, but as the template does
not reference the command at all, it is lost. The generated .bat file
is invalid as there is nothing after the last `&&`.
Fix by appending the command as is done for the common case further
down.
---
llvm/utils/lit/lit/TestRunner.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 00432b8d317784..d6a0d26b470436 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1216,6 +1216,8 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
commands[i] = match.expand(
"echo '\\1' > nul && " if command else "echo '\\1' > nul"
)
+ if command:
+ commands[i] += command
f.write("@echo on\n")
f.write("\n at if %ERRORLEVEL% NEQ 0 EXIT\n".join(commands))
else:
More information about the llvm-commits
mailing list