[PATCH] D63254: [lit] Fix UnicodeEncodeError when test commands contain non-ASCII chars
Michał Górny via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 08:44:01 PDT 2019
mgorny updated this revision to Diff 204557.
mgorny added a comment.
Here's a proposed test case. I've verified that it failed (became unresolved) without my patch.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63254/new/
https://reviews.llvm.org/D63254
Files:
llvm/utils/lit/lit/TestRunner.py
llvm/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt
llvm/utils/lit/tests/shtest-format.py
Index: llvm/utils/lit/tests/shtest-format.py
===================================================================
--- llvm/utils/lit/tests/shtest-format.py
+++ 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]+}}"/>
Index: llvm/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt
===================================================================
--- /dev/null
+++ 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 £
Index: llvm/utils/lit/lit/TestRunner.py
===================================================================
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -1133,9 +1133,12 @@
# Write script file
mode = 'w'
+ open_kwargs = {}
if litConfig.isWindows and not isWin32CMDEXE:
- mode += 'b' # Avoid CRLFs when writing bash scripts.
- f = open(script, mode)
+ mode += 'b' # Avoid CRLFs when writing bash scripts.
+ elif sys.version_info > (3,0):
+ open_kwargs['encoding'] = 'utf-8'
+ f = open(script, mode, **open_kwargs)
if isWin32CMDEXE:
for i, ln in enumerate(commands):
commands[i] = re.sub(kPdbgRegex, "echo '\\1' > nul && ", ln)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63254.204557.patch
Type: text/x-patch
Size: 1918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190613/7c30c156/attachment.bin>
More information about the llvm-commits
mailing list