llvm-project/llvm/test/FileCheck/check-not-custom-prefix.txt
Vinayak Dev 497a8604b3
[FileCheck]: Fix diagnostics for NOT prefixes (#78412)
Fixes #70221 

Fix a bug in FileCheck that corrects the error message when multiple
prefixes are provided
through --check-prefixes and one of them is a PREFIX-NOT.

Earlier, only the first of the provided prefixes was displayed as the
erroneous prefix, while the
actual error might be on the prefix that occurred at the end of the
prefix list in the input file.

Now, the right NOT prefix is shown in the error message.
2024-01-19 15:08:24 +00:00

70 lines
3.5 KiB
Plaintext

; Test two trailing NOT strings
; RUN: rm -f %t && \
; RUN: echo "LEADING: placeholder1" >>%t && echo "MIDDLE-NOT: placeholder2" >>%t && echo "TRAILING-NOT: placeholder3" >>%t && \
; RUN: %ProtectFileCheckOutput not FileCheck --strict-whitespace --check-prefixes LEADING,MIDDLE,TRAILING --dump-input=never --input-file %t %t 2>&1 | \
; RUN: FileCheck --check-prefix TEST1 %s
; Test NOT string occurring in between two allowable strings
; RUN: rm -f %t && \
; RUN: echo "LEADING: placeholder1" >>%t && echo "MIDDLE-NOT: placeholder2" >>%t && echo "TRAILING: placeholder3" >>%t && \
; RUN: %ProtectFileCheckOutput not FileCheck --strict-whitespace --check-prefixes LEADING,MIDDLE,TRAILING --dump-input=never --input-file %t %t 2>&1 | \
; RUN: FileCheck --check-prefix TEST2 %s
; Test first prefix found being the NOT string
; RUN: rm -f %t && \
; RUN: echo "LEADING-NOT: placeholder1" >>%t && echo "MIDDLE: placeholder2" >>%t && echo "TRAILING: placeholder3" >>%t && \
; RUN: %ProtectFileCheckOutput not FileCheck --strict-whitespace --check-prefixes LEADING,MIDDLE,TRAILING --dump-input=never --input-file %t %t 2>&1 | \
; RUN: FileCheck --check-prefix TEST3 %s
; Test all given prefixes being NOT strings
; RUN: rm -f %t && \
; RUN: echo "LEADING-NOT: placeholder1" >>%t && echo "MIDDLE-NOT: placeholder2" >>%t && echo "TRAILING-NOT: placeholder3" >>%t && \
; RUN: %ProtectFileCheckOutput not FileCheck --strict-whitespace --check-prefixes LEADING,MIDDLE,TRAILING --dump-input=never --input-file %t %t 2>&1 | \
; RUN: FileCheck --check-prefix TEST4 %s
; TEST1: error: MIDDLE-NOT: excluded string found in input
; TEST1-NEXT: MIDDLE-NOT: placeholder2
; TEST1-NEXT: {{^}} ^{{$}}
; TEST1-NEXT: note: found here
; TEST1-NEXT: MIDDLE-NOT: placeholder2
; TEST1-NEXT: {{^}} ^~~~~~~~~~~~{{$}}
; TEST1-NEXT: error: TRAILING-NOT: excluded string found in input
; TEST1-NEXT: TRAILING-NOT: placeholder3
; TEST1-NEXT: {{^}} ^{{$}}
; TEST1-NEXT: note: found here
; TEST1-NEXT: TRAILING-NOT: placeholder3
; TEST1-NEXT: {{^}} ^~~~~~~~~~~~{{$}}
; TEST2: error: MIDDLE-NOT: excluded string found in input
; TEST2-NEXT: MIDDLE-NOT: placeholder2
; TEST2-NEXT: {{^}} ^{{$}}
; TEST2-NEXT: note: found here
; TEST2-NEXT: MIDDLE-NOT: placeholder2
; TEST2-NEXT: {{^}} ^~~~~~~~~~~~{{$}}
; TEST3: error: LEADING-NOT: excluded string found in input
; TEST3-NEXT: LEADING-NOT: placeholder1
; TEST3-NEXT: {{^}} ^{{$}}
; TEST3-NEXT: note: found here
; TEST3-NEXT: LEADING-NOT: placeholder1
; TEST3-NEXT: {{^}} ^~~~~~~~~~~~{{$}}
; TEST4: error: LEADING-NOT: excluded string found in input
; TEST4-NEXT: LEADING-NOT: placeholder1
; TEST4-NEXT: {{^}} ^{{$}}
; TEST4-NEXT: note: found here
; TEST4-NEXT: LEADING-NOT: placeholder1
; TEST4-NEXT: {{^}} ^~~~~~~~~~~~{{$}}
; TEST4-NEXT: error: MIDDLE-NOT: excluded string found in input
; TEST4-NEXT: MIDDLE-NOT: placeholder2
; TEST4-NEXT: {{^}} ^{{$}}
; TEST4-NEXT: note: found here
; TEST4-NEXT: MIDDLE-NOT: placeholder2
; TEST4-NEXT: {{^}} ^~~~~~~~~~~~{{$}}
; TEST4-NEXT: error: TRAILING-NOT: excluded string found in input
; TEST4-NEXT: TRAILING-NOT: placeholder3
; TEST4-NEXT: {{^}} ^{{$}}
; TEST4-NEXT: note: found here
; TEST4-NEXT: TRAILING-NOT: placeholder3
; TEST4-NEXT: {{^}} ^~~~~~~~~~~~{{$}}