xref: /llvm-project/llvm/utils/lit/tests/shtest-run-at-line.py (revision 3dc7039f244f5da7368b8ba2f0e419c7d851c851)
1# Check that -a/-v/-vv makes the line number of the failing RUN command clear.
2
3
4# RUN: not %{lit} -a %{inputs}/shtest-run-at-line | %{filter-lit} | FileCheck %s
5# RUN: not %{lit} -v %{inputs}/shtest-run-at-line | %{filter-lit} | FileCheck %s
6# RUN: not %{lit} -vv %{inputs}/shtest-run-at-line | %{filter-lit} | FileCheck %s
7# END.
8
9
10# CHECK: Testing: 8 tests
11
12
13# In the case of the external shell, we check for only RUN lines in stderr in
14# case some shell implementations format "set -x" output differently.
15
16# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/basic.txt
17
18#       CHECK: Command Output (stderr)
19#  CHECK-NEXT: --
20#  CHECK-NEXT: {{^}}RUN: at line 4: true{{$}}
21#  CHECK-NEXT: true
22#  CHECK-NEXT: {{^}}RUN: at line 5: false{{$}}
23#  CHECK-NEXT: false
24# CHECK-EMPTY:
25#  CHECK-NEXT: --
26
27# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/empty-run-line.txt
28
29#       CHECK: Command Output (stderr)
30#  CHECK-NEXT: --
31#  CHECK-NEXT: {{^}}RUN: at line 2 has no command after substitutions{{$}}
32#  CHECK-NEXT: {{^}}RUN: at line 3: false{{$}}
33#  CHECK-NEXT: false
34# CHECK-EMPTY:
35#  CHECK-NEXT: --
36
37# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/line-continuation.txt
38
39# The execution trace from an external sh-like shell might print the commands
40# from a pipeline in any order, so this time just check that lit suppresses the
41# trace of the echo command for each 'RUN: at line N: cmd-line'.
42
43#       CHECK: Command Output (stderr)
44#  CHECK-NEXT: --
45#  CHECK-NEXT: {{^}}RUN: at line 4: echo 'foo bar' | FileCheck
46#   CHECK-NOT: RUN
47#       CHECK: {{^}}RUN: at line 6: echo 'foo baz' | FileCheck
48#   CHECK-NOT: RUN
49#       CHECK: --
50
51# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/run-line-with-newline.txt
52
53#      CHECK: Command Output (stderr)
54# CHECK-NEXT: --
55# CHECK-NEXT: {{^}}RUN: at line 1: echo abc |
56# CHECK-NEXT: FileCheck {{.*}} &&
57# CHECK-NEXT: false
58#  CHECK-NOT: RUN
59
60
61# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/basic.txt
62
63# CHECK:      Command Output (stdout)
64# CHECK-NEXT: --
65# CHECK-NEXT: # RUN: at line 1
66# CHECK-NEXT: true
67# CHECK-NEXT: # executed command: true
68# CHECK-NEXT: # RUN: at line 2
69# CHECK-NEXT: false
70# CHECK-NEXT: # executed command: false
71# CHECK-NOT:  RUN
72
73# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/empty-run-line.txt
74
75#      CHECK: Command Output (stdout)
76# CHECK-NEXT: --
77# CHECK-NEXT: # RUN: at line 2 has no command after substitutions
78# CHECK-NEXT: # RUN: at line 3
79# CHECK-NEXT: false
80# CHECK-NEXT: # executed command: false
81#  CHECK-NOT: RUN
82
83# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/line-continuation.txt
84
85# CHECK:      Command Output (stdout)
86# CHECK-NEXT: --
87# CHECK-NEXT: # RUN: at line 1
88# CHECK-NEXT: : first line continued to second line
89# CHECK-NEXT: # executed command: : first line continued to second line
90# CHECK-NEXT: # RUN: at line 3
91# CHECK-NEXT: echo 'foo bar' | FileCheck {{.*}}
92# CHECK-NEXT: # executed command: echo 'foo bar'
93# CHECK-NEXT: # executed command: FileCheck {{.*}}
94# CHECK-NEXT: # RUN: at line 5
95# CHECK-NEXT: echo 'foo baz' | FileCheck {{.*}}
96# CHECK-NEXT: # executed command: echo 'foo baz'
97# CHECK-NEXT: # executed command: FileCheck {{.*}}
98# CHECK-NOT:  RUN
99
100# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/run-line-with-newline.txt
101
102#      CHECK: Command Output (stdout)
103# CHECK-NEXT: --
104# CHECK-NEXT: # RUN: at line 1
105# CHECK-NEXT: echo abc |
106# CHECK-NEXT: FileCheck {{.*}} &&
107# CHECK-NEXT: false
108# CHECK-NEXT: # executed command: echo abc
109# CHECK-NEXT: # executed command: FileCheck {{.*}}
110# CHECK-NEXT: # executed command: false
111#  CHECK-NOT: RUN
112