Skip to content
Permalink
Browse files

[FileCheck]] Canonicalize caret location testing

Summary:
Testing of caret location in diagnostic message is currently made with
CHECK directive with the following general format:
CHECK: {{^         \^$}}

James Henderson suggested the following would be more readable:
CHECK: {{^}}         ^{{$}}

and when whole lines can be matched (as is the case for command-line
testing where error messages do not include path):
CHECK:         ^
using the option --match-full-lines.

This commit implements these 2 changes on all existing caret position
tests. It also aligns the caret to the character it is trying to match
in the above line.

Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk

Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya

Tags: #llvm

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

> llvm-svn: 366861

llvm-svn: 366898
  • Loading branch information...
Thomas Preud'homme
Thomas Preud'homme committed Jul 24, 2019
1 parent 4cd9b85 commit a83dfd92bef4ffdc08765a20dffa1e29d194d618
@@ -1,10 +1,11 @@
; RUN: not FileCheck -input-file %s %s 2>&1 | FileCheck -check-prefix DIAG %s
; RUN: not FileCheck --input-file %s %s 2>&1 \
; RUN: | FileCheck --strict-whitespace --check-prefix DIAG %s

CHECK-NOT: test

DIAG: error: CHECK-NOT: excluded string found in input
DIAG-NEXT: CHECK-NOT: test
DIAG-NEXT: {{^ \^}}
DIAG-NEXT: note: found here
DIAG-NEXT: CHECK-NOT: test
DIAG-NEXT: {{^ \^}}
DIAG: error: CHECK-NOT: excluded string found in input
DIAG-NEXT: CHECK-NOT: test
DIAG-NEXT: {{^}} ^{{$}}
DIAG-NEXT: note: found here
DIAG-NEXT: CHECK-NOT: test
DIAG-NEXT: {{^}} ^~~~{{$}}
@@ -2,24 +2,24 @@

; Invalid variable name: starts with a digit.
RUN: not FileCheck -D#10VALUE=10 --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix NUMERRCLIFMT
RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix NUMERRCLIFMT

NUMERRCLIFMT: Global defines:1:46: error: invalid variable name
NUMERRCLIFMT-NEXT: Global define #1: #10VALUE=10 (parsed as: {{\[\[#10VALUE:10\]\]}})
NUMERRCLIFMT-NEXT: {{^ \^$}}
NUMERRCLIFMT:Global defines:1:46: error: invalid variable name
NUMERRCLIFMT-NEXT:Global define #1: #10VALUE=10 (parsed as: {{\[\[#10VALUE:10\]\]}})
NUMERRCLIFMT-NEXT: ^

; Invalid definition of pseudo variable.
RUN: not FileCheck -D#@VALUE=10 --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix NUMERRCLIPSEUDO
RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix NUMERRCLIPSEUDO

NUMERRCLIPSEUDO: Global defines:1:45: error: definition of pseudo numeric variable unsupported
NUMERRCLIPSEUDO-NEXT: Global define #1: #@VALUE=10 (parsed as: {{\[\[#@VALUE:10\]\]}})
NUMERRCLIPSEUDO-NEXT: {{^ \^$}}
NUMERRCLIPSEUDO:Global defines:1:45: error: definition of pseudo numeric variable unsupported
NUMERRCLIPSEUDO-NEXT:Global define #1: #@VALUE=10 (parsed as: {{\[\[#@VALUE:10\]\]}})
NUMERRCLIPSEUDO-NEXT: ^

; Invalid definition of an expression.
RUN: not FileCheck -D#VALUE+2=10 --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix NUMERRCLITRAIL
RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix NUMERRCLITRAIL

NUMERRCLITRAIL: Global defines:1:51: error: unexpected characters after numeric variable name
NUMERRCLITRAIL-NEXT: Global define #1: #VALUE+2=10 (parsed as: {{\[\[#VALUE\+2:10\]\]}})
NUMERRCLITRAIL-NEXT: {{^ \^$}}
NUMERRCLITRAIL:Global defines:1:51: error: unexpected characters after numeric variable name
NUMERRCLITRAIL-NEXT:Global define #1: #VALUE+2=10 (parsed as: {{\[\[#VALUE\+2:10\]\]}})
NUMERRCLITRAIL-NEXT: ^
@@ -105,14 +105,14 @@ UNDEFVAR: 11
UNDEF-USE-LABEL: UNDEF VAR USE
UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR1+UNDEFVAR2]]
UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:17: error: {{U}}NDEF-USE-NEXT: expected string not found in input
UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR1\+UNDEFVAR2\]\]}}
UNDEF-USE-MSG-NEXT: {{^ \^$}}
UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here
UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
UNDEF-USE-MSG-NEXT: {{^\^$}}
UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable(s): "UNDEFVAR1" "UNDEFVAR2"
UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
UNDEF-USE-MSG-NEXT: {{^\^$}}
UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR1\+UNDEFVAR2\]\]}}
UNDEF-USE-MSG-NEXT: {{^}} ^{{$}}
UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here
UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
UNDEF-USE-MSG-NEXT: {{^}}^{{$}}
UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable(s): "UNDEFVAR1" "UNDEFVAR2"
UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
UNDEF-USE-MSG-NEXT: {{^}}^{{$}}

; Numeric expression with unsupported operator.
RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP --input-file %s %s 2>&1 \
@@ -124,7 +124,7 @@ INVAL-OP-LABEL: INVALID OPERATOR
INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]]
INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*'
INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}}
INVAL-OP-MSG-NEXT: {{^ \^$}}
INVAL-OP-MSG-NEXT: {{^}} ^{{$}}

; Name conflict between Numeric variable definition and string variable
; definition whether from the command-line or input text.
@@ -152,16 +152,16 @@ CONFLICT3: [[STRVAR:foo.*]]
CONFLICT4: redef2 [[#STRVAR:]]
INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists
INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}}
INPUT-STR-CONFLICT-NEXT: {{^ \^$}}
INPUT-STR-CONFLICT-NEXT: {{^}} ^{{$}}
CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists
CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar
CLI-STR-CONFLICT-NEXT: {{^ \^$}}
CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar
CLI-STR-CONFLICT-NEXT: {{^}} ^{{$}}
INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists
INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}}
INPUT-NUM-CONFLICT-NEXT: {{^ \^$}}
INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}}
INPUT-NUM-CONFLICT-NEXT: {{^}} ^{{$}}
CLI-NUM-CONFLICT: Global defines:2:45: error: string variable with name 'STRVAR' already exists
CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42 (parsed as: {{\[\[#STRVAR:42\]\]}})
CLI-NUM-CONFLICT-NEXT: {{^ \^$}}
CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42 (parsed as: {{\[\[#STRVAR:42\]\]}})
CLI-NUM-CONFLICT-NEXT: {{^}} ^{{$}}

; Numeric variable definition with too big value.
RUN: not FileCheck --check-prefix BIGVAL --input-file %s %s 2>&1 \
@@ -172,8 +172,8 @@ NUMVAR: 10000000000000000000000
BIGVAL-LABEL: BIG VALUE
BIGVAL-NEXT: NUMVAR: [[#NUMVAR:]]
BIGVAL-MSG: numeric-expression.txt:[[#@LINE-3]]:9: error: Unable to represent numeric value
BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000
BIGVAL-MSG-NEXT: {{^ \^$}}
BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000
BIGVAL-MSG-NEXT: {{^}} ^{{$}}

; Verify that when a variable is set to an expression the expression is still
; checked.
@@ -188,4 +188,4 @@ DEF-EXPR-FAIL-NEXT: [[# VAR20:]]
DEF-EXPR-FAIL-NEXT: [[# VAR42: VAR20+22]]
DEF-EXPR-FAIL-MSG: numeric-expression.txt:[[#@LINE-1]]:21: error: {{D}}EF-EXPR-FAIL-NEXT: is not on the line after the previous match
DEF-EXPR-FAIL-MSG-NEXT: {{D}}EF-EXPR-FAIL-NEXT: {{\[\[# VAR42: VAR20\+22\]\]}}
DEF-EXPR-FAIL-MSG-NEXT: {{^ \^$}}
DEF-EXPR-FAIL-MSG-NEXT: {{^}} ^{{$}}
@@ -26,24 +26,24 @@ ERRCLIVAR2: Missing variable name in command-line definition '-D='

; Invalid variable name: starts with a digit.
RUN: not FileCheck -D10VALUE=10 --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix ERRCLIFMT
RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix ERRCLIFMT

ERRCLIFMT: Global defines:1:19: error: invalid variable name
ERRCLIFMT-NEXT: Global define #1: 10VALUE=10
ERRCLIFMT-NEXT: {{^ \^$}}
ERRCLIFMT:Global defines:1:19: error: invalid variable name
ERRCLIFMT-NEXT:Global define #1: 10VALUE=10
ERRCLIFMT-NEXT: ^

; Invalid definition of pseudo variable.
RUN: not FileCheck -D@VALUE=10 --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix ERRCLIPSEUDO
RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix ERRCLIPSEUDO

ERRCLIPSEUDO: Global defines:1:19: error: invalid name in string variable definition '@VALUE'
ERRCLIPSEUDO-NEXT: Global define #1: @VALUE=10
ERRCLIPSEUDO-NEXT: {{^ \^$}}
ERRCLIPSEUDO:Global defines:1:19: error: invalid name in string variable definition '@VALUE'
ERRCLIPSEUDO-NEXT:Global define #1: @VALUE=10
ERRCLIPSEUDO-NEXT: ^

; Invalid definition of an expression.
RUN: not FileCheck -D'VALUE + 2=10' --input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace --check-prefix ERRCLITRAIL

ERRCLITRAIL: Global defines:1:19: error: invalid name in string variable definition 'VALUE + 2'
ERRCLITRAIL-NEXT: Global define #1: VALUE + 2=10
ERRCLITRAIL-NEXT: {{^ \^$}}
ERRCLITRAIL:Global defines:1:19: error: invalid name in string variable definition 'VALUE + 2'
ERRCLITRAIL-NEXT:Global define #1: VALUE + 2=10
ERRCLITRAIL-NEXT: ^
@@ -9,22 +9,22 @@ CHECK-NOT: raboof
CHECK-NEXT: bar

V: verbose.txt:[[@LINE-4]]:8: remark: {{C}}HECK: expected string found in input
V-NEXT: {{C}}HECK: foo{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: {{C}}HECK: foo{{$}}
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[@LINE-9]]:1: note: found here
V-NEXT: {{^}}foo{{$}}
V-NEXT: {{^}}^~~{{$}}

V-NEXT: verbose.txt:[[@LINE-9]]:13: remark: {{C}}HECK-NEXT: expected string found in input
V-NEXT: {{C}}HECK-NEXT: bar{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: {{C}}HECK-NEXT: bar{{$}}
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[@LINE-15]]:1: note: found here
V-NEXT: {{^}}bar{{$}}
V-NEXT: {{^}}^~~{{$}}

VV-NEXT: verbose.txt:[[@LINE-17]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
VV-NEXT: {{C}}HECK-NOT: raboof{{$}}
VV-NEXT: {{^ \^$}}
VV-NEXT: {{C}}HECK-NOT: raboof{{$}}
VV-NEXT: {{^}} ^{{$}}
VV-NEXT: verbose.txt:[[@LINE-22]]:1: note: scanning from here
VV-NEXT: {{^}}bar{{$}}
VV-NEXT: {{^}}^{{$}}
@@ -37,14 +37,14 @@ CHECK-NEXT: NUMVAR - 1:[[#NUMVAR - 1]]

V: verbose.txt:[[#@LINE-4]]:8: remark: {{C}}HECK: expected string found in input
V-NEXT: {{C}}HECK: {{NUMVAR=[[][[]#NUMVAR:[]][]]$}}
V-NEXT: {{^ \^$}}
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[#@LINE-9]]:1: note: found here
V-NEXT: {{^}}NUMVAR=42{{$}}
V-NEXT: {{^}}^~~~~~~~~{{$}}

V-NEXT: verbose.txt:[[#@LINE-9]]:13: remark: {{C}}HECK-NEXT: expected string found in input
V-NEXT: {{C}}HECK-NEXT: {{NUMVAR - 1:[[][[]#NUMVAR - 1[]][]]$}}
V-NEXT: {{^ \^$}}
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[#@LINE-15]]:1: note: found here
V-NEXT: {{^}}NUMVAR - 1:41{{$}}
V-NEXT: {{^}}^~~~~~~~~~~~~{{$}}
@@ -54,7 +54,7 @@ V-NEXT: {{^}}^~~~~~~~~~~~~{{$}}

VV-NEXT: verbose.txt:[[#@LINE-20]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
VV-NEXT: {{C}}HECK-NOT: {{[[][[]#NUMVAR [+] 1[]][]]$}}
VV-NEXT: {{^ \^$}}
VV-NEXT: {{^}} ^{{$}}
VV-NEXT: verbose.txt:[[#@LINE-25]]:1: note: scanning from here
VV-NEXT: {{^}}NUMVAR - 1:41{{$}}
VV-NEXT: {{^}}^{{$}}
@@ -67,22 +67,22 @@ CHECK-EMPTY:
CHECK-NEXT: after empty

V: verbose.txt:[[@LINE-4]]:8: remark: {{C}}HECK: expected string found in input
V-NEXT: {{C}}HECK: before empty{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: {{C}}HECK: before empty{{$}}
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[@LINE-10]]:1: note: found here
V-NEXT: {{^}}before empty{{$}}
V-NEXT: {{^}}^~~~~~~~~~~~{{$}}

V-NEXT: verbose.txt:[[@LINE-10]]:13: remark: {{C}}HECK-EMPTY: expected string found in input
V-NEXT: {{C}}HECK-EMPTY:{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: {{C}}HECK-EMPTY:{{$}}
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[@LINE-16]]:1: note: found here
V-EMPTY:
V-NEXT: {{^}}^{{$}}

V-NEXT: verbose.txt:[[@LINE-16]]:13: remark: {{C}}HECK-NEXT: expected string found in input
V-NEXT: {{C}}HECK-NEXT: after empty{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: {{C}}HECK-NEXT: after empty{{$}}
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[@LINE-22]]:1: note: found here
V-NEXT: {{^}}after empty{{$}}
V-NEXT: {{^}}^~~~~~~~~~~{{$}}
@@ -93,53 +93,53 @@ CHECK-DAG: abcdef
CHECK-DAG: def

V-NEXT: verbose.txt:[[@LINE-3]]:12: remark: {{C}}HECK-DAG: expected string found in input
V-NEXT: {{C}}HECK-DAG: abcdef
V-NEXT: {{^ \^$}}
V-NEXT: {{C}}HECK-DAG: abcdef
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[@LINE-8]]:1: note: found here
V-NEXT: {{^}}abcdef{{$}}
V-NEXT: {{^}}^~~~~~{{$}}

VV-NEXT: verbose.txt:[[@LINE-9]]:12: remark: {{C}}HECK-DAG: expected string found in input
VV-NEXT: {{C}}HECK-DAG: def
VV-NEXT: {{^ \^$}}
VV-NEXT: {{C}}HECK-DAG: def
VV-NEXT: {{^}} ^{{$}}
VV-NEXT: verbose.txt:[[@LINE-15]]:4: note: found here
VV-NEXT: {{^abcdef$}}
VV-NEXT: {{^ \^~~$}}
VV-NEXT: {{^abcdef$}}
VV-NEXT: {{^}} ^~~
VV-NEXT: verbose.txt:[[@LINE-18]]:1: note: match discarded, overlaps earlier DAG match here
VV-NEXT: {{^}}abcdef{{$}}
VV-NEXT: {{^}}^~~~~~{{$}}

V-NEXT: verbose.txt:[[@LINE-19]]:12: remark: {{C}}HECK-DAG: expected string found in input
V-NEXT: {{C}}HECK-DAG: def
V-NEXT: {{^ \^$}}
V-NEXT: {{C}}HECK-DAG: def
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[@LINE-24]]:4: note: found here
V-NEXT: {{^abcdef$}}
V-NEXT: {{^ \^~~$}}
V-NEXT: {{^abcdef$}}
V-NEXT: {{^}} ^~~

xyz
CHECK: xyz
CHECK-NOT: {{z}}yx

V: verbose.txt:[[@LINE-3]]:8: remark: {{C}}HECK: expected string found in input
V-NEXT: {{C}}HECK: xyz{{$}}
V-NEXT: {{^ \^$}}
V-NEXT: {{C}}HECK: xyz{{$}}
V-NEXT: {{^}} ^{{$}}
V-NEXT: verbose.txt:[[@LINE-7]]:1: note: found here
V-NEXT: {{^}}xyz{{$}}
V-NEXT: {{^}}^~~{{$}}

VV-NEXT: verbose.txt:[[@LINE-9]]:19: remark: implicit EOF: expected string found in input
VV-NEXT: {{C}}HECK-NOT: {{[{][{]z[}][}]yx$}}
VV-NEXT: {{^ \^$}}
VV-NEXT: {{^}} ^{{$}}
VV-NEXT: verbose.txt:[[@LINE+13]]:1: note: found here
VV-NOT: {{.}}
VV: {{^\^$}}
VV: {{^}}^

VV-NEXT: verbose.txt:[[@LINE-16]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
VV-NEXT: {{C}}HECK-NOT: {{[{][{]z[}][}]yx$}}
VV-NEXT: {{^ \^$}}
VV-NEXT: {{^}} ^{{$}}
VV-NEXT: verbose.txt:[[@LINE-20]]:1: note: scanning from here
VV-NEXT: {{^C}}HECK: xyz{{$}}
VV-NEXT: {{^\^$}}
VV-NEXT: {{^}}^{{$}}

QUIET-NOT: {{.}}
V-NOT: {{.}}

0 comments on commit a83dfd9

Please sign in to comment.
You can’t perform that action at this time.