diff options
| author | Joel E. Denny <jdenny.ornl@gmail.com> | 2018-12-18 00:01:39 +0000 |
|---|---|---|
| committer | Joel E. Denny <jdenny.ornl@gmail.com> | 2018-12-18 00:01:39 +0000 |
| commit | 3c5d267eb728556b8f25a145d3b006f9f5356589 (patch) | |
| tree | fc464ad8572cec841994fabd0eca79e70b59cad0 /llvm/test/FileCheck | |
| parent | f47c734e49da195cd5c0435119ed2a86cdfdb5b3 (diff) | |
| download | bcm5719-llvm-3c5d267eb728556b8f25a145d3b006f9f5356589.tar.gz bcm5719-llvm-3c5d267eb728556b8f25a145d3b006f9f5356589.zip | |
[FileCheck] Annotate input dump (1/7)
Extend FileCheck to dump its input annotated with FileCheck's
diagnostics: errors, good matches if -v, and additional information if
-vv. The goal is to make it easier to visualize FileCheck's matching
behavior when debugging.
Each patch in this series implements input annotations for a
particular category of FileCheck diagnostics. While the first few
patches alone are somewhat useful, the annotations become much more
useful as later patches implement annotations for -v and -vv
diagnostics, which show the matching behavior leading up to the error.
This first patch implements boilerplate plus input annotations for
error diagnostics reporting that no matches were found for a
directive. These annotations mark the search ranges of the failed
directives. Instead of using the usual `^~~`, which is used by later
patches for good matches, these annotations use `X~~` so that this
category of errors is visually distinct.
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 match result for a pattern of type T from line L of
the check file
- X~~ marks search range when no match is found
- colors error
If you are not seeing color above or in input dumps, try: -color
$ FileCheck -v -dump-input=always check1 < input1 |& sed -n '/^Input file/,$p'
Input file: <stdin>
Check file: check1
-dump-input=help describes the format of the following dump.
Full input was:
<<<<<<
1: ; abc def
2: ; ghI jkl
next:3 X~~~~~~~~ error: no match found
>>>>>>
$ cat check1
CHECK: abc
CHECK-SAME: def
CHECK-NEXT: ghi
CHECK-SAME: jkl
$ cat input1
; abc def
; ghI jkl
```
Some additional details related to the boilerplate:
* Enabling: The annotated input dump is enabled by `-dump-input`,
which can also be set via the `FILECHECK_OPTS` environment variable.
Accepted values are `help`, `always`, `fail`, or `never`. As shown
above, `help` describes the format of the dump. `always` is helpful
when you want to investigate a successful FileCheck run, perhaps for
an unexpected pass. `-dump-input-on-failure` and
`FILECHECK_DUMP_INPUT_ON_FAILURE` remain as a deprecated alias for
`-dump-input=fail`.
* Diagnostics: The usual diagnostics are not suppressed in this mode
and are printed first. For brevity in the example above, I've
omitted them using a sed command. Sometimes they're perfectly
sufficient, and then they make debugging quicker than if you were
forced to hunt through a dump of long input looking for the error.
If you think they'll get in the way sometimes, keep in mind that
it's pretty easy to grep for the start of the input dump, which is
`<<<`.
* Colored Annotations: The annotated input is colored if colors are
enabled (enabling colors can be forced using -color). For example,
errors are red. However, as in the above example, colors are not
vital to reading the annotations.
I don't know how to test color in the output, so any hints here would
be appreciated.
Reviewed By: george.karpenkov, zturner, probinson
Differential Revision: https://reviews.llvm.org/D52999
llvm-svn: 349418
Diffstat (limited to 'llvm/test/FileCheck')
| -rw-r--r-- | llvm/test/FileCheck/dump-input-annotations.txt | 241 | ||||
| -rw-r--r-- | llvm/test/FileCheck/dump-input-enable.txt | 126 | ||||
| -rw-r--r-- | llvm/test/FileCheck/no-check-file.txt | 3 | ||||
| -rw-r--r-- | llvm/test/FileCheck/verbose_mode.txt | 17 |
4 files changed, 370 insertions, 17 deletions
diff --git a/llvm/test/FileCheck/dump-input-annotations.txt b/llvm/test/FileCheck/dump-input-annotations.txt new file mode 100644 index 00000000000..1d6740622eb --- /dev/null +++ b/llvm/test/FileCheck/dump-input-annotations.txt @@ -0,0 +1,241 @@ +;-------------------------------------------------- +; Use -strict-whitespace to check marker alignment here. +; (Also check multiline marker where start/end columns vary across lines.) +; +; In the remaining checks, don't use -strict-whitespace and thus check just the +; presence, order, and lengths of markers. That way, if we ever change padding +; within line labels, we don't have to adjust so many tests. +;-------------------------------------------------- + +; RUN: echo 'hello world' > %t.in +; RUN: echo 'goodbye' >> %t.in +; RUN: echo 'world' >> %t.in + +; RUN: echo 'CHECK: hello' > %t.chk +; RUN: echo 'CHECK: universe' >> %t.chk + +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ +; RUN: | FileCheck -strict-whitespace -match-full-lines -check-prefix=ALIGN %s + +; ALIGN:Full input was: +; ALIGN-NEXT:<<<<<< +; ALIGN-NEXT: 1: hello world +; ALIGN-NEXT:check:2 X~~~~ +; ALIGN-NEXT: 2: goodbye +; ALIGN-NEXT:check:2 ~~~~~~~ +; ALIGN-NEXT: 3: world +; ALIGN-NEXT:check:2 ~~~~~ error: no match found +; ALIGN-NEXT:>>>>>> +; ALIGN-NOT:{{.}} + +;-------------------------------------------------- +; CHECK (also: multi-line search range) +;-------------------------------------------------- + +; Good match and no match. + +; RUN: echo 'hello' > %t.in +; RUN: echo 'again' >> %t.in +; RUN: echo 'whirled' >> %t.in + +; RUN: echo 'CHECK: hello' > %t.chk +; RUN: echo 'CHECK: world' >> %t.chk + +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefix=CHK +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V + +; CHK: <<<<<< +; CHK-NEXT: 1: hello +; CHK-NEXT: 2: again +; CHK-NEXT: check:2 X~~~~ +; CHK-NEXT: 3: whirled +; CHK-NEXT: check:2 ~~~~~~~ error: no match found +; CHK-NEXT: >>>>>> +; CHK-NOT: {{.}} + +;-------------------------------------------------- +; CHECK-COUNT-<num> +;-------------------------------------------------- + +; Good match and no match. + +; RUN: echo 'pete' > %t.in +; RUN: echo 'repete' >> %t.in +; RUN: echo 'repeat' >> %t.in + +; RUN: echo 'CHECK-COUNT-3: pete' > %t.chk + +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefix=CNT +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V + +; CNT: <<<<<< +; CNT-NEXT: 1: pete +; CNT-NEXT: 2: repete +; CNT-NEXT: 3: repeat +; CNT-NEXT: count:1 X~~~~~ error: no match found +; CNT-NEXT: >>>>>> +; CNT-NOT: {{.}} + +;-------------------------------------------------- +; CHECK-NEXT (also: EOF search-range) +;-------------------------------------------------- + +; Good match and no match. + +; RUN: echo 'hello' > %t.in +; RUN: echo 'again' >> %t.in + +; RUN: echo 'CHECK: hello' > %t.chk +; RUN: echo 'CHECK-NEXT: again' >> %t.chk +; RUN: echo 'CHECK-NEXT: world' >> %t.chk + +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefix=NXT +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V,NXT-VV + +; NXT: <<<<<< +; NXT-NEXT: 1: hello +; NXT-NEXT: 2: again +; NXT-NEXT: 3: +; NXT-NEXT: next:3 X error: no match found +; NXT-NEXT: >>>>>> +; NXT-NOT: {{.}} + +;-------------------------------------------------- +; CHECK-SAME (also: single-char search range) +;-------------------------------------------------- + +; Good match and no match. + +; RUN: echo 'hello world!' > %t.in + +; RUN: echo 'CHECK: hello' > %t.chk +; RUN: echo 'CHECK-SAME: world' >> %t.chk +; RUN: echo 'CHECK-SAME: again' >> %t.chk + +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefix=SAM +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V,SAM-VV + +; SAM: <<<<<< +; SAM-NEXT: 1: hello world! +; SAM-NEXT: same:3 X error: no match found +; SAM-NEXT: >>>>>> +; SAM-NOT: {{.}} + +;-------------------------------------------------- +; CHECK-EMPTY (also: search range ends at label) +;-------------------------------------------------- + +; Good match and no match. +; +; CHECK-EMPTY always seems to match an empty line at EOF (illegally when it's +; not the next line) unless either (1) the last line is non-empty and has no +; newline or (2) there's a CHECK-LABEL to end the search range before EOF. We +; choose scenario 2 to check the case of no match. + +; RUN: echo 'hello' > %t.in +; RUN: echo '' >> %t.in +; RUN: echo 'world' >> %t.in +; RUN: echo 'label' >> %t.in + +; RUN: echo 'CHECK: hello' > %t.chk +; RUN: echo 'CHECK-EMPTY:' >> %t.chk +; RUN: echo 'CHECK-EMPTY:' >> %t.chk +; RUN: echo 'CHECK-LABEL: label' >> %t.chk + +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V,EMP-VV + +; EMP: <<<<<< +; EMP-NEXT: 1: hello +; EMP-NEXT: 2: +; EMP-NEXT: 3: world +; EMP-NEXT: empty:3 X~~~~ +; EMP-NEXT: 4: label +; EMP-NEXT: empty:3 ~~~~~ error: no match found +; EMP-NEXT: >>>>>> +; EMP-NOT: {{.}} + +;-------------------------------------------------- +; CHECK-DAG +;-------------------------------------------------- + +; Good match, discarded match plus good match, and no match. + +; RUN: echo 'abc' > %t.in +; RUN: echo 'def' >> %t.in +; RUN: echo 'abc' >> %t.in + +; RUN: echo 'CHECK-DAG: def' > %t.chk +; RUN: echo 'CHECK-DAG: abc' >> %t.chk +; RUN: echo 'CHECK-DAG: abc' >> %t.chk +; RUN: echo 'CHECK-DAG: def' >> %t.chk + +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG + +; DAG: <<<<<< +; DAG-NEXT: 1: abc +; DAG-NEXT: 2: def +; DAG-NEXT: 3: abc +; DAG-NEXT: dag:4 X~~ error: no match found +; DAG-NEXT: >>>>>> +; DAG-NOT: {{.}} + +;-------------------------------------------------- +; CHECK-LABEL +;-------------------------------------------------- + +; Good match and no match. + +; RUN: echo 'lab0' > %t.in +; RUN: echo 'foo' >> %t.in +; RUN: echo 'lab1' >> %t.in +; RUN: echo 'bar' >> %t.in + +; RUN: echo 'CHECK-LABEL: lab0' > %t.chk +; RUN: echo 'CHECK: foo' >> %t.chk +; RUN: echo 'CHECK-LABEL: lab2' >> %t.chk + +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V +; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V,LAB-VV + +; LAB: <<<<<< +; LAB-NEXT: 1: lab0 +; LAB-NEXT: 2: foo +; LAB-NEXT: label:3 X~~ +; LAB-NEXT: 3: lab1 +; LAB-NEXT: label:3 ~~~~ +; LAB-NEXT: 4: bar +; LAB-NEXT: label:3 ~~~ error: no match found +; LAB-NEXT: >>>>>> +; LAB-NOT: {{.}} + + diff --git a/llvm/test/FileCheck/dump-input-enable.txt b/llvm/test/FileCheck/dump-input-enable.txt new file mode 100644 index 00000000000..cbc167ac079 --- /dev/null +++ b/llvm/test/FileCheck/dump-input-enable.txt @@ -0,0 +1,126 @@ +; 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: 2: world +; 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: <<<<<< diff --git a/llvm/test/FileCheck/no-check-file.txt b/llvm/test/FileCheck/no-check-file.txt new file mode 100644 index 00000000000..e9325d611af --- /dev/null +++ b/llvm/test/FileCheck/no-check-file.txt @@ -0,0 +1,3 @@ +; RUN: not FileCheck 2>&1 | FileCheck %s + +CHECK: <check-file> not specified diff --git a/llvm/test/FileCheck/verbose_mode.txt b/llvm/test/FileCheck/verbose_mode.txt deleted file mode 100644 index 2146d6a95c4..00000000000 --- a/llvm/test/FileCheck/verbose_mode.txt +++ /dev/null @@ -1,17 +0,0 @@ -; RUN: not FileCheck -input-file %s %s --check-prefix=CHECK1 --match-full-lines --dump-input-on-failure 2>&1 | FileCheck %s --check-prefix=CHECKERROR --match-full-lines -; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 not FileCheck -input-file %s %s --check-prefix=CHECK1 --match-full-lines 2>&1 | FileCheck %s --check-prefix=CHECKERROR --match-full-lines -; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 not FileCheck -input-file %s %s --check-prefix=CHECK1 --match-full-lines --dump-input-on-failure=0 2>&1 | FileCheck %s --check-prefix=CHECKERRORNOVERBOSE --match-full-lines - -hello -world - -; CHECK1: ciao -; CHECK1-NEXT: world - -; CHECKERROR: Full input was: -; CHECKERROR-NEXT: <<<<<< -; CHECKERROR: hello -; CHECKERROR: world -; CHECKERROR: >>>>>> - -; CHECKERRORNOVERBOSE-NOT: <<<<<< |

