diff --git a/filecheck/FileCheck.py b/filecheck/FileCheck.py index 322ac14..1682f1c 100755 --- a/filecheck/FileCheck.py +++ b/filecheck/FileCheck.py @@ -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 diff --git a/tasks.py b/tasks.py index f85afa1..a10be8d 100644 --- a/tasks.py +++ b/tasks.py @@ -18,19 +18,6 @@ def get_os_filename_string(): assert 0, "error: FileCheck.py could not detect OS" -def get_filecheck_py_exec(): - cwd = os.getcwd() - return 'python \\"{cwd}/filecheck/FileCheck.py\\"'.format(cwd=cwd) - - -def get_filecheck_tester_exec(): - cwd = os.getcwd() - os_string = get_os_filename_string() - - template = '\\"{cwd}/tests/integration/tools/FileCheck/FileCheck-9.0.1-{os_string}\\"' - return template.format(cwd=cwd, os_string=os_string) - - def get_filecheck_llvm_path(filecheck_exec): cwd = os.getcwd() os_string = get_os_filename_string() @@ -41,11 +28,16 @@ def get_filecheck_llvm_path(filecheck_exec): ) +def get_filecheck_py_exec(): + cwd = os.getcwd() + return 'python \\"{cwd}/filecheck/FileCheck.py\\"'.format(cwd=cwd) + + def formatted_command(string): return re.sub('\\s+', ' ', string).strip() -def run_lit_tests(c, filecheck_exec, llvm_only): +def run_lit_tests(c, filecheck_exec, filecheck_tester_exec, llvm_only): assert c assert filecheck_exec assert llvm_only is not None @@ -53,7 +45,6 @@ def run_lit_tests(c, filecheck_exec, llvm_only): cwd = os.getcwd() llvm_only_value = "1" if llvm_only else "" - filecheck_tester_exec = get_filecheck_tester_exec() command = formatted_command(""" lit @@ -71,11 +62,37 @@ def run_lit_tests(c, filecheck_exec, llvm_only): c.run("{}".format(command)) +@task +def test_filecheck_llvm(c): + filecheck_llvm_8_exec = get_filecheck_llvm_path(FILECHECK_LLVM_8_EXEC) + filecheck_llvm_9_exec = get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC) + filecheck_tester_exec = get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC) + + run_lit_tests(c, filecheck_llvm_8_exec, filecheck_tester_exec, True) + run_lit_tests(c, filecheck_llvm_9_exec, filecheck_tester_exec, True) + + +@task +def test_filecheck_py_using_file_check_llvm_tester(c): + filecheck_exec = get_filecheck_py_exec() + filecheck_tester_exec = get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC) + + run_lit_tests(c, filecheck_exec, filecheck_tester_exec, False) + + +@task +def test_filecheck_py_using_filecheck_py_tester(c): + filecheck_exec = get_filecheck_py_exec() + filecheck_tester_exec = filecheck_exec + + run_lit_tests(c, filecheck_exec, filecheck_tester_exec, False) + + @task def test(c): - run_lit_tests(c, get_filecheck_llvm_path(FILECHECK_LLVM_8_EXEC), True) - run_lit_tests(c, get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC), True) - run_lit_tests(c, get_filecheck_py_exec(), False) + test_filecheck_llvm(c) + test_filecheck_py_using_file_check_llvm_tester(c) + @task def clean(c): diff --git a/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/filecheck.check b/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/filecheck.check new file mode 100644 index 0000000..2a08fcc --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/filecheck.check @@ -0,0 +1 @@ +; CHECK:{{^.*filecheck.check:1:(9|10): error: CHECK: expected string not found in input$}} diff --git a/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/filecheck.input b/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/filecheck.input new file mode 100644 index 0000000..1350049 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/filecheck.input @@ -0,0 +1 @@ +A-very-long-path/filecheck.check:1:9: error: CHECK: expected string not found in input diff --git a/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/sample.itest b/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/sample.itest new file mode 100644 index 0000000..ed5ddc6 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK/one_string/positive-match/05-CHECK-two-times-matches-first/sample.itest @@ -0,0 +1 @@ +; RUN: %cat "%S/filecheck.input" | %expect_exit 0 --expect-no-content %FILECHECK_EXEC "%S/filecheck.check" diff --git a/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/filecheck.check b/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/filecheck.check new file mode 100644 index 0000000..a3937b2 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/filecheck.check @@ -0,0 +1,2 @@ +; CHECK: hello1 +; CHECK: foo diff --git a/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/filecheck.input b/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/filecheck.input new file mode 100644 index 0000000..fc94b50 --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/filecheck.input @@ -0,0 +1,2 @@ +hello1 +hello2 \ No newline at end of file diff --git a/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/sample.itest b/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/sample.itest new file mode 100644 index 0000000..69ca0ac --- /dev/null +++ b/tests/integration/tests/check_commands/CHECK/two_strings/04-wip-negative_match_second_string/sample.itest @@ -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: {{^:.*:.*: note: scanning from here$}} +; CHECK: hello2 +; CHECK: ^{{$}} +; CHECK: {{^:.*:.*: note: possible intended match here$}} +; CHECK: hello2 +; CHECK: ^ +; CHECK-EMPTY: diff --git a/tests/integration/tests/options/--match-full-lines/CHECK/01_matching_substring_is_rejected_when_full_match_enabled/sample.itest b/tests/integration/tests/options/--match-full-lines/CHECK/01_matching_substring_is_rejected_when_full_match_enabled/sample.itest index e3266b7..79dfb00 100644 --- a/tests/integration/tests/options/--match-full-lines/CHECK/01_matching_substring_is_rejected_when_full_match_enabled/sample.itest +++ b/tests/integration/tests/options/--match-full-lines/CHECK/01_matching_substring_is_rejected_when_full_match_enabled/sample.itest @@ -1,5 +1,5 @@ ; RUN: %cat "%S/filecheck.input" | %expect_exit 0 --expect-no-content %FILECHECK_EXEC "%S/filecheck.check" -; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --match-full-lines | %FILECHECK_TESTER_EXEC "%s" --match-full-lines --strict-whitespace -check-prefix=OPTION +; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --match-full-lines | %FILECHECK_TESTER_EXEC "%s" --match-full-lines --strict-whitespace --check-prefix=OPTION ; OPTION:{{^.*}}filecheck.check:1:10: error: CHECK: expected string not found in input{{$}} ; OPTION:; CHECK: hello world diff --git a/tests/integration/tests/options/--strict-whitespace/CHECK/01_input_has_mixed_spaces_and_tabs/sample.itest b/tests/integration/tests/options/--strict-whitespace/CHECK/01_input_has_mixed_spaces_and_tabs/sample.itest index ac6b271..551666a 100644 --- a/tests/integration/tests/options/--strict-whitespace/CHECK/01_input_has_mixed_spaces_and_tabs/sample.itest +++ b/tests/integration/tests/options/--strict-whitespace/CHECK/01_input_has_mixed_spaces_and_tabs/sample.itest @@ -1,5 +1,5 @@ ; RUN: %cat "%S/filecheck.input" | %expect_exit 0 --expect-no-content %FILECHECK_EXEC "%S/filecheck.check" -; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --strict-whitespace | %FILECHECK_TESTER_EXEC "%s" --match-full-lines -check-prefix=OPTION +; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --strict-whitespace | %FILECHECK_TESTER_EXEC "%s" --match-full-lines --check-prefix=OPTION ; OPTION: {{^.*}}filecheck.check:1:10: error: CHECK: expected string not found in input{{$}} ; OPTION: ; CHECK: hello world hello world diff --git a/tests/integration/tests/options/--strict-whitespace/CHECK/02_check_has_mixed_spaces_and_tabs/sample.itest b/tests/integration/tests/options/--strict-whitespace/CHECK/02_check_has_mixed_spaces_and_tabs/sample.itest index 6b705db..fa9134c 100644 --- a/tests/integration/tests/options/--strict-whitespace/CHECK/02_check_has_mixed_spaces_and_tabs/sample.itest +++ b/tests/integration/tests/options/--strict-whitespace/CHECK/02_check_has_mixed_spaces_and_tabs/sample.itest @@ -1,5 +1,5 @@ ; RUN: %cat "%S/filecheck.input" | %expect_exit 0 --expect-no-content %FILECHECK_EXEC "%S/filecheck.check" -; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --strict-whitespace | %FILECHECK_TESTER_EXEC "%s" --strict-whitespace --match-full-lines -check-prefix=OPTION +; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --strict-whitespace | %FILECHECK_TESTER_EXEC "%s" --strict-whitespace --match-full-lines --check-prefix=OPTION ; OPTION:{{^.*}}filecheck.check:1:10: error: CHECK: expected string not found in input{{$}} ; OPTION:; CHECK: hello world hello world diff --git a/tests/integration/tests/options/--strict-whitespace/CHECK_NOT/01_input_has_mixed_spaces_and_tabs/sample.itest b/tests/integration/tests/options/--strict-whitespace/CHECK_NOT/01_input_has_mixed_spaces_and_tabs/sample.itest index b7c9e99..0977b4e 100644 --- a/tests/integration/tests/options/--strict-whitespace/CHECK_NOT/01_input_has_mixed_spaces_and_tabs/sample.itest +++ b/tests/integration/tests/options/--strict-whitespace/CHECK_NOT/01_input_has_mixed_spaces_and_tabs/sample.itest @@ -1,4 +1,4 @@ -; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" | %FILECHECK_TESTER_EXEC "%s" --strict-whitespace --match-full-lines -check-prefix=NO_OPTION +; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" | %FILECHECK_TESTER_EXEC "%s" --strict-whitespace --match-full-lines --check-prefix=NO_OPTION ; RUN: %cat "%S/filecheck.input" | %expect_exit 0 --expect-no-content %FILECHECK_EXEC "%S/filecheck.check" --strict-whitespace ; NO_OPTION:{{^.*}}filecheck.check:1:14: error: CHECK-NOT: excluded string found in input{{$}} diff --git a/tests/integration/tests/options/--strict-whitespace/CHECK_NOT/02_check_has_mixed_spaces_and_tabs/sample.itest b/tests/integration/tests/options/--strict-whitespace/CHECK_NOT/02_check_has_mixed_spaces_and_tabs/sample.itest index 6b705db..fa9134c 100644 --- a/tests/integration/tests/options/--strict-whitespace/CHECK_NOT/02_check_has_mixed_spaces_and_tabs/sample.itest +++ b/tests/integration/tests/options/--strict-whitespace/CHECK_NOT/02_check_has_mixed_spaces_and_tabs/sample.itest @@ -1,5 +1,5 @@ ; RUN: %cat "%S/filecheck.input" | %expect_exit 0 --expect-no-content %FILECHECK_EXEC "%S/filecheck.check" -; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --strict-whitespace | %FILECHECK_TESTER_EXEC "%s" --strict-whitespace --match-full-lines -check-prefix=OPTION +; RUN: %cat "%S/filecheck.input" | %expect_exit 1 %FILECHECK_EXEC "%S/filecheck.check" --strict-whitespace | %FILECHECK_TESTER_EXEC "%s" --strict-whitespace --match-full-lines --check-prefix=OPTION ; OPTION:{{^.*}}filecheck.check:1:10: error: CHECK: expected string not found in input{{$}} ; OPTION:; CHECK: hello world hello world