xref: /llvm-project/llvm/test/FileCheck/dump-input/annotations.txt (revision 497a8604b39f8b5736c389f6d7ccd8242a122cbf)
1;--------------------------------------------------
2; Use -strict-whitespace to check marker and note alignment here.
3; (Also check multiline marker where start/end columns vary across lines.)
4;
5; In the remaining checks, don't use -strict-whitespace and thus check just the
6; presence, order, and lengths of markers.  That way, if we ever change padding
7; within line labels, we don't have to adjust so many tests.
8;--------------------------------------------------
9
10; RUN: echo 'hello world' > %t.in
11; RUN: echo 'goodbye' >> %t.in
12; RUN: echo 'world' >> %t.in
13; RUN: echo 'unicorn' >> %t.in
14
15; RUN: echo 'CHECK: hello' > %t.chk
16; RUN: echo 'CHECK: universe' >> %t.chk
17
18; RUN: %ProtectFileCheckOutput \
19; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
20; RUN: | FileCheck -strict-whitespace -match-full-lines -check-prefix=ALIGN \
21; RUN:             -implicit-check-not='remark:' %s
22
23; Verbose diagnostics are suppressed but not errors.
24; ALIGN:{{.*}}error:{{.*}}
25; ALIGN:{{.*}}possible intended match here{{.*}}
26
27; ALIGN:Input was:
28; ALIGN-NEXT:<<<<<<
29; ALIGN-NEXT:           1: hello world
30; ALIGN-NEXT:check:1       ^~~~~
31; ALIGN-NEXT:check:2'0          X~~~~~~ error: no match found
32; ALIGN-NEXT:           2: goodbye
33; ALIGN-NEXT:check:2'0     ~~~~~~~~
34; ALIGN-NEXT:           3: world
35; ALIGN-NEXT:check:2'0     ~~~~~~
36; ALIGN-NEXT:           4: unicorn
37; ALIGN-NEXT:check:2'0     ~~~~~~~~
38; ALIGN-NEXT:check:2'1     ?        possible intended match
39; ALIGN-NEXT:>>>>>>
40; ALIGN-NOT:{{.}}
41
42;--------------------------------------------------
43; CHECK (also: multi-line search range, fuzzy match)
44;--------------------------------------------------
45
46; Good match and no match.
47
48; RUN: echo 'hello'   > %t.in
49; RUN: echo 'again'   >> %t.in
50; RUN: echo 'whirled' >> %t.in
51
52; RUN: echo 'CHECK: hello' > %t.chk
53; RUN: echo 'CHECK: world' >> %t.chk
54
55; RUN: %ProtectFileCheckOutput \
56; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
57; RUN: | FileCheck -match-full-lines %s -check-prefix=CHK \
58; RUN:             -implicit-check-not='remark:'
59; RUN: %ProtectFileCheckOutput \
60; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
61; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V \
62; RUN:             -implicit-check-not='remark:'
63; RUN: %ProtectFileCheckOutput \
64; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
65; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V \
66; RUN:             -implicit-check-not='remark:'
67
68; Verbose diagnostics are suppressed but not errors.
69; CHK: {{.*}}error:{{.*}}
70; CHK: {{.*}}possible intended match here{{.*}}
71
72; CHK:        <<<<<<
73; CHK-NEXT:              1: hello
74; CHK-V-NEXT: check:1       ^~~~~
75; CHK-NEXT:   check:2'0          X error: no match found
76; CHK-NEXT:              2: again
77; CHK-NEXT:   check:2'0     ~~~~~~
78; CHK-NEXT:              3: whirled
79; CHK-NEXT:   check:2'0     ~~~~~~~~
80; CHK-NEXT:   check:2'1     ?        possible intended match
81; CHK-NEXT:   >>>>>>
82; CHK-NOT:    {{.}}
83
84;--------------------------------------------------
85; CHECK-COUNT-<num>
86;--------------------------------------------------
87
88; Good match and no match.
89
90; RUN: echo 'pete'   > %t.in
91; RUN: echo 'repete' >> %t.in
92; RUN: echo 'repeat' >> %t.in
93
94; RUN: echo 'CHECK-COUNT-3: pete' > %t.chk
95
96; RUN: %ProtectFileCheckOutput \
97; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
98; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-Q \
99; RUN:             -implicit-check-not='remark:'
100; RUN: %ProtectFileCheckOutput \
101; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
102; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V \
103; RUN:             -implicit-check-not='remark:'
104; RUN: %ProtectFileCheckOutput \
105; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
106; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V \
107; RUN:             -implicit-check-not='remark:'
108
109; Verbose diagnostics are suppressed but not errors.
110; CNT: {{.*}}error:{{.*}}
111
112; CNT:          <<<<<<
113; CNT-NEXT:                1: pete
114; CNT-V-NEXT:   count:1'0     ^~~~
115; CNT-NEXT:                2: repete
116; CNT-V-NEXT:   count:1'1       ^~~~
117; CNT-Q-NEXT:   count:1'0           X error: no match found
118; CNT-V-NEXT:   count:1'2           X error: no match found
119; CNT-NEXT:                3: repeat
120; CNT-Q-NEXT:   count:1'0     ~~~~~~~
121; CNT-Q-NEXT:   count:1'1     ?       possible intended match
122; CNT-V-NEXT:   count:1'2     ~~~~~~~
123; CNT-V-NEXT:   count:1'3     ?       possible intended match
124; CNT-NEXT:     >>>>>>
125; CNT-NOT:      {{.}}
126
127;--------------------------------------------------
128; CHECK-NEXT (also: EOF search-range, wrong-line match)
129;--------------------------------------------------
130
131; Good match and no match.
132
133; RUN: echo 'hello' > %t.in
134; RUN: echo 'again' >> %t.in
135
136; RUN: echo 'CHECK: hello' > %t.chk
137; RUN: echo 'CHECK-NEXT: again' >> %t.chk
138; RUN: echo 'CHECK-NEXT: world' >> %t.chk
139
140; RUN: %ProtectFileCheckOutput \
141; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
142; RUN: | FileCheck -match-full-lines %s -check-prefix=NXT \
143; RUN:             -implicit-check-not='remark:'
144; RUN: %ProtectFileCheckOutput \
145; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
146; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V \
147; RUN:             -implicit-check-not='remark:'
148; RUN: %ProtectFileCheckOutput \
149; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
150; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V,NXT-VV \
151; RUN:             -implicit-check-not='remark:' -allow-unused-prefixes
152
153; Verbose diagnostics are suppressed but not errors.
154; NXT: {{.*}}error:{{.*}}
155
156; NXT:        <<<<<<
157; NXT-NEXT:            1: hello
158; NXT-V-NEXT: check:1     ^~~~~
159; NXT-NEXT:            2: again
160; NXT-V-NEXT: next:2      ^~~~~
161; NXT-NEXT:   next:3           X error: no match found
162; NXT-NEXT:   >>>>>>
163; NXT-NOT:    {{.}}
164
165; Wrong-line match.
166
167; RUN: echo 'yonder' >> %t.in
168; RUN: echo 'world' >> %t.in
169
170; RUN: %ProtectFileCheckOutput \
171; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
172; RUN: | FileCheck -match-full-lines %s -check-prefix=NXT2
173
174; NXT2:      <<<<<<
175; NXT2-NEXT:         1: hello
176; NXT2-NEXT:         2: again
177; NXT2-NEXT:         3: yonder
178; NXT2-NEXT:         4: world
179; NXT2-NEXT: next:3     !~~~~  error: match on wrong line
180; NXT2-NEXT: >>>>>>
181; NXT2-NOT:  {{.}}
182
183;--------------------------------------------------
184; CHECK-SAME (also: multiple annotations per line, single-char search range,
185; wrong-line match)
186;--------------------------------------------------
187
188; Good match and no match.
189
190; RUN: echo 'hello world!' > %t.in
191
192; RUN: echo 'CHECK: hello' > %t.chk
193; RUN: echo 'CHECK-SAME: world' >> %t.chk
194; RUN: echo 'CHECK-SAME: again' >> %t.chk
195
196; RUN: %ProtectFileCheckOutput \
197; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
198; RUN: | FileCheck -match-full-lines %s -check-prefix=SAM \
199; RUN:             -implicit-check-not='remark:'
200; RUN: %ProtectFileCheckOutput \
201; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
202; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V \
203; RUN:             -implicit-check-not='remark:'
204; RUN: %ProtectFileCheckOutput \
205; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
206; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V,SAM-VV \
207; RUN:             -implicit-check-not='remark:' -allow-unused-prefixes
208
209; Verbose diagnostics are suppressed but not errors.
210; SAM: {{.*}}error:{{.*}}
211
212; SAM:        <<<<<<
213; SAM-NEXT:            1: hello world!
214; SAM-V-NEXT: check:1     ^~~~~
215; SAM-V-NEXT: same:2            ^~~~~
216; SAM-NEXT:   same:3                 X~ error: no match found
217; SAM-NEXT:   >>>>>>
218; SAM-NOT:    {{.}}
219
220; Wrong-line match.
221
222; RUN: echo 'again' >> %t.in
223
224; RUN: %ProtectFileCheckOutput \
225; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
226; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM2 \
227; RUN:             -implicit-check-not='remark:'
228
229; Verbose diagnostics are suppressed but not errors.
230; SAM2: {{.*}}error:{{.*}}
231
232; SAM2:      <<<<<<
233; SAM2-NEXT:          1: hello world!
234; SAM2-NEXT: check:1     ^~~~~
235; SAM2-NEXT: same:2            ^~~~~
236; SAM2-NEXT:          2: again
237; SAM2-NEXT: same:3      !~~~~  error: match on wrong line
238; SAM2-NEXT: >>>>>>
239; SAM2-NOT:  {{.}}
240
241;--------------------------------------------------
242; CHECK-EMPTY (also: search range ends at label, single-char match, wrong-line
243; match)
244;--------------------------------------------------
245
246; Good match and no match.
247;
248; CHECK-EMPTY always seems to match an empty line at EOF (illegally when it's
249; not the next line) unless either (1) the last line is non-empty and has no
250; newline or (2) there's a CHECK-LABEL to end the search range before EOF.  We
251; choose scenario 2 to check the case of no match.
252
253; RUN: echo 'hello' > %t.in
254; RUN: echo '' >> %t.in
255; RUN: echo 'world' >> %t.in
256; RUN: echo 'label' >> %t.in
257
258; RUN: echo 'CHECK: hello' > %t.chk
259; RUN: echo 'CHECK-EMPTY:' >> %t.chk
260; RUN: echo 'CHECK-EMPTY:' >> %t.chk
261; RUN: echo 'CHECK-LABEL: label' >> %t.chk
262
263; RUN: %ProtectFileCheckOutput \
264; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
265; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP \
266; RUN:             -implicit-check-not='remark:'
267; RUN: %ProtectFileCheckOutput \
268; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
269; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V \
270; RUN:             -implicit-check-not='remark:'
271; RUN: %ProtectFileCheckOutput \
272; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
273; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V,EMP-VV \
274; RUN:             -implicit-check-not='remark:' -allow-unused-prefixes
275
276; Verbose diagnostics are suppressed but not errors.
277; EMP: {{.*}}error:{{.*}}
278
279; EMP:        <<<<<<
280; EMP-NEXT:            1: hello
281; EMP-V-NEXT: check:1     ^~~~~
282; EMP-NEXT:            2:
283; EMP-V-NEXT: empty:2     ^
284; EMP-NEXT:   empty:3          X error: no match found
285; EMP-NEXT:            3: world
286; EMP-NEXT:   empty:3     ~~~~~~
287; EMP-NEXT:            4: label
288; EMP-V-NEXT: label:4     ^~~~~
289; EMP-NEXT:   empty:3     ~~~~~
290; EMP-NEXT:   >>>>>>
291; EMP-NOT:    {{.}}
292
293; Wrong-line match.
294
295; RUN: echo 'hello' > %t.in
296; RUN: echo 'world' >> %t.in
297
298; RUN: echo 'CHECK: hello' > %t.chk
299; RUN: echo 'CHECK-EMPTY:' >> %t.chk
300
301; RUN: %ProtectFileCheckOutput \
302; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
303; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP2 \
304; RUN:             -implicit-check-not='remark:'
305; RUN: %ProtectFileCheckOutput \
306; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
307; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V \
308; RUN:             -implicit-check-not='remark:'
309; RUN: %ProtectFileCheckOutput \
310; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
311; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V,EMP2-VV \
312; RUN:             -implicit-check-not='remark:' -allow-unused-prefixes
313
314; Verbose diagnostics are suppressed but not errors.
315; EMP2: {{.*}}error:{{.*}}
316
317; EMP2:        <<<<<<
318; EMP2-NEXT:            1: hello
319; EMP2-V-NEXT: check:1     ^~~~~
320; EMP2-NEXT:            2: world
321; EMP2-NEXT:            3:
322; EMP2-NEXT:   empty:2     !      error: match on wrong line
323; EMP2-NEXT:   >>>>>>
324; EMP2-NOT:    {{.}}
325
326;--------------------------------------------------
327; CHECK-NOT (also: EOF pattern, and multiline range that ends before EOL)
328;--------------------------------------------------
329
330; No match (success) and unexpected match (error).
331
332; RUN: echo 'hello' > %t.in
333; RUN: echo 'world' >> %t.in
334; RUN: echo 'again' >> %t.in
335
336; RUN: echo 'CHECK-NOT: goodbye' > %t.chk
337; RUN: echo 'CHECK-NOT: world' >> %t.chk
338
339; RUN: %ProtectFileCheckOutput \
340; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
341; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT \
342; RUN:             -implicit-check-not='remark:'
343; RUN: %ProtectFileCheckOutput \
344; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
345; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V \
346; RUN:             -implicit-check-not='remark:' -allow-unused-prefixes
347; RUN: %ProtectFileCheckOutput \
348; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
349; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V,NOT-VV \
350; RUN:             -implicit-check-not='remark:' -allow-unused-prefixes
351
352; Verbose diagnostics are suppressed but not errors.
353; NOT: {{.*}}error:{{.*}}
354
355; NOT:         <<<<<<
356; NOT-NEXT:           1: hello
357; NOT-VV-NEXT: not:1     X~~~~~
358; NOT-NEXT:           2: world
359; NOT-VV-NEXT: not:1     ~~~~~~
360; NOT-NEXT:    not:2     !~~~~  error: no match expected
361; NOT-NEXT:           3: again
362; NOT-VV-NEXT: not:1     ~~~~~~
363; NOT-VV-NEXT:        4:
364; NOT-VV-NEXT: eof:2     ^
365; NOT-NEXT:    >>>>>>
366; NOT-NOT:     {{.}}
367
368; Again, but with a CHECK instead of EOF as search range end.
369
370; RUN: echo 'CHECK: ain' >> %t.chk
371
372; RUN: %ProtectFileCheckOutput \
373; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
374; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT2 \
375; RUN:             -implicit-check-not='remark:'
376; RUN: %ProtectFileCheckOutput \
377; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
378; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V \
379; RUN:             -implicit-check-not='remark:'
380; RUN: %ProtectFileCheckOutput \
381; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
382; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V,NOT2-VV \
383; RUN:             -implicit-check-not='remark:'
384
385; Verbose diagnostics are suppressed but not errors.
386; NOT2: {{.*}}error:{{.*}}
387
388; NOT2:         <<<<<<
389; NOT2-NEXT:             1: hello
390; NOT2-VV-NEXT: not:1       X~~~~~
391; NOT2-NEXT:             2: world
392; NOT2-VV-NEXT: not:1       ~~~~~~
393; NOT2-NEXT:    not:2       !~~~~  error: no match expected
394; NOT2-NEXT:             3: again
395; NOT2-V-NEXT:  check:3       ^~~
396; NOT2-VV-NEXT: not:1       ~~
397; NOT2-NEXT:    >>>>>>
398; NOT2-NOT:     {{.}}
399
400;--------------------------------------------------
401; CHECK-DAG (also: matches in different order than directives, discarded match)
402;--------------------------------------------------
403
404; Good match, discarded match plus good match, and no match.
405
406; RUN: echo 'abc' > %t.in
407; RUN: echo 'def' >> %t.in
408; RUN: echo 'abc' >> %t.in
409
410; RUN: echo 'CHECK-DAG: def' > %t.chk
411; RUN: echo 'CHECK-DAG: abc' >> %t.chk
412; RUN: echo 'CHECK-DAG: abc' >> %t.chk
413; RUN: echo 'CHECK-DAG: def' >> %t.chk
414
415; Prefixes used here:
416; DAG    = quiet, -v, or -vv
417; DAG-Q  = quiet
418; DAG-V  = -v or -vv (-vv implies -v)
419; DAG-VQ = -v and not -vv
420; DAG-VV = -vv
421
422; RUN: %ProtectFileCheckOutput \
423; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
424; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-Q \
425; RUN:             -implicit-check-not='remark:'
426; RUN: %ProtectFileCheckOutput \
427; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
428; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VQ \
429; RUN:             -implicit-check-not='remark:'
430; RUN: %ProtectFileCheckOutput \
431; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
432; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VV \
433; RUN:             -implicit-check-not='remark:'
434
435; Verbose diagnostics are suppressed but not errors.
436; DAG: {{.*}}error:{{.*}}
437
438; DAG:         <<<<<<
439; DAG-NEXT:             1: abc
440; DAG-V-NEXT:  dag:2       ^~~
441; DAG-VV-NEXT: dag:3'0     !~~  discard: overlaps earlier match
442; DAG-NEXT:             2: def
443; DAG-V-NEXT:  dag:1       ^~~
444; DAG-VV-NEXT: dag:4'0     !~~  discard: overlaps earlier match
445; DAG-Q-NEXT:  dag:4          X error: no match found
446; DAG-VQ-NEXT: dag:4          X error: no match found
447; DAG-VV-NEXT: dag:4'1        X error: no match found
448; DAG-NEXT:             3: abc
449; DAG-VQ-NEXT: dag:3       ^~~
450; DAG-VV-NEXT: dag:3'1     ^~~
451; DAG-Q-NEXT:  dag:4       ~~~~
452; DAG-VQ-NEXT: dag:4       ~~~~
453; DAG-VV-NEXT: dag:4'1     ~~~~
454; DAG-NEXT:    >>>>>>
455; DAG-NOT:     {{.}}
456
457; Check sorting of annotations when the order of diagnostics across an input
458; line is different than the order of the associated directives in the check
459; file.  Try cases when diagnostics' input ranges overlap but are not
460; identical to check how that affects sorting.
461
462; RUN: echo 'abc def abc def' > %t.in
463
464; RUN: echo 'CHECK-DAG: def' > %t.chk
465; RUN: echo 'CHECK-DAG: bc' >> %t.chk
466; RUN: echo 'CHECK-DAG: abc' >> %t.chk
467; RUN: echo 'CHECK-DAG: de' >> %t.chk
468; RUN: echo 'CHECK-DAG: def' >> %t.chk
469
470; RUN: %ProtectFileCheckOutput \
471; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
472; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG1L,DAG1L-Q \
473; RUN:             -implicit-check-not='remark:'
474; RUN: %ProtectFileCheckOutput \
475; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
476; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG1L,DAG1L-V,DAG1L-VQ \
477; RUN:             -implicit-check-not='remark:'
478; RUN: %ProtectFileCheckOutput \
479; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
480; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG1L,DAG1L-V,DAG1L-VV \
481; RUN:             -implicit-check-not='remark:'
482
483; Verbose diagnostics are suppressed but not errors.
484; DAG1L:{{.*}}error:{{.*}}
485
486;         DAG1L:<<<<<<
487;    DAG1L-NEXT:         1: abc def abc def
488;  DAG1L-V-NEXT:dag:1           ^~~
489;  DAG1L-V-NEXT:dag:2        ^~
490; DAG1L-VV-NEXT:dag:3'0     !~~              discard: overlaps earlier match
491; DAG1L-VQ-NEXT:dag:3               ^~~
492; DAG1L-VV-NEXT:dag:3'1             ^~~
493; DAG1L-VV-NEXT:dag:4'0         !~           discard: overlaps earlier match
494; DAG1L-VQ-NEXT:dag:4                   ^~
495; DAG1L-VV-NEXT:dag:4'1                 ^~
496; DAG1L-VV-NEXT:dag:5'0         !~~          discard: overlaps earlier match
497; DAG1L-VV-NEXT:dag:5'1                 !~~  discard: overlaps earlier match
498;  DAG1L-Q-NEXT:dag:5                     X~ error: no match found
499; DAG1L-VQ-NEXT:dag:5                     X~ error: no match found
500; DAG1L-VV-NEXT:dag:5'2                   X~ error: no match found
501;    DAG1L-NEXT:>>>>>>
502;     DAG1L-NOT:{{.}}
503
504;--------------------------------------------------
505; CHECK-LABEL
506;
507; Each CHECK-LABEL is processed twice: once before other patterns in the
508; preceding section, and once afterward.
509;
510; As expected, the search range for a negative pattern preceding a CHECK-LABEL
511; ends at the start of the CHECK-LABEL match.  not:7 and not:11 below
512; demonstrate this behavior.
513;
514; The search range for a positive pattern preceding a CHECK-LABEL ends at the
515; end of the CHECK-LABEL match.  check:3 and check:5 below demonstrate this
516; behavior.  As in the case of check:5, an effect of this behavior is that the
517; second CHECK-LABEL match might fail even though the first succeeded.
518;
519; FIXME: It seems like the search range for such a positive pattern should be
520; the same as in the case of a negative pattern.  Note that -dump-input is
521; correct here.  It's the matching behavior that's strange.
522;--------------------------------------------------
523
524; RUN: echo 'text'   >  %t.in
525; RUN: echo 'labelA' >> %t.in
526; RUN: echo 'textA'  >> %t.in
527; RUN: echo 'labelB' >> %t.in
528; RUN: echo 'textB'  >> %t.in
529; RUN: echo 'labelC' >> %t.in
530; RUN: echo 'textC'  >> %t.in
531; RUN: echo 'labelD' >> %t.in
532; RUN: echo 'textD'  >> %t.in
533; RUN: echo 'labelE' >> %t.in
534; RUN: echo 'textE'  >> %t.in
535; RUN: echo 'labelF' >> %t.in
536
537; RUN: echo 'CHECK: text'         >  %t.chk
538; RUN: echo 'CHECK-LABEL: labelA' >> %t.chk
539; RUN: echo 'CHECK: foobar'       >> %t.chk
540; RUN: echo 'CHECK-LABEL: labelB' >> %t.chk
541; RUN: echo 'CHECK: labelC'       >> %t.chk
542; RUN: echo 'CHECK-LABEL: labelC' >> %t.chk
543; RUN: echo 'CHECK-NOT: foobar'   >> %t.chk
544; RUN: echo 'CHECK-LABEL: labelD' >> %t.chk
545; RUN: echo 'CHECK-NOT: textD'    >> %t.chk
546; RUN: echo 'CHECK-LABEL: labelE' >> %t.chk
547; RUN: echo 'CHECK-NOT: labelF'   >> %t.chk
548; RUN: echo 'CHECK-LABEL: labelF' >> %t.chk
549
550; RUN: %ProtectFileCheckOutput \
551; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \
552; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-Q \
553; RUN:             -implicit-check-not='{{remark:|error:}}'
554; RUN: %ProtectFileCheckOutput \
555; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \
556; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V \
557; RUN:             -implicit-check-not='{{remark:|error:}}'
558; RUN: %ProtectFileCheckOutput \
559; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \
560; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V,LAB-VV \
561; RUN:             -implicit-check-not='{{remark:|error:}}'
562
563; Verbose diagnostics are suppressed but not errors.
564; LAB:{{.*}}.chk:3:8: error: CHECK: expected string not found in input
565; LAB:{{.*}}.chk:6:14: error: CHECK-LABEL: expected string not found in input
566; LAB:{{.*}}.chk:9:12: error: CHECK-NOT: excluded string found in input
567
568;         LAB:<<<<<<
569;    LAB-NEXT:            1: text
570;  LAB-V-NEXT:check:1        ^~~~
571;    LAB-NEXT:            2: labelA
572;  LAB-V-NEXT:label:2'0      ^~~~~~
573;  LAB-V-NEXT:label:2'1      ^~~~~~
574;    LAB-NEXT:check:3              X error: no match found
575;    LAB-NEXT:            3: textA
576;    LAB-NEXT:check:3        ~~~~~~
577;    LAB-NEXT:            4: labelB
578;  LAB-V-NEXT:label:4        ^~~~~~
579;    LAB-NEXT:check:3        ~~~~~~
580;    LAB-NEXT:            5: textB
581;    LAB-NEXT:            6: labelC
582;  LAB-V-NEXT:label:6'0      ^~~~~~
583;  LAB-V-NEXT:check:5        ^~~~~~
584;  LAB-Q-NEXT:label:6              X error: no match found
585;  LAB-V-NEXT:label:6'1            X error: no match found
586; LAB-VV-NEXT:not:7                X
587;    LAB-NEXT:            7: textC
588; LAB-VV-NEXT:not:7          ~~~~~~
589;    LAB-NEXT:            8: labelD
590;  LAB-V-NEXT:label:8'0      ^~~~~~
591;  LAB-V-NEXT:label:8'1      ^~~~~~
592;    LAB-NEXT:            9: textD
593;    LAB-NEXT:not:9          !~~~~  error: no match expected
594;    LAB-NEXT:           10: labelE
595;  LAB-V-NEXT:label:10'0     ^~~~~~
596;  LAB-V-NEXT:label:10'1     ^~~~~~
597; LAB-VV-NEXT:not:11               X
598;    LAB-NEXT:           11: textE
599; LAB-VV-NEXT:not:11         ~~~~~~
600;    LAB-NEXT:           12: labelF
601;  LAB-V-NEXT:label:12'0     ^~~~~~
602;  LAB-V-NEXT:label:12'1     ^~~~~~
603;    LAB-NEXT:>>>>>>
604;     LAB-NOT:{{.}}
605
606;--------------------------------------------------
607; --implicit-check-not
608;
609; The first two --implicit-check-not patterns have no match (success).  The
610; third has an unexpected match (error).  To check per-input-line annotation
611; sorting, all of those plus the CHECK directives have annotations on the same
612; input line.
613;--------------------------------------------------
614
615; RUN: echo 'hello world again!' > %t.in
616
617; RUN: echo 'CHECK: hel' > %t.chk
618; RUN: echo 'CHECK: wor' >> %t.chk
619; RUN: echo 'CHECK: !' >> %t.chk
620
621; Prefixes used here:
622; IMPNOT    = quiet, -v, or -vv
623; IMPNOT-Q  = quiet
624; IMPNOT-V  = -v or -vv (-vv implies -v)
625; IMPNOT-VQ = -v and not -vv
626; IMPNOT-VV = -vv
627
628; RUN: %ProtectFileCheckOutput \
629; RUN: not FileCheck -dump-input=always -input-file=%t.in %t.chk 2>&1 \
630; RUN:               --implicit-check-not='goodbye' \
631; RUN:               --implicit-check-not='world' \
632; RUN:               --implicit-check-not='again' \
633; RUN: | FileCheck -match-full-lines %s -check-prefixes=IMPNOT,IMPNOT-Q \
634; RUN:             -implicit-check-not='{{remark:|error:}}'
635; RUN: %ProtectFileCheckOutput \
636; RUN: not FileCheck -dump-input=always -input-file=%t.in %t.chk -v 2>&1 \
637; RUN:               --implicit-check-not='goodbye' \
638; RUN:               --implicit-check-not='world' \
639; RUN:               --implicit-check-not='again' \
640; RUN: | FileCheck -match-full-lines %s \
641; RUN:             -check-prefixes=IMPNOT,IMPNOT-V,IMPNOT-VQ \
642; RUN:             -implicit-check-not='{{remark:|error:}}'
643; RUN: %ProtectFileCheckOutput \
644; RUN: not FileCheck -dump-input=always -input-file=%t.in %t.chk -vv 2>&1 \
645; RUN:               --implicit-check-not='goodbye' \
646; RUN:               --implicit-check-not='world' \
647; RUN:               --implicit-check-not='again' \
648; RUN: | FileCheck -match-full-lines %s \
649; RUN:             -check-prefixes=IMPNOT,IMPNOT-V,IMPNOT-VV \
650; RUN:             -implicit-check-not='{{remark:|error:}}'
651
652; Verbose diagnostics are suppressed but not errors.
653; IMPNOT:{{.*}}command line:1:22: error: IMPLICIT-CHECK-NOT: excluded string found in input
654
655;         IMPNOT:<<<<<<
656;    IMPNOT-NEXT:            1: hello world again!
657;  IMPNOT-V-NEXT:check:1        ^~~
658; IMPNOT-VV-NEXT:not:imp1'0     X
659; IMPNOT-VV-NEXT:not:imp2'0     X
660; IMPNOT-VV-NEXT:not:imp3'0     X
661;  IMPNOT-V-NEXT:check:2              ^~~
662; IMPNOT-VV-NEXT:not:imp1'1        X~~
663; IMPNOT-VV-NEXT:not:imp2'1        X~~
664; IMPNOT-VV-NEXT:not:imp3'1        X~~
665;  IMPNOT-V-NEXT:check:3                         ^
666; IMPNOT-VV-NEXT:not:imp1'2              X~~~~~~~
667; IMPNOT-VV-NEXT:not:imp2'2              X~~~~~~~
668;  IMPNOT-Q-NEXT:not:imp3                   !~~~~   error: no match expected
669; IMPNOT-VQ-NEXT:not:imp3                   !~~~~   error: no match expected
670; IMPNOT-VV-NEXT:not:imp3'2                 !~~~~   error: no match expected
671;    IMPNOT-NEXT:>>>>>>
672;     IMPNOT-NOT:{{.}}
673
674;--------------------------------------------------
675; Substitutions: successful and failed positive directives.
676;--------------------------------------------------
677
678; RUN: echo 'def-match1 def-match2'  >  %t.in
679; RUN: echo 'def-match1 def-nomatch' >> %t.in
680
681; RUN: echo 'CHECK: [[DEF_MATCH1]] [[DEF_MATCH2]]'            >  %t.chk
682; RUN: echo 'CHECK: [[DEF_MATCH1]] [[UNDEF]] [[DEF_NOMATCH]]' >> %t.chk
683
684; RUN: %ProtectFileCheckOutput \
685; RUN: not FileCheck -dump-input=always -vv -input-file=%t.in %t.chk 2>&1 \
686; RUN:               -DDEF_MATCH1=def-match1 -DDEF_MATCH2=def-match2 \
687; RUN:               -DDEF_NOMATCH=foobar \
688; RUN: | FileCheck -match-full-lines %s -check-prefix=SUBST-POS
689
690;      SUBST-POS:<<<<<<
691; SUBST-POS-NEXT:           1: def-match1 def-match2
692; SUBST-POS-NEXT:check:1'0     ^~~~~~~~~~~~~~~~~~~~~
693; SUBST-POS-NEXT:check:1'1                            with "DEF_MATCH1" equal to "def-match1"
694; SUBST-POS-NEXT:check:1'2                            with "DEF_MATCH2" equal to "def-match2"
695; SUBST-POS-NEXT:check:2'0     X error: match failed for invalid pattern
696; SUBST-POS-NEXT:check:2'1                            undefined variable: UNDEF
697; SUBST-POS-NEXT:check:2'2                            with "DEF_MATCH1" equal to "def-match1"
698; SUBST-POS-NEXT:check:2'3                            with "DEF_NOMATCH" equal to "foobar"
699; SUBST-POS-NEXT:           2: def-match1 def-nomatch
700; SUBST-POS-NEXT:check:2'0     ~~~~~~~~~~~~~~~~~~~~~~~
701; SUBST-POS-NEXT:check:2'4 ? possible intended match
702; SUBST-POS-NEXT:>>>>>>
703
704;--------------------------------------------------
705; Substitutions: successful and failed negative directives.
706;--------------------------------------------------
707
708; RUN: echo 'def-match1 def-nomatch' >  %t.in
709; RUN: echo 'def-match1 def-match2'  >> %t.in
710; RUN: echo 'END'                    >> %t.in
711
712; RUN: echo 'CHECK-NOT: [[DEF_MATCH1]] [[UNDEF]] [[DEF_NOMATCH]]' >  %t.chk
713; RUN: echo 'CHECK-NOT: [[DEF_MATCH1]] [[DEF_MATCH2]]'            >> %t.chk
714; RUN: echo 'CHECK: END'                                          >> %t.chk
715
716; RUN: %ProtectFileCheckOutput \
717; RUN: not FileCheck -dump-input=always -vv -input-file=%t.in %t.chk 2>&1 \
718; RUN:               -DDEF_MATCH1=def-match1 -DDEF_MATCH2=def-match2 \
719; RUN:               -DDEF_NOMATCH=foobar \
720; RUN: | FileCheck -match-full-lines %s -check-prefix=SUBST-NEG
721
722;      SUBST-NEG:<<<<<<
723; SUBST-NEG-NEXT:         1: def-match1 def-nomatch
724; SUBST-NEG-NEXT:not:1'0     X~~~~~~~~~~~~~~~~~~~~~~ error: match failed for invalid pattern
725; SUBST-NEG-NEXT:not:1'1                             undefined variable: UNDEF
726; SUBST-NEG-NEXT:not:1'2                             with "DEF_MATCH1" equal to "def-match1"
727; SUBST-NEG-NEXT:not:1'3                             with "DEF_NOMATCH" equal to "foobar"
728; SUBST-NEG-NEXT:         2: def-match1 def-match2
729; SUBST-NEG-NEXT:not:1'0     ~~~~~~~~~~~~~~~~~~~~~~
730; SUBST-NEG-NEXT:not:2'0     !~~~~~~~~~~~~~~~~~~~~  error: no match expected
731; SUBST-NEG-NEXT:not:2'1                            with "DEF_MATCH1" equal to "def-match1"
732; SUBST-NEG-NEXT:not:2'2                            with "DEF_MATCH2" equal to "def-match2"
733; SUBST-NEG-NEXT:         3: END
734; SUBST-NEG-NEXT:check:3     ^~~
735; SUBST-NEG-NEXT:>>>>>>
736
737;--------------------------------------------------
738; Captured variables
739;--------------------------------------------------
740
741; RUN: echo 'strvar: foo'           >  %t.in
742; RUN: echo 'numvar no expr: 51'    >> %t.in
743; RUN: echo 'numvar expr: -49'      >> %t.in
744; RUN: echo 'many: foo 100 8 bar'   >> %t.in
745; RUN: echo 'var in neg match: foo' >> %t.in
746; RUN: echo 'END'                   >> %t.in
747
748; RUN: echo 'CHECK: strvar: [[STRVAR:[a-z]+]]'                         >  %t.chk
749; RUN: echo 'CHECK: numvar no expr: [[#NUMVAR_NO_EXPR:]]'              >> %t.chk
750; RUN: echo 'CHECK: numvar expr: [[#%d,NUMVAR_EXPR:2-NUMVAR_NO_EXPR]]' >> %t.chk
751
752; Capture many variables of different kinds in a different order than their
753; names sort alphabetically to ensure they're sorted in capture order.
754; RUN: echo 'CHECK: many: [[VAR1:foo]] [[#%d,VAR3:]] [[#VAR2:]] [[VAR4:bar]]' \
755; RUN:      >> %t.chk
756
757; RUN: echo 'CHECK-NOT: var in neg match: [[VAR:foo]]' >> %t.chk
758; RUN: echo 'CHECK: END'                               >> %t.chk
759
760; RUN: %ProtectFileCheckOutput \
761; RUN: not FileCheck -dump-input=always -vv -input-file=%t.in %t.chk 2>&1 \
762; RUN: | FileCheck -strict-whitespace -match-full-lines %s -check-prefix=CAPTURE-NEG
763
764;      CAPTURE-NEG:<<<<<<
765; CAPTURE-NEG-NEXT:           1: strvar: foo
766; CAPTURE-NEG-NEXT:check:1'0     ^~~~~~~~~~~
767; CAPTURE-NEG-NEXT:check:1'1             ^~~  captured var "STRVAR"
768; CAPTURE-NEG-NEXT:           2: numvar no expr: 51
769; CAPTURE-NEG-NEXT:check:2'0     ^~~~~~~~~~~~~~~~~~
770; CAPTURE-NEG-NEXT:check:2'1                     ^~  captured var "NUMVAR_NO_EXPR"
771; CAPTURE-NEG-NEXT:           3: numvar expr: -49
772; CAPTURE-NEG-NEXT:check:3'0     ^~~~~~~~~~~~~~~~
773; CAPTURE-NEG-NEXT:check:3'1                       with "%d,NUMVAR_EXPR:2-NUMVAR_NO_EXPR" equal to "-49"
774; CAPTURE-NEG-NEXT:check:3'2                  ^~~  captured var "NUMVAR_EXPR"
775; CAPTURE-NEG-NEXT:           4: many: foo 100 8 bar
776; CAPTURE-NEG-NEXT:check:4'0     ^~~~~~~~~~~~~~~~~~~
777; CAPTURE-NEG-NEXT:check:4'1           ^~~            captured var "VAR1"
778; CAPTURE-NEG-NEXT:check:4'2               ^~~        captured var "VAR3"
779; CAPTURE-NEG-NEXT:check:4'3                   ^      captured var "VAR2"
780; CAPTURE-NEG-NEXT:check:4'4                     ^~~  captured var "VAR4"
781; CAPTURE-NEG-NEXT:           5: var in neg match: foo
782; CAPTURE-NEG-NEXT:not:5'0       !~~~~~~~~~~~~~~~~~~~~  error: no match expected
783; CAPTURE-NEG-NEXT:not:5'1                         !~~  captured var "VAR"
784; CAPTURE-NEG-NEXT:           6: END
785; CAPTURE-NEG-NEXT:check:6       ^~~
786; CAPTURE-NEG-NEXT:>>>>>>
787
788;--------------------------------------------------
789; CHECK-NEXT, CHECK-SAME, CHECK-DAG note fixups.
790;
791; When CHECK-NEXT or CHECK-SAME fails for the wrong line, or when a CHECK-DAG
792; match is discarded, the associated diagnostic type must be converted from
793; successful to failed or discarded.  However, any note annotation must be
794; traversed to find that diagnostic.  We check this behavior here only for
795; substitutions, but it's the same mechanism for all note annotations.
796;--------------------------------------------------
797
798;- - - - - - - - - - - - - - - - - - - - - - - - -
799; CHECK-NEXT.
800;- - - - - - - - - - - - - - - - - - - - - - - - -
801
802; RUN: echo 'pre var' > %t.in
803
804; RUN: echo 'CHECK: pre'          >  %t.chk
805; RUN: echo 'CHECK-NEXT: [[VAR]]' >> %t.chk
806
807; RUN: %ProtectFileCheckOutput \
808; RUN: not FileCheck -dump-input=always -vv -input-file=%t.in %t.chk 2>&1 \
809; RUN:               -DVAR=var \
810; RUN: | FileCheck -match-full-lines %s -check-prefix=SUBST_NEXT
811
812;      SUBST_NEXT:<<<<<<
813; SUBST_NEXT-NEXT:          1: pre var
814; SUBST_NEXT-NEXT:check:1      ^~~
815; SUBST_NEXT-NEXT:next:2'0         !~~  error: match on wrong line
816; SUBST_NEXT-NEXT:next:2'1              with "VAR" equal to "var"
817; SUBST_NEXT-NEXT:>>>>>>
818
819;- - - - - - - - - - - - - - - - - - - - - - - - -
820; CHECK-SAME.
821;- - - - - - - - - - - - - - - - - - - - - - - - -
822
823; RUN: echo 'pre' >  %t.in
824; RUN: echo 'var' >> %t.in
825
826; RUN: echo 'CHECK: pre'          >  %t.chk
827; RUN: echo 'CHECK-SAME: [[VAR]]' >> %t.chk
828
829; RUN: %ProtectFileCheckOutput \
830; RUN: not FileCheck -dump-input=always -vv -input-file=%t.in %t.chk 2>&1 \
831; RUN:               -DVAR=var \
832; RUN: | FileCheck -match-full-lines %s -check-prefix=SUBST_SAME
833
834;      SUBST_SAME:<<<<<<
835; SUBST_SAME-NEXT:          1: pre
836; SUBST_SAME-NEXT:check:1      ^~~
837; SUBST_SAME-NEXT:          2: var
838; SUBST_SAME-NEXT:same:2'0     !~~  error: match on wrong line
839; SUBST_SAME-NEXT:same:2'1          with "VAR" equal to "var"
840; SUBST_SAME-NEXT:>>>>>>
841
842;- - - - - - - - - - - - - - - - - - - - - - - - -
843; CHECK-DAG.
844;- - - - - - - - - - - - - - - - - - - - - - - - -
845
846; RUN: echo 'var' >  %t.in
847; RUN: echo 'var' >> %t.in
848; RUN: echo 'END' >> %t.in
849
850; RUN: echo 'CHECK-DAG: var'      >  %t.chk
851; RUN: echo 'CHECK-DAG: [[VAR]]'  >> %t.chk
852; RUN: echo 'CHECK: END'          >> %t.chk
853
854; RUN: %ProtectFileCheckOutput \
855; RUN: FileCheck -dump-input=always -vv -input-file=%t.in %t.chk 2>&1 \
856; RUN:           -DVAR=var \
857; RUN: | FileCheck -match-full-lines %s -check-prefix=SUBST_DAG
858
859;      SUBST_DAG:<<<<<<
860; SUBST_DAG-NEXT:         1: var
861; SUBST_DAG-NEXT:dag:1       ^~~
862; SUBST_DAG-NEXT:dag:2'0     !~~  discard: overlaps earlier match
863; SUBST_DAG-NEXT:dag:2'1          with "VAR" equal to "var"
864; SUBST_DAG-NEXT:         2: var
865; SUBST_DAG-NEXT:dag:2'2     ^~~
866; SUBST_DAG-NEXT:dag:2'3          with "VAR" equal to "var"
867; SUBST_DAG-NEXT:         3: END
868; SUBST_DAG-NEXT:check:3     ^~~
869; SUBST_DAG-NEXT:>>>>>>
870