Skip to content

Commit 7f9ceab

Browse files
committed
Revert "Revert "[lit] Echo full RUN lines in case of external shells""
This reverts commit efec733. The reason for the revert is discussed at: https://discourse.llvm.org/t/rfc-improving-lits-debug-output/72839/52
1 parent 1cc9f62 commit 7f9ceab

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

llvm/utils/lit/lit/TestRunner.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,8 +1153,14 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
11531153
for j, ln in enumerate(commands):
11541154
match = re.match(kPdbgRegex, ln)
11551155
if match:
1156+
dbg = match.group(1)
11561157
command = match.group(2)
1157-
commands[j] = match.expand(": '\\1'; \\2" if command else ": '\\1'")
1158+
commands[j] = f"echo '{dbg}'"
1159+
if command:
1160+
commands[j] += f": {shlex.quote(command.lstrip())} >&2 " \
1161+
f"&& {command}"
1162+
else:
1163+
commands[j] += " has no command after substitutions >&2"
11581164
if litConfig.per_test_coverage:
11591165
# Extract the test case name from the test object
11601166
test_case_name = test.path_in_suite[-1]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# DEFINE: %{empty} =
2+
# RUN: %{empty}
3+
# RUN: false
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# DEFINE: %{empty} =
2+
# RUN: %{empty}
3+
# RUN: false

llvm/utils/lit/tests/shtest-run-at-line.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,35 @@
66
# END.
77

88

9-
# CHECK: Testing: 4 tests
9+
# CHECK: Testing: 6 tests
1010

1111

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

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

17-
# CHECK: RUN: at line 4
18-
# CHECK: RUN: at line 5
19-
# CHECK-NOT: RUN
17+
# CHECK: Command Output (stderr)
18+
# CHECK-NEXT: --
19+
# CHECK: {{^}}RUN: at line 4: true
20+
# CHECK: {{^}}RUN: at line 5: false
21+
# CHECK-NOT: RUN
22+
23+
# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/empty-run-line.txt
24+
25+
# CHECK: Command Output (stderr)
26+
# CHECK-NEXT: --
27+
# CHECK: {{^}}RUN: at line 2 has no command after substitutions
28+
# CHECK: {{^}}RUN: at line 3: false
29+
# CHECK-NOT: RUN
2030

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

23-
# CHECK: RUN: at line 4
24-
# CHECK: RUN: at line 6
25-
# CHECK-NOT: RUN
33+
# CHECK: Command Output (stderr)
34+
# CHECK-NEXT: --
35+
# CHECK: {{^}}RUN: at line 4: echo 'foo bar' | FileCheck
36+
# CHECK: {{^}}RUN: at line 6: echo 'foo baz' | FileCheck
37+
# CHECK-NOT: RUN
2638

2739

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

52+
# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/empty-run-line.txt
53+
54+
# CHECK: Command Output (stdout)
55+
# CHECK-NEXT: --
56+
# CHECK-NEXT: # RUN: at line 2 has no command after substitutions
57+
# CHECK-NEXT: # RUN: at line 3
58+
# CHECK-NEXT: false
59+
# CHECK-NEXT: # executed command: false
60+
# CHECK-NOT: RUN
61+
4062
# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/line-continuation.txt
4163

4264
# CHECK: Command Output (stdout)

0 commit comments

Comments
 (0)