1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/FileCheck/dump-input-enable.txt
Joel E. Denny 82eeb7f9a7 [FileCheck] Implement -dump-input-context
This patch is motivated by discussions at each of:

* <https://reviews.llvm.org/D81422>
* <http://lists.llvm.org/pipermail/llvm-dev/2020-June/142369.html>

When input is dumped as specified by `-dump-input=fail`, this patch
filters the dump to show only input lines that are the starting lines
of error diagnostics plus the number of contextual lines specified
`-dump-input-context` (defaults to 5).

When `-dump-input=always`, there might be not be any errors, so all
input lines are printed, as without this patch.

Here's some sample output with `-dump-input-context=3 -vv`:

```
<<<<<<
           .
           .
           .
          13: foo
          14: foo
          15: hello world
check:1       ^~~~~~~~~~~
          16: foo
check:2'0     X~~ error: no match found
          17: foo
check:2'0     ~~~
          18: foo
check:2'0     ~~~
          19: foo
check:2'0     ~~~
           .
           .
           .
          27: foo
check:2'0     ~~~
          28: foo
check:2'0     ~~~
          29: foo
check:2'0     ~~~
          30: goodbye word
check:2'0     ~~~~~~~~~~~~
check:2'1     ?            possible intended match
          31: foo
check:2'0     ~~~
          32: foo
check:2'0     ~~~
          33: foo
check:2'0     ~~~
           .
           .
           .
>>>>>>
```

Reviewed By: mehdi_amini, arsenm, jhenderson, rsmith, SjoerdMeijer, Meinersbur, lattner

Differential Revision: https://reviews.llvm.org/D82203
2020-07-10 11:02:10 -04:00

254 lines
9.8 KiB
Plaintext

;--------------------------------------------------
; Create the check file, good input, and bad input.
;
; For both good and bad input, make sure the -v trace has at least one remark
; so we can check how trace suppression is affected by -dump-input.
;--------------------------------------------------
; RUN: echo hello > %t.good
; RUN: echo world >> %t.good
; RUN: echo hello > %t.err
; RUN: echo whirled >> %t.err
; RUN: echo 'CHECK: hello' > %t.check
; RUN: echo 'CHECK-NEXT: world' >> %t.check
;--------------------------------------------------
; Check -dump-input=<bad value>.
;--------------------------------------------------
; RUN: %ProtectFileCheckOutput \
; 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: %ProtectFileCheckOutput not FileCheck -dump-input=foobar 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefix=BADVAL
BADVAL: {{F|f}}ile{{C|c}}heck{{.*}}: for the --dump-input option: Cannot find option named 'foobar'!
;--------------------------------------------------
; Check -dump-input=help.
;--------------------------------------------------
; Appended to normal command line.
; RUN: %ProtectFileCheckOutput \
; RUN: FileCheck -input-file %t.err -color %t.check -dump-input=help \
; RUN: | FileCheck %s -check-prefix=HELP
; No positional arg.
; RUN: %ProtectFileCheckOutput FileCheck -dump-input=help \
; RUN: | FileCheck %s -check-prefix=HELP
;--------------------------------------------------
; Check -dump-input=never.
;
; Include the case without -v, which isn't covered elsewhere.
;--------------------------------------------------
; FileCheck success, no -v => no dump, no trace.
; RUN: %ProtectFileCheckOutput \
; 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 -allow-empty \
; RUN: -check-prefixes=NOTRACE,NODUMP
; FileCheck fail, no -v => no dump, no trace.
; RUN: %ProtectFileCheckOutput \
; 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-prefixes=NOTRACE,ERR,NODUMP
; FileCheck success, -v => no dump, trace.
; RUN: %ProtectFileCheckOutput \
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=never -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,NODUMP
; FileCheck fail, -v => no dump, trace.
; RUN: %ProtectFileCheckOutput \
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=never -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,ERR,NODUMP
;--------------------------------------------------
; Check no -dump-input, which defaults to fail.
;--------------------------------------------------
; FileCheck success, -v => no dump, no trace.
; RUN: %ProtectFileCheckOutput \
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines -allow-empty \
; RUN: -check-prefixes=NOTRACE,NODUMP
; FileCheck fail, -v => dump, no trace.
; RUN: %ProtectFileCheckOutput \
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines \
; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
;--------------------------------------------------
; Check -dump-input=fail.
;
; Include the case without -v, which isn't covered elsewhere.
;--------------------------------------------------
; FileCheck success, no -v => no dump, no trace.
; RUN: %ProtectFileCheckOutput \
; 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 -allow-empty \
; RUN: -check-prefixes=NOTRACE,NODUMP
; FileCheck fail, no -v => dump, no trace.
; RUN: %ProtectFileCheckOutput \
; 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-prefixes=NOTRACE,ERR,DUMP-ERR
; FileCheck success, -v => no dump, no trace.
; RUN: %ProtectFileCheckOutput \
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=fail -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines -allow-empty \
; RUN: -check-prefixes=NOTRACE,NODUMP
; FileCheck fail, -v => dump, no trace.
; RUN: %ProtectFileCheckOutput \
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=fail -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines \
; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
;--------------------------------------------------
; Check -dump-input=always.
;--------------------------------------------------
; FileCheck success, -v => dump, no trace.
; RUN: %ProtectFileCheckOutput \
; 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-prefixes=NOTRACE,DUMP-OK
; FileCheck fail, -v => dump, no trace.
; RUN: %ProtectFileCheckOutput \
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=always -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines \
; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
;--------------------------------------------------
; Check multiple -dump-input options.
;
; This occurs most commonly when a test author specifies -dump-input on a
; specific FileCheck call while a test runner specifies -dump-input in
; FILECHECK_OPTS, but check the behavior generally.
;
; "help" has precedence, and then the most verbose value wins. The most
; common combinations involve "fail" and "always", so test those the most.
;--------------------------------------------------
;- - - - - - - - - - - - - - - - - - - - - - - - -
; Check duplicate.
;- - - - - - - - - - - - - - - - - - - - - - - - -
; fail, fail => fail (FileCheck fail => dump)
; RUN: %ProtectFileCheckOutput \
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=fail -dump-input=fail -v \
; RUN: 2>&1 \
; RUN: | FileCheck %s -match-full-lines \
; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
;- - - - - - - - - - - - - - - - - - - - - - - - -
; Check precedence.
;- - - - - - - - - - - - - - - - - - - - - - - - -
; help, always => help
; RUN: %ProtectFileCheckOutput \
; RUN: FileCheck -input-file %t.err -color %t.check \
; RUN: -dump-input=help -dump-input=always \
; RUN: | FileCheck %s -check-prefix=HELP
; always, fail => always (FileCheck success => dump)
; RUN: %ProtectFileCheckOutput \
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=always -dump-input=fail \
; RUN: -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,DUMP-OK
; fail, never => fail (FileCheck fail => dump)
; RUN: %ProtectFileCheckOutput \
; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=fail -dump-input=never -v \
; RUN: 2>&1 \
; RUN: | FileCheck %s -match-full-lines \
; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V
;- - - - - - - - - - - - - - - - - - - - - - - - -
; Check that order doesn't matter.
;- - - - - - - - - - - - - - - - - - - - - - - - -
; fail, always => always (FileCheck success => dump)
; RUN: %ProtectFileCheckOutput \
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=fail -dump-input=always \
; RUN: -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,DUMP-OK
;- - - - - - - - - - - - - - - - - - - - - - - - -
; Check that FILECHECK_OPTS isn't handled differently.
;- - - - - - - - - - - - - - - - - - - - - - - - -
; always, fail => always (FileCheck success => dump)
; RUN: %ProtectFileCheckOutput FILECHECK_OPTS=-dump-input=always \
; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \
; RUN: -match-full-lines -dump-input=fail -v 2>&1 \
; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,DUMP-OK
; fail, always => always (FileCheck success => dump)
; RUN: %ProtectFileCheckOutput FILECHECK_OPTS=-dump-input=fail \
; 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-prefixes=NOTRACE,DUMP-OK
; END.
;--------------------------------------------------
; Check the output.
;--------------------------------------------------
; HELP-NOT: {{.}}
; HELP: The following description was requested by -dump-input=help
; HELP: - colors {{.*}}
; HELP-NOT: {{.}}
; Trace is sometimes suppressed.
; TRACE: {{.*}}remark:{{.*}}
; NOTRACE-NOT: remark:
; Error diagnostics are never suppressed.
; ERR: {{.*}}error:{{.*}}
; NODUMP-NOT: <<<<<<
; DUMP-OK: Input was:
; DUMP-OK-NEXT: <<<<<<
; DUMP-OK-NEXT: 1: hello
; DUMP-OK-NEXT: check:1 ^~~~~
; DUMP-OK-NEXT: 2: world
; DUMP-OK-NEXT: next:2 ^~~~~
; DUMP-OK-NEXT: >>>>>>
; DUMP-ERR: Input was:
; DUMP-ERR-NEXT: <<<<<<
; DUMP-ERR-NEXT: 1: hello
; DUMP-ERR-V-NEXT: check:1 ^~~~~
; DUMP-ERR-NEXT: 2: whirled
; DUMP-ERR-NEXT: next:2 X~~~~~~ error: no match found
; DUMP-ERR-NEXT: >>>>>>