summaryrefslogtreecommitdiffstats
path: root/llvm/utils/lit/tests
diff options
context:
space:
mode:
authorMichal Gorny <mgorny@gentoo.org>2019-06-14 13:31:48 +0000
committerMichal Gorny <mgorny@gentoo.org>2019-06-14 13:31:48 +0000
commit0c28a8f6282f09b1003ebbbb9ce07c8e12d79c46 (patch)
treec33329654099ec4d0b838b46bf824574727e3030 /llvm/utils/lit/tests
parent6b78e4d0a43b780311cfff3b7023fd94fc247748 (diff)
downloadbcm5719-llvm-0c28a8f6282f09b1003ebbbb9ce07c8e12d79c46.tar.gz
bcm5719-llvm-0c28a8f6282f09b1003ebbbb9ce07c8e12d79c46.zip
[lit] Fix UnicodeEncodeError when test commands contain non-ASCII chars
Ensure that the bash script written by lit TestRunner is open with UTF-8 encoding when using Python 3. Otherwise, attempt to write non-ASCII characters causes UnicodeEncodeError. This happened e.g. with the following LLD test: UNRESOLVED: lld :: ELF/format-binary-non-ascii.s (657 of 2119) ******************** TEST 'lld :: ELF/format-binary-non-ascii.s' FAILED ******************** Exception during script execution: Traceback (most recent call last): File "/home/mgorny/llvm-project/llvm/utils/lit/lit/worker.py", line 63, in _execute_test result = test.config.test_format.execute(test, lit_config) File "/home/mgorny/llvm-project/llvm/utils/lit/lit/formats/shtest.py", line 25, in execute self.execute_external) File "/home/mgorny/llvm-project/llvm/utils/lit/lit/TestRunner.py", line 1644, in executeShTest res = _runShTest(test, litConfig, useExternalSh, script, tmpBase) File "/home/mgorny/llvm-project/llvm/utils/lit/lit/TestRunner.py", line 1590, in _runShTest res = executeScript(test, litConfig, tmpBase, script, execdir) File "/home/mgorny/llvm-project/llvm/utils/lit/lit/TestRunner.py", line 1157, in executeScript f.write('{ ' + '; } &&\n{ '.join(commands) + '; }') UnicodeEncodeError: 'ascii' codec can't encode character '\xa3' in position 274: ordinal not in range(128) Differential Revision: https://reviews.llvm.org/D63254 llvm-svn: 363388
Diffstat (limited to 'llvm/utils/lit/tests')
-rw-r--r--llvm/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt3
-rw-r--r--llvm/utils/lit/tests/shtest-format.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt
new file mode 100644
index 00000000000..cec0b389603
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt
@@ -0,0 +1,3 @@
+# Run a command including UTF-8 characters.
+#
+# RUN: echo £
diff --git a/llvm/utils/lit/tests/shtest-format.py b/llvm/utils/lit/tests/shtest-format.py
index 0031ccf711b..4f628dc7242 100644
--- a/llvm/utils/lit/tests/shtest-format.py
+++ b/llvm/utils/lit/tests/shtest-format.py
@@ -80,7 +80,7 @@
# CHECK: shtest-format :: external_shell/fail_with_bad_encoding.txt
# CHECK: shtest-format :: fail.txt
-# CHECK: Expected Passes : 7
+# CHECK: Expected Passes : 8
# CHECK: Expected Failures : 4
# CHECK: Unsupported Tests : 5
# CHECK: Unresolved Tests : 3
@@ -90,7 +90,7 @@
# XUNIT: <?xml version="1.0" encoding="UTF-8" ?>
# XUNIT-NEXT: <testsuites>
-# XUNIT-NEXT: <testsuite name="shtest-format" tests="23" failures="7" skipped="5">
+# XUNIT-NEXT: <testsuite name="shtest-format" tests="24" failures="7" skipped="5">
# XUNIT: <testcase classname="shtest-format.shtest-format" name="argv0.txt" time="{{[0-9]+\.[0-9]+}}"/>
OpenPOWER on IntegriCloud