From 3c18300ffe454f51a3eb0dbd8035dc475ccaa419 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Thu, 19 Mar 2020 21:25:48 +0100 Subject: [PATCH 1/2] CHECK-NOT: case when a few CHECK-NOT are the last --- filecheck/FileCheck.py | 18 +++++++++++++----- .../filecheck.check | 2 ++ .../filecheck.input | 2 ++ .../sample.itest | 7 +++++++ 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/filecheck.check create mode 100644 tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/filecheck.input create mode 100644 tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/sample.itest diff --git a/filecheck/FileCheck.py b/filecheck/FileCheck.py index 33a8788..137b6d9 100755 --- a/filecheck/FileCheck.py +++ b/filecheck/FileCheck.py @@ -361,8 +361,8 @@ def main(): print("FileCheck command line: {}".format(check_file)) exit(2) + current_not_checks = [] try: - current_not_checks = [] failed_check = None while True: @@ -454,10 +454,18 @@ def main(): try: while True: line_idx, line = next(stdin_input_iter) - if check_line(line, current_check, args.match_full_lines) == \ - CheckResult.CHECK_NOT_MATCH: - current_check_line_idx = line_idx - break + + for not_check in current_not_checks: + if check_line(line, not_check, args.match_full_lines) == \ + CheckResult.CHECK_NOT_MATCH: + current_check_line_idx = line_idx + failed_check = FailedCheck(not_check, line_idx) + raise CheckFailedException(failed_check) + + except CheckFailedException as e: + current_check = e.failed_check.check + current_check_line_idx = e.failed_check.line_idx + except StopIteration: exit(0) diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/filecheck.check b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/filecheck.check new file mode 100644 index 0000000..aafa8e3 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/filecheck.check @@ -0,0 +1,2 @@ +; CHECK-NOT:warning +; CHECK-NOT:error \ No newline at end of file diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/filecheck.input b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/filecheck.input new file mode 100644 index 0000000..080bdb0 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/filecheck.input @@ -0,0 +1,2 @@ +not w a r n i n g string +warning diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/sample.itest b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/sample.itest new file mode 100644 index 0000000..bcc98fd --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/06-multiple-CHECK-NOT-all-have-effect/sample.itest @@ -0,0 +1,7 @@ +; 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:; CHECK-NOT:warning +; CHECK: ^ +; CHECK::2:1: note: found here +; CHECK:warning +; CHECK:^~~~~~~ From f30eb2a3ce6b825180c5cb3a8beb740948580426 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Thu, 19 Mar 2020 22:12:15 +0100 Subject: [PATCH 2/2] CHECK-NOT: Fix edge case when CHECK_NOT strings get shadowed by each other Closes #103 --- filecheck/FileCheck.py | 3 +++ .../filecheck.check | 2 ++ .../filecheck.input | 1 + .../sample.itest | 9 +++++++++ 4 files changed, 15 insertions(+) create mode 100644 tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/filecheck.check create mode 100644 tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/filecheck.input create mode 100644 tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/sample.itest diff --git a/filecheck/FileCheck.py b/filecheck/FileCheck.py index 137b6d9..4a1a797 100755 --- a/filecheck/FileCheck.py +++ b/filecheck/FileCheck.py @@ -415,6 +415,9 @@ def main(): raise CheckFailedException(failed_check) elif check_result == CheckResult.CHECK_NOT_WITHOUT_MATCH: + if failed_check: + raise CheckFailedException(failed_check) + try: current_not_checks.append(current_check) current_check = next(check_iterator) diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/filecheck.check b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/filecheck.check new file mode 100644 index 0000000..11614e6 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/filecheck.check @@ -0,0 +1,2 @@ +; CHECK-NOT:warning +; CHECK-NOT:error diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/filecheck.input b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/filecheck.input new file mode 100644 index 0000000..14b472d --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/filecheck.input @@ -0,0 +1 @@ +warning \ No newline at end of file diff --git a/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/sample.itest b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/sample.itest new file mode 100644 index 0000000..159f514 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK-NOT/multiple_strings/07-multiple-CHECK-NOT-do-not-get-shadowed-by-each-other/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:warning +; CHECK: ^ +; CHECK::1:1: note: found here +; CHECK:warning +; CHECK:^~~~~~~ +; CHECK-EMPTY: