Files
llvm/test/FileCheck/dump-input-enable.txt
T
Joel E. Denny cf38e31d99 [FileCheck] Annotate input dump (5/7)
This patch implements input annotations for diagnostics enabled by -v,
which report good matches for directives.  These annotations mark
match ranges using `^~~`.

For example:

```
$ FileCheck -dump-input=help
The following description was requested by -dump-input=help to
explain the input annotations printed by -dump-input=always and
-dump-input=fail:

  - L:     labels line number L of the input file
  - T:L    labels the only match result for a pattern of type T from line L of
           the check file
  - T:L'N  labels the Nth match result for a pattern of type T from line L of
           the check file
  - ^~~    marks good match (reported if -v)
  - !~~    marks bad match, such as:
           - CHECK-NEXT on same line as previous match (error)
           - CHECK-NOT found (error)
  - X~~    marks search range when no match is found, such as:
           - CHECK-NEXT not found (error)
  - ?      marks fuzzy match when no match is found
  - colors success, error, fuzzy match, unmatched input

If you are not seeing color above or in input dumps, try: -color

$ FileCheck -v -dump-input=always check3 < input3 |& sed -n '/^<<<</,$p'
<<<<<<
         1: abc foobar def
check:1     ^~~
not:2           !~~~~~     error: no match expected
check:3                ^~~
>>>>>>

$ cat check3
CHECK:     abc
CHECK-NOT: foobar
CHECK:     def

$ cat input3
abc foobar def
```

-vv enables these annotations for FileCheck's implicit EOF patterns as
well.  For an example where EOF patterns become relevant, see patch 7
in this series.

If colors are enabled, `^~~` is green to suggest success.

-v plus color enables highlighting of input text that has no final
match for any expected pattern.  The highlight uses a cyan background
to suggest a cold section.  This highlighting can make it easier to
spot text that was intended to be matched but that failed to be
matched in a long series of good matches.

CHECK-COUNT-<num> good matches are another case where there can be
multiple match results for the same directive.

Reviewed By: george.karpenkov, probinson

Differential Revision: https://reviews.llvm.org/D53897

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349422 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-18 00:03:03 +00:00

129 lines
4.7 KiB
Plaintext

; RUN: echo ciao > %t.good
; RUN: echo world >> %t.good
; RUN: echo hello > %t.err
; RUN: echo world >> %t.err
; RUN: echo 'CHECK: ciao' > %t.check
; RUN: echo 'CHECK-NEXT: world' >> %t.check
;--------------------------------------------------
; unknown value
;--------------------------------------------------
; RUN: not FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=foobar 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=BADVAL
; No positional arg.
; RUN: not FileCheck -dump-input=foobar 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=BADVAL
BADVAL: FileCheck: for the -dump-input option: Cannot find option named 'foobar'!
;--------------------------------------------------
; help
;--------------------------------------------------
; Appended to normal command line.
; RUN: FileCheck -input-file %t.err -color %t.check -dump-input=help \
; RUN: | FileCheck %s -check-prefix=HELP
; No positional arg.
; RUN: FileCheck -dump-input=help | FileCheck %s -check-prefix=HELP
HELP-NOT: {{.}}
HELP: The following description was requested by -dump-input=help
HELP: try{{.*}}-color
HELP-NOT: {{.}}
;--------------------------------------------------
; never
;--------------------------------------------------
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=never 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=never 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP
;--------------------------------------------------
; default: never
;--------------------------------------------------
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP
;--------------------------------------------------
; fail
;--------------------------------------------------
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=fail 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=fail 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR
;--------------------------------------------------
; -dump-input-on-failure
;--------------------------------------------------
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input-on-failure 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input-on-failure 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR
; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 \
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty
; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 \
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR
;--------------------------------------------------
; always
;--------------------------------------------------
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=always -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-GOOD
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=always 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR
; END.
; CHECK-GOOD: Full input was:
; CHECK-GOOD-NEXT: <<<<<<
; CHECK-GOOD-NEXT: 1: ciao
; CHECK-GOOD-NEXT: check:1 ^~~~
; CHECK-GOOD-NEXT: 2: world
; CHECK-GOOD-NEXT: next:2 ^~~~~
; CHECK-GOOD-NEXT: >>>>>>
; CHECK-ERR: Full input was:
; CHECK-ERR-NEXT: <<<<<<
; CHECK-ERR-NEXT: 1: hello
; CHECK-ERR-NEXT: check:1 X~~~~
; CHECK-ERR-NEXT: 2: world
; CHECK-ERR-NEXT: check:1 ~~~~~ error: no match found
; CHECK-ERR-NEXT: >>>>>>
; CHECK-NODUMP-NOT: <<<<<<