diff --git a/filecheck/FileCheck.py b/filecheck/FileCheck.py index d24b0e6..8fb68c7 100755 --- a/filecheck/FileCheck.py +++ b/filecheck/FileCheck.py @@ -23,6 +23,10 @@ def __init__(self, failed_check): self.failed_check = failed_check +class CheckNOTIsLastException(BaseException): + pass + + class InputFinishedException(BaseException): def __init__(self): pass @@ -390,7 +394,7 @@ def main(): current_check = next(check_iterator) continue except StopIteration: - exit(0) + raise CheckNOTIsLastException elif check_result == CheckResult.FAIL_SKIP_LINE: try: @@ -417,6 +421,20 @@ def main(): current_check = still_actual_check current_check_line_idx = line_idx + except CheckNOTIsLastException: + # Here we catch the case when the last check is known to be CHECK-NOT. + # We have to iterate over the remaining input lines and check them all + # against this last check. + try: + while True: + line_idx, line = next(stdin_input_iter) + input_lines.append(line) + if check_line(line, current_check, args.match_full_lines) == \ + CheckResult.CHECK_NOT_MATCH: + current_check_line_idx = line_idx + break + except StopIteration: + exit(0) except CheckFailedException as e: current_check = e.failed_check.check diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/filecheck.check b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/filecheck.check new file mode 100644 index 0000000..d8c3cc6 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/filecheck.check @@ -0,0 +1 @@ +; CHECK-NOT:String5 diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/filecheck.input b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/filecheck.input new file mode 100644 index 0000000..a0be416 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/filecheck.input @@ -0,0 +1,5 @@ +String1 +String2 +String3 +String4 +String5 diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/sample.itest b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/sample.itest new file mode 100644 index 0000000..e3105dc --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/02-CHECK-NOT-is-the-last-check-and-multiple-to-check-yet/sample.itest @@ -0,0 +1,9 @@ +; RUN: cat %S/filecheck.input | (%FILECHECK_EXEC %S/filecheck.check 2>&1; test $? = 1;) | %FILECHECK_TESTER_EXEC %s --strict-whitespace --match-full-lines +; CHECK:{{^.*}}FileCheck{{(\.py)?$}} +; CHECK:{{^.*}}filecheck.check:1:13: error: CHECK-NOT: excluded string found in input{{$}} +; CHECK:; CHECK-NOT:String5 +; CHECK: ^ +; CHECK::5:1: note: found here +; CHECK:String5 +; CHECK:^~~~~~~ +; CHECK-EMPTY: