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
9 changes: 7 additions & 2 deletions src/FileCheck
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ with open(check_file) as f:
match_type = MatchType.REGEX
check_expression = regex_line
else:
check_expression = re.sub("\\s+", ' ', check_expression).strip()
if not args.strict_whitespace:
check_expression = re.sub("\\s+", ' ', check_expression).strip()

check = Check(check_type=CheckType.CHECK_NOT,
match_type=match_type,
Expand Down Expand Up @@ -175,7 +176,8 @@ for line_idx, line in enumerate(sys.stdin):

elif current_check.check_type == CheckType.CHECK_NOT:
if current_check.match_type == MatchType.SUBSTRING:
line = re.sub("\\s+", ' ', line).strip()
if not args.strict_whitespace:
line = re.sub("\\s+", ' ', line).strip()

if current_check.expression in line:
break
Expand Down Expand Up @@ -243,6 +245,9 @@ if current_check.check_type == CheckType.CHECK_NOT:
if (current_check.match_type == MatchType.SUBSTRING or
current_check.match_type == MatchType.REGEX):
last_read_line = input_lines[-1]
if not args.strict_whitespace:
last_read_line = re.sub("\\s+", ' ', last_read_line).strip()

print("{}:{}:{}: error: CHECK-NOT: excluded string found in input"
.format(check_file,
current_check.check_line_idx + 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; CHECK-NOT: hello world hello world
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world hello world
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; RUN: cat %S/filecheck.input | (%FILECHECK_EXEC %S/filecheck.check 2>&1; test $? = 1) | %FILECHECK_TESTER_EXEC %s --strict-whitespace --match-full-lines -check-prefix=NO_OPTION
; RUN: cat %S/filecheck.input | (%FILECHECK_EXEC %S/filecheck.check --strict-whitespace 2>&1; test $? = 0) | %FILECHECK_TESTER_EXEC %s --match-full-lines -check-prefix=OPTION

; NO_OPTION:{{^.*}}FileCheck{{$}}
; NO_OPTION:{{^.*}}filecheck.check:1:14: error: CHECK-NOT: excluded string found in input{{$}}
; NO_OPTION:; CHECK-NOT: hello world hello world
; NO_OPTION: ^
; NO_OPTION:{{^<stdin>:.:.: note: found here$}}
; NO_OPTION:hello world hello world
; NO_OPTION:^~~~~~~~~~~~~~~~~~~~~~~
; NO_OPTION-EMPTY:

; OPTION: {{^.*}}FileCheck{{$}}
; OPTION-EMPTY:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; CHECK: hello world hello world
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world hello world
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; RUN: cat %S/filecheck.input | %FILECHECK_EXEC %S/filecheck.check | %FILECHECK_TESTER_EXEC %s --match-full-lines -check-prefix=NO_OPTION
; RUN: cat %S/filecheck.input | (%FILECHECK_EXEC %S/filecheck.check --strict-whitespace 2>&1; test $? = 1) | %FILECHECK_TESTER_EXEC %s --strict-whitespace --match-full-lines -check-prefix=OPTION

; NO_OPTION: {{^.*}}FileCheck{{$}}
; NO_OPTION-EMPTY:

; OPTION:{{^.*}}FileCheck{{$}}
; OPTION:{{^.*}}filecheck.check:1:10: error: CHECK: expected string not found in input{{$}}
; OPTION:; CHECK: hello world hello world
; OPTION: ^
; OPTION:{{^<stdin>:.*:.*: note: scanning from here$}}
; OPTION:hello world hello world
; OPTION:^
; TODO: error: OPTION-EMPTY is not on the line after the previous match
; OPTION-EMPTY