Skip to content

Commit

Permalink
Use non-greedy match when matching for CHECK: lines
Browse files Browse the repository at this point in the history
This implements some part of the #145.
  • Loading branch information
stanislaw committed Jun 6, 2020
1 parent d866cd3 commit 38b79b3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions filecheck/FileCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ def main():
# CHECK and CHECK-NEXT
strict_whitespace_match = "" if args.strict_whitespace and args.match_full_lines else " *"

check_regex = ".*({}):{}(.*)".format(check_prefix, strict_whitespace_match)
check_regex = ".*?({}):{}(.*)".format(check_prefix, strict_whitespace_match)
check_match = re.search(check_regex, line)
check_type = CheckType.CHECK
if not check_match:
check_regex = ".*({}-NEXT):{}(.*)".format(check_prefix, strict_whitespace_match)
check_regex = ".*?({}-NEXT):{}(.*)".format(check_prefix, strict_whitespace_match)
check_match = re.search(check_regex, line)
check_type = CheckType.CHECK_NEXT

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; CHECK:{{^.*filecheck.check:1:(9|10): error: CHECK: expected string not found in input$}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A-very-long-path/filecheck.check:1:9: error: CHECK: expected string not found in input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; RUN: %cat "%S/filecheck.input" | %expect_exit 0 --expect-no-content %FILECHECK_EXEC "%S/filecheck.check"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; CHECK: hello1
; CHECK: foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello1
hello2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" | %FILECHECK_TESTER_EXEC "%s" --match-full-lines

; CHECK: {{.*filecheck.check:2:10: error: CHECK: expected string not found in input$}}
; CHECK: {{^}}; CHECK: foo{{$}}
; CHECK: {{^}} ^{{$}}
; CHECK: {{^<stdin>:.*:.*: note: scanning from here$}}
; CHECK: hello2
; CHECK: ^{{$}}
; CHECK: {{^<stdin>:.*:.*: note: possible intended match here$}}
; CHECK: hello2
; CHECK: ^
; CHECK-EMPTY:

0 comments on commit 38b79b3

Please sign in to comment.