Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[lit] Fix missing command for external Windows shell #116603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from

Conversation

svenvh
Copy link
Member

@svenvh svenvh commented Nov 18, 2024

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).

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.
@llvmbot
Copy link
Member

llvmbot commented Nov 18, 2024

@llvm/pr-subscribers-testing-tools

Author: Sven van Haastregt (svenvh)

Changes

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).


Full diff: https://github.com/llvm/llvm-project/pull/116603.diff

1 Files Affected:

  • (modified) llvm/utils/lit/lit/TestRunner.py (+2)
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@if %ERRORLEVEL% NEQ 0 EXIT\n".join(commands))
     else:

@jh7370
Copy link
Collaborator

jh7370 commented Nov 18, 2024

Why are you using the external shell on Windows? The internal is the default and we are aiming to get rid of external shell support entirely, as I understand it.

@svenvh
Copy link
Member Author

svenvh commented Nov 18, 2024

Why are you using the external shell on Windows? The internal is the default and we are aiming to get rid of external shell support entirely, as I understand it.

We are indeed migrating our (downstream) tests away from the external shell but we're not ready yet to drop it entirely. I wasn't aware of any removal plans of external shell support, but that seems like the right longer term direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.