mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-20 07:34:25 -04:00
583ccd4384
Prior to this change, there was no clean way of getting FileCheck to
check that a line is completely empty. The expected way of using
"CHECK: {{^$}}" does not work because the '^' matches the end of the
previous match (this behaviour may be desirable in certain instances).
For the same reason, "CHECK-NEXT: {{^$}}" will fail when the previous
match was at the end of the line, as the pattern will match there.
Using the recommended [[:space:]] to match an explicit new line could
also match a space, and thus is not always desired. Literal '\n'
matches also do not work. A workaround was suggested in the review, but
it is a little clunky.
This change adds a new directive that behaves the same as CHECK-NEXT,
except that it only matches against empty lines (nothing, not even
whitespace, is allowed). As with CHECK-NEXT, it will fail if more than
one newline occurs before the next blank line. Example usage:
; test.txt
foo
bar
; CHECK: foo
; CHECK-EMPTY:
; CHECK-NEXT: bar
Differential Revision: https://reviews.llvm.org/D28896
Reviewed by: probinson
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335613 91177308-0d34-0410-b5e6-96231b3b80d8
45 lines
1.7 KiB
Plaintext
45 lines
1.7 KiB
Plaintext
; basic functionality
|
|
; RUN: FileCheck %s --input-file %s --check-prefix=CHECK1
|
|
foo
|
|
|
|
bar
|
|
CHECK1: foo
|
|
CHECK1-EMPTY:
|
|
CHECK1-NEXT: bar
|
|
|
|
; next line must be blank
|
|
; RUN: not FileCheck %s --input-file %s --check-prefix=CHECK2A 2>&1 | FileCheck %s --check-prefix=CHECK2B
|
|
badger
|
|
CHECK2A: badger
|
|
CHECK2A-EMPTY:
|
|
CHECK2B: CHECK2A-EMPTY: is not on the line after the previous match
|
|
|
|
; CHECK-EMPTY must have empty pattern
|
|
; RUN: not FileCheck %s --input-file %s --check-prefix=CHECK3A 2>&1 | FileCheck %s --check-prefix=CHECK3B
|
|
CHECK3A: foo
|
|
CHECK3A-EMPTY: this is not empty
|
|
CHECK3B: found non-empty check string for empty check with prefix 'CHECK3A:'
|
|
|
|
; CHECK-EMPTY cannot be the first check
|
|
; RUN: not FileCheck %s --input-file %s --check-prefix=CHECK4A 2>&1 | FileCheck %s --check-prefix=CHECK4B
|
|
CHECK4A-EMPTY:
|
|
CHECK4B: found 'CHECK4A-EMPTY' without previous 'CHECK4A: line
|
|
|
|
; CHECK-EMPTY-NOT and CHECK-NOT-EMPTY rejected
|
|
; RUN: not FileCheck %s --input-file %s --check-prefixes=CHECK5A 2>&1 | FileCheck %s --check-prefix=CHECK5C
|
|
; RUN: not FileCheck %s --input-file %s --check-prefixes=CHECK5B 2>&1 | FileCheck %s --check-prefix=CHECK5C
|
|
CHECK5A-EMPTY-NOT:
|
|
CHECK5B-NOT-EMPTY:
|
|
CHECK5C: unsupported -NOT combo on prefix 'CHECK5{{A|B}}'
|
|
|
|
; whitespace does not count as empty
|
|
; RUN: not FileCheck %s --input-file %s --check-prefix=CHECK6A --match-full-lines 2>&1 | FileCheck %s --check-prefix=CHECK6B
|
|
CHECK6A: the next line has spaces
|
|
CHECK6A-EMPTY:
|
|
CHECK6B: expected string not found in input
|
|
|
|
; ***don't add any further blank lines after this point***
|
|
; CHECK-EMPTY, like CHECK-NEXT, will report an error if the first matching
|
|
; line is not the line immediately following the previous check.
|
|
the next line has spaces
|
|
|