Skip to content
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

[lit] Echo full RUN lines in case of external shells #65267

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,14 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
for j, ln in enumerate(commands):
match = re.match(kPdbgRegex, ln)
if match:
dbg = match.group(1)
command = match.group(2)
commands[j] = match.expand(": '\\1'; \\2" if command else ": '\\1'")
commands[j] = f"echo '{dbg}'"
if command:
commands[j] += f": {shlex.quote(command.lstrip())} >&2 " \
f"&& {command}"
else:
commands[j] += " has no command after substitutions >&2"
if litConfig.per_test_coverage:
# Extract the test case name from the test object
test_case_name = test.path_in_suite[-1]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DEFINE: %{empty} =
# RUN: %{empty}
# RUN: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DEFINE: %{empty} =
# RUN: %{empty}
# RUN: false
36 changes: 29 additions & 7 deletions llvm/utils/lit/tests/shtest-run-at-line.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,35 @@
# END.


# CHECK: Testing: 4 tests
# CHECK: Testing: 6 tests


# In the case of the external shell, we check for only RUN lines in stderr in
# case some shell implementations format "set -x" output differently.

# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/basic.txt

# CHECK: RUN: at line 4
# CHECK: RUN: at line 5
# CHECK-NOT: RUN
# CHECK: Command Output (stderr)
# CHECK-NEXT: --
# CHECK: {{^}}RUN: at line 4: true
# CHECK: {{^}}RUN: at line 5: false
# CHECK-NOT: RUN

# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/empty-run-line.txt

# CHECK: Command Output (stderr)
# CHECK-NEXT: --
# CHECK: {{^}}RUN: at line 2 has no command after substitutions
# CHECK: {{^}}RUN: at line 3: false
# CHECK-NOT: RUN

# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/line-continuation.txt

# CHECK: RUN: at line 4
# CHECK: RUN: at line 6
# CHECK-NOT: RUN
# CHECK: Command Output (stderr)
# CHECK-NEXT: --
# CHECK: {{^}}RUN: at line 4: echo 'foo bar' | FileCheck
# CHECK: {{^}}RUN: at line 6: echo 'foo baz' | FileCheck
# CHECK-NOT: RUN


# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/basic.txt
Expand All @@ -37,6 +49,16 @@
# CHECK-NEXT: # executed command: false
# CHECK-NOT: RUN

# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/empty-run-line.txt

# CHECK: Command Output (stdout)
# CHECK-NEXT: --
# CHECK-NEXT: # RUN: at line 2 has no command after substitutions
# CHECK-NEXT: # RUN: at line 3
# CHECK-NEXT: false
# CHECK-NEXT: # executed command: false
# CHECK-NOT: RUN

# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/line-continuation.txt

# CHECK: Command Output (stdout)
Expand Down