xref: /llvm-project/llvm/test/FileCheck/dump-input/context.txt (revision d3778490622bca45c0768e8ed590cd9fa1797dee)
1;--------------------------------------------------
2; Input file, check file, and directives for checking the size of the context.
3;
4; These are designed to be used with -dump-input=fail -vv.
5;
6; In the resulting input dump, there are three potential ellipses:
7;
8; - S: At the start of the input.
9; - M: Between two input lines included by the filter.
10; - E: At the end of the input.
11;
12; They are all present at -dump-input-context=4.  One becomes useless each time
13; -dump-input-context is incremented beyond that because then that ellipsis
14; becomes equal to or larger than the input lines it elides.
15;--------------------------------------------------
16
17; RUN: echo foo8       >  %t.in
18; RUN: echo foo7       >> %t.in
19; RUN: echo foo6       >> %t.in
20; RUN: echo foo5       >> %t.in
21; RUN: echo foo4       >> %t.in
22; RUN: echo foo3       >> %t.in
23; RUN: echo foo2       >> %t.in
24; RUN: echo foo1       >> %t.in
25; RUN: echo lab1 hello >> %t.in
26; RUN: echo foo1       >> %t.in
27; RUN: echo foo2       >> %t.in
28; RUN: echo foo3       >> %t.in
29; RUN: echo foo4       >> %t.in
30; RUN: echo foo5       >> %t.in
31; RUN: echo foo6       >> %t.in
32; RUN: echo foo7       >> %t.in
33; RUN: echo foo7       >> %t.in
34; RUN: echo foo6       >> %t.in
35; RUN: echo foo5       >> %t.in
36; RUN: echo foo4       >> %t.in
37; RUN: echo foo3       >> %t.in
38; RUN: echo foo2       >> %t.in
39; RUN: echo foo1       >> %t.in
40; RUN: echo lab2 world >> %t.in
41; RUN: echo foo1       >> %t.in
42; RUN: echo foo2       >> %t.in
43; RUN: echo foo3       >> %t.in
44; RUN: echo foo4       >> %t.in
45; RUN: echo foo5       >> %t.in
46; RUN: echo foo6       >> %t.in
47; RUN: echo foo7       >> %t.in
48; RUN: echo foo8       >> %t.in
49; RUN: echo foo9       >> %t.in
50; RUN: echo foo0       >> %t.in
51
52; RUN: echo 'CHECK-LABEL: lab1'  >  %t.chk
53; RUN: echo ' CHECK-NEXT: hello' >> %t.chk
54; RUN: echo 'CHECK-LABEL: lab2'  >> %t.chk
55; RUN: echo ' CHECK-NEXT: world' >> %t.chk
56
57;      C0: <<<<<<
58; CS-NEXT:            .
59; CS-NEXT:            .
60; CS-NEXT:            .
61; C5-NEXT:            1: foo8
62; C5-NEXT:            2: foo7
63; C5-NEXT:            3: foo6
64; C5-NEXT:            4: foo5
65; C4-NEXT:            5: foo4
66; C3-NEXT:            6: foo3
67; C2-NEXT:            7: foo2
68; C1-NEXT:            8: foo1
69; C0-NEXT:            9: lab1 hello
70; C0-NEXT: label:1'0     ^~~~
71; C0-NEXT: label:1'1     ^~~~
72; C0-NEXT: next:2             !~~~~  error: match on wrong line
73; C1-NEXT:           10: foo1
74; C2-NEXT:           11: foo2
75; C3-NEXT:           12: foo3
76; C4-NEXT:           13: foo4
77; C5-NEXT:           14: foo5
78; C6-NEXT:           15: foo6
79; C6-NEXT:           16: foo7
80; CM-NEXT:            .
81; CM-NEXT:            .
82; CM-NEXT:            .
83; C6-NEXT:           17: foo7
84; C6-NEXT:           18: foo6
85; C5-NEXT:           19: foo5
86; C4-NEXT:           20: foo4
87; C3-NEXT:           21: foo3
88; C2-NEXT:           22: foo2
89; C1-NEXT:           23: foo1
90; C0-NEXT:           24: lab2 world
91; C0-NEXT: label:3       ^~~~
92; C0-NEXT: next:4             !~~~~  error: match on wrong line
93; C1-NEXT:           25: foo1
94; C2-NEXT:           26: foo2
95; C3-NEXT:           27: foo3
96; C4-NEXT:           28: foo4
97; C5-NEXT:           29: foo5
98; C6-NEXT:           30: foo6
99; C7-NEXT:           31: foo7
100; C7-NEXT:           32: foo8
101; C7-NEXT:           33: foo9
102; C7-NEXT:           34: foo0
103; CE-NEXT:            .
104; CE-NEXT:            .
105; CE-NEXT:            .
106; C0-NEXT: >>>>>>
107
108; Now build an alternate set of checks where input lines that might be elided by
109; ellipses have annotations.
110
111; RUN: cp %t.in %t.wide.in
112; RUN: echo 'CHECK-LABEL: lab1'    >  %t.wide.chk
113; RUN: echo '      CHECK: hello'   >> %t.wide.chk
114; RUN: echo '      CHECK: goodbye' >> %t.wide.chk
115; RUN: echo 'CHECK-LABEL: lab2'    >> %t.wide.chk
116; RUN: echo ' CHECK-NEXT: world'   >> %t.wide.chk
117
118;      W5: <<<<<<
119;      W5:            9: lab1 hello
120; W5-NEXT: label:1'0     ^~~~
121; W5-NEXT: label:1'1     ^~~~
122; W5-NEXT: check:2            ^~~~~
123; W5-NEXT: check:3'0               X error: no match found
124; W5-NEXT:           10: foo1
125; W5-NEXT: check:3'0     ~~~~~
126; W5-NEXT: check:3'1     ?     possible intended match
127; W5-NEXT:           11: foo2
128; W5-NEXT: check:3'0     ~~~~~
129; W5-NEXT:           12: foo3
130; W5-NEXT: check:3'0     ~~~~~
131; W5-NEXT:           13: foo4
132; W5-NEXT: check:3'0     ~~~~~
133; W5-NEXT:           14: foo5
134; W5-NEXT: check:3'0     ~~~~~
135; W5-NEXT:           15: foo6
136; W5-NEXT: check:3'0     ~~~~~
137; W6-NEXT:           16: foo7
138; W6-NEXT: check:3'0     ~~~~~
139; WM-NEXT:            .
140; WM-NEXT:            .
141; WM-NEXT:            .
142; W6-NEXT:           17: foo7
143; W6-NEXT: check:3'0     ~~~~~
144; W6-NEXT:           18: foo6
145; W6-NEXT: check:3'0     ~~~~~
146; W5-NEXT:           19: foo5
147; W5-NEXT: check:3'0     ~~~~~
148; W5-NEXT:           20: foo4
149; W5-NEXT: check:3'0     ~~~~~
150; W5-NEXT:           21: foo3
151; W5-NEXT: check:3'0     ~~~~~
152; W5-NEXT:           22: foo2
153; W5-NEXT: check:3'0     ~~~~~
154; W5-NEXT:           23: foo1
155; W5-NEXT: check:3'0     ~~~~~
156; W5-NEXT:           24: lab2 world
157; W5-NEXT: label:4       ^~~~
158; W5-NEXT: check:3'0     ~~~~
159; W5-NEXT: next:5             !~~~~  error: match on wrong line
160
161;--------------------------------------------------
162; Check -dump-input-context=<bad value>.
163;--------------------------------------------------
164
165; RUN: %ProtectFileCheckOutput \
166; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
167; RUN:               -dump-input-context=-1 \
168; RUN: | FileCheck %s -match-full-lines -check-prefix=BADVAL -DVAL=-1
169
170; RUN: %ProtectFileCheckOutput \
171; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
172; RUN:               -dump-input-context=foobar \
173; RUN: | FileCheck %s -match-full-lines -check-prefix=BADVAL -DVAL=foobar
174
175BADVAL: {{F|f}}ile{{C|c}}heck{{.*}}: for the --dump-input-context option: '[[VAL]]' value invalid for uint argument!
176
177;--------------------------------------------------
178; Check -dump-input-context explicit values.
179;--------------------------------------------------
180
181; 0 is an important boundary case.
182; RUN: %ProtectFileCheckOutput \
183; RUN: not FileCheck -dump-input=fail -vv  %t.chk < %t.in 2>&1 \
184; RUN:               -dump-input-context=0 \
185; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,CS,CM,CE
186
187; 1 is an important boundary case.
188; RUN: %ProtectFileCheckOutput \
189; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
190; RUN:               -dump-input-context=1 \
191; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,CS,CM,CE
192
193; 4 is the boundary case at which all ellipses are present in our test.
194; RUN: %ProtectFileCheckOutput \
195; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
196; RUN:               -dump-input-context=4 \
197; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,C2,C3,C4,CS,CM,CE
198
199; 5 is the boundary case at which the start ellipsis is useless.
200; RUN: %ProtectFileCheckOutput \
201; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
202; RUN:               -dump-input-context=5 \
203; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,C2,C3,C4,C5,CM,CE
204
205; 6 is the boundary case at which the middle ellipsis is useless.
206; RUN: %ProtectFileCheckOutput \
207; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
208; RUN:               -dump-input-context=6 \
209; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,C2,C3,C4,C5,C6,CE
210
211; 7 is the boundary case at which the end ellipsis is useless.
212; RUN: %ProtectFileCheckOutput \
213; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
214; RUN:               -dump-input-context=7 \
215; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,C2,C3,C4,C5,C6,C7
216
217; Make sure all is fine when -dump-input-context is far larger than the input.
218; RUN: %ProtectFileCheckOutput \
219; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
220; RUN:               -dump-input-context=200 \
221; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,C2,C3,C4,C5,C6,C7
222
223;--------------------------------------------------
224; Check that -dump-input-context default is 5.
225;--------------------------------------------------
226
227; RUN: %ProtectFileCheckOutput \
228; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
229; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,C2,C3,C4,C5,CM,CE
230
231;--------------------------------------------------
232; Check multiple -dump-input-context options.
233;
234; This might occur when a test author specifies -dump-input-context on a
235; specific FileCheck call while a test runner specifies -dump-input-context in
236; FILECHECK_OPTS, but check the behavior generally.
237;
238; The largest value wins because it provides the most information.
239;--------------------------------------------------
240
241;- - - - - - - - - - - - - - - - - - - - - - - - -
242; Check duplicate.
243;- - - - - - - - - - - - - - - - - - - - - - - - -
244
245; RUN: %ProtectFileCheckOutput \
246; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
247; RUN:               -dump-input-context=1 -dump-input-context=1 \
248; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,CS,CM,CE
249
250;- - - - - - - - - - - - - - - - - - - - - - - - -
251; Check precedence.
252;- - - - - - - - - - - - - - - - - - - - - - - - -
253
254; RUN: %ProtectFileCheckOutput \
255; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
256; RUN:               -dump-input-context=0 -dump-input-context=1 \
257; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,CS,CM,CE
258
259; RUN: %ProtectFileCheckOutput \
260; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
261; RUN:               -dump-input-context=1 -dump-input-context=0 \
262; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,CS,CM,CE
263
264;- - - - - - - - - - - - - - - - - - - - - - - - -
265; Check that FILECHECK_OPTS isn't handled differently.
266;- - - - - - - - - - - - - - - - - - - - - - - - -
267
268; RUN: %ProtectFileCheckOutput FILECHECK_OPTS=-dump-input-context=0 \
269; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
270; RUN:               -dump-input-context=1 \
271; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,CS,CM,CE
272
273; RUN: %ProtectFileCheckOutput FILECHECK_OPTS=-dump-input-context=1 \
274; RUN: not FileCheck -dump-input=fail -vv %t.chk < %t.in 2>&1 \
275; RUN:               -dump-input-context=0 \
276; RUN: | FileCheck %s -match-full-lines -check-prefixes=C0,C1,CS,CM,CE
277
278;--------------------------------------------------
279; Check how annotations on input lines that might be elided by ellipses affect
280; whether they are actually elided.
281;--------------------------------------------------
282
283; At -dump-input-context=5, the ellipsis is useful but only when annotations on
284; elided input lines are considered.
285; RUN: %ProtectFileCheckOutput \
286; RUN: not FileCheck -dump-input=fail -vv %t.wide.chk < %t.wide.in 2>&1 \
287; RUN:               -dump-input-context=5 \
288; RUN: | FileCheck %s -match-full-lines -check-prefixes=W5,WM
289
290; At -dump-input-context=6, the ellipsis is not useful even when annotations on
291; elided input lines are considered.
292; RUN: %ProtectFileCheckOutput \
293; RUN: not FileCheck -dump-input=fail -vv %t.wide.chk < %t.wide.in 2>&1 \
294; RUN:               -dump-input-context=6 \
295; RUN: | FileCheck %s -match-full-lines -check-prefixes=W5,W6
296