Skip to content

lit: Move RUN at line comment after the command. #132485

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

Merged

Conversation

pcc
Copy link
Contributor

@pcc pcc commented Mar 21, 2025

When a developer copy/pastes a failing command line into their
shell to rerun it, they have to manually delete the "RUN: at line
N:" prefix. To make life easier for such developers, let's make it
possible to copy/paste a command without needing to modify it while
still showing the line number in the output by moving the line number
to a comment at the end of the command line.

Created using spr 1.3.6-beta.1
@llvmbot
Copy link
Member

llvmbot commented Mar 21, 2025

@llvm/pr-subscribers-testing-tools

Author: Peter Collingbourne (pcc)

Changes

When a developer copy/pastes a failing command line into their
shell to rerun it, they have to manually delete the "RUN: at line
N:" prefix. To make life easier for such developers, let's make it
possible to copy/paste a command without needing to modify it while
still showing the line number in the output by moving the line number
to a comment at the end of the command line.


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

2 Files Affected:

  • (modified) llvm/docs/CommandGuide/lit.rst (+1-1)
  • (modified) llvm/utils/lit/lit/TestRunner.py (+1-1)
diff --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst
index 8c0e275e1f8ca..812e1d819e9c8 100644
--- a/llvm/docs/CommandGuide/lit.rst
+++ b/llvm/docs/CommandGuide/lit.rst
@@ -100,7 +100,7 @@ OUTPUT OPTIONS
 
  Each command is printed before it is executed. This can be valuable for
  debugging test failures, as the last printed command is the one that failed.
- Moreover, :program:`lit` inserts ``'RUN: at line N'`` before each
+ Moreover, :program:`lit` inserts ``'RUN: at line N'`` after each
  command pipeline in the output to help you locate the source line of
  the failed command.
 
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 00432b8d31778..dab83cbc20624 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1231,7 +1231,7 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
                 # the shell's execution trace for the 'set' commands by
                 # redirecting their stderr to /dev/null.
                 if command:
-                    msg = f"'{dbg}': {shlex.quote(command.lstrip())}"
+                    msg = f"{shlex.quote(command.lstrip())} \\# '{dbg}'"
                 else:
                     msg = f"'{dbg}' has no command after substitutions"
                 commands[i] = (

@pcc pcc requested a review from MaskRay March 21, 2025 23:07
Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@jroelofs jroelofs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pcc pcc merged commit 8d3dc1e into main Mar 24, 2025
15 checks passed
@pcc pcc deleted the users/pcc/spr/lit-move-run-at-line-comment-after-the-command branch March 24, 2025 18:30
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Mar 24, 2025
When a developer copy/pastes a failing command line into their
shell to rerun it, they have to manually delete the "RUN: at line
N:" prefix. To make life easier for such developers, let's make it
possible to copy/paste a command without needing to modify it while
still showing the line number in the output by moving the line number
to a comment at the end of the command line.

Reviewers: jroelofs, MaskRay

Reviewed By: jroelofs, MaskRay

Pull Request: llvm/llvm-project#132485
schwitanski pushed a commit to RWTH-HPC/llvm-lit-mirror that referenced this pull request Mar 25, 2025
When a developer copy/pastes a failing command line into their
shell to rerun it, they have to manually delete the "RUN: at line
N:" prefix. To make life easier for such developers, let's make it
possible to copy/paste a command without needing to modify it while
still showing the line number in the output by moving the line number
to a comment at the end of the command line.

Reviewers: jroelofs, MaskRay

Reviewed By: jroelofs, MaskRay

Pull Request: llvm/llvm-project#132485
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.

4 participants