diff --git a/filecheck/FileCheck.py b/filecheck/FileCheck.py index 2f9e6d5..0710c21 100755 --- a/filecheck/FileCheck.py +++ b/filecheck/FileCheck.py @@ -200,6 +200,10 @@ def implicit_check_line(check_not_check, strict_mode, line): def main(): + # Force UTF-8 to be sent to stdout. + # https://stackoverflow.com/a/3597849/598057 + sys.stdout = open(1, 'w', encoding='utf-8', closefd=False) + args = None input_lines = None diff --git a/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.check b/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.check new file mode 100644 index 0000000..a9988ba --- /dev/null +++ b/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.check @@ -0,0 +1 @@ +CHECK: Match line that does not exist in input. diff --git a/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.input b/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.input new file mode 100644 index 0000000..eaaee08 --- /dev/null +++ b/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.input @@ -0,0 +1,2 @@ +# © A line with UTF-8 produces +# vadsэавфыаЭХÜÜÄ diff --git a/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.itest b/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.itest new file mode 100644 index 0000000..8f5b75b --- /dev/null +++ b/tests/integration/tests/general/02-utf8-characters-printed-at-failure/sample.itest @@ -0,0 +1,11 @@ +RUN: %cat "%S/sample.input" | \ +RUN: %expect_exit 1 %FILECHECK_EXEC "%S/sample.check" --dump-input=fail | \ +RUN: %FILECHECK_TESTER_EXEC "%s" \ +RUN: --strict-whitespace \ +RUN: --match-full-lines + +CHECK:{{.*}}/sample.check:1:8: error: CHECK: expected string not found in input +CHECK:{{.*}}CHECK: Match line that does not exist in input. +CHECK:{{.*}}:1:1: note: scanning from here +CHECK:{{.*}}# © A line with UTF-8 produces +CHECK:{{.*}}# vadsэавфыаЭХÜÜÄ diff --git a/tests/integration/tools/expect_exit.py b/tests/integration/tools/expect_exit.py index 878ba26..69de584 100644 --- a/tests/integration/tools/expect_exit.py +++ b/tests/integration/tools/expect_exit.py @@ -1,6 +1,10 @@ import subprocess import sys +# Force UTF-8 to be sent to stdout. +# https://stackoverflow.com/a/3597849/598057 +sys.stdout = open(1, 'w', encoding='utf-8', closefd=False) + if len(sys.argv) <= 2: print("error: expect_exit: expect arguments to be provided") exit(1)