Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions filecheck/FileCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def exit_handler(code):
line = canonicalize_whitespace(line)

# CHECK and CHECK-NEXT
strict_whitespace_match = "" if args.strict_whitespace and args.match_full_lines else " *"
strict_whitespace_match = "" if strict_mode else " *"

check_regex = "{}({}):{}(.*)".format(before_prefix, check_prefix, strict_whitespace_match)
check_match = re.search(check_regex, line)
Expand All @@ -296,7 +296,7 @@ def exit_handler(code):
if check_match:
check_keyword = check_match.group(2)
check_expression = check_match.group(3)
if not (args.strict_whitespace and args.match_full_lines):
if not strict_mode:
check_expression = check_expression.strip(' ')

match_type = MatchType.SUBSTRING
Expand All @@ -306,6 +306,11 @@ def exit_handler(code):
regex_line = re.sub(r"\{\{(.*?)\}\}", r"\1", regex_line)
match_type = MatchType.REGEX
check_expression = regex_line
if strict_mode:
if check_expression[0] != "^":
check_expression = "^" + check_expression
if check_expression[-1] != "$":
check_expression = check_expression + "$"

check = Check(check_type=check_type,
match_type=match_type,
Expand All @@ -325,7 +330,7 @@ def exit_handler(code):

check_keyword = check_match.group(2)
check_expression = check_match.group(3)
if not (args.strict_whitespace and args.match_full_lines):
if not strict_mode:
check_expression = check_expression.strip(' ')

if re.search(r"\{\{.*\}\}", check_expression):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHECK:Substring2{{.*}}Substring3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Substring1 Substring2 Substring3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --match-full-lines --strict-whitespace
CHECK:{{.*}}filecheck.check:1:7: error: CHECK: expected string not found in input
CHECK:CHECK:Substring2{{.*}}Substring3
CHECK: ^
CHECK:<stdin>:1:1: note: scanning from here
CHECK:Substring1 Substring2 Substring3
CHECK:^
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHECK:Substring1{{.*}}Substring2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Substring1 Substring2 Substring3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --match-full-lines --strict-whitespace
CHECK:{{.*}}filecheck.check:1:7: error: CHECK: expected string not found in input
CHECK:CHECK:Substring1{{.*}}Substring2
CHECK: ^
CHECK:<stdin>:1:1: note: scanning from here
CHECK:Substring1 Substring2 Substring3
CHECK:^