[PATCH] D82754: [lit] Prevent hang when lit sees non-ASCII characters

Richard Barton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 09:14:41 PDT 2020


richard.barton.arm updated this revision to Diff 276096.
richard.barton.arm added a comment.

Arg - finger trouble using arc!

I pushed the Flang test that I was writing that made me stumble across this
issue as part of this patch by mistake. Remove it from the new version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82754/new/

https://reviews.llvm.org/D82754

Files:
  llvm/utils/lit/lit/display.py
  llvm/utils/lit/tests/Inputs/shtest-shell-ascii/diff-in.bin
  llvm/utils/lit/tests/Inputs/shtest-shell-ascii/lit.cfg
  llvm/utils/lit/tests/Inputs/shtest-shell-ascii/stdout-encoding.txt
  llvm/utils/lit/tests/shtest-shell-ascii.py


Index: llvm/utils/lit/tests/shtest-shell-ascii.py
===================================================================
--- /dev/null
+++ llvm/utils/lit/tests/shtest-shell-ascii.py
@@ -0,0 +1,22 @@
+# Check the internal shell handling component of the ShTest format.
+#
+# RUN: env PYTHONIOENCODING=ascii %{lit} -j 1 -a %{inputs}/shtest-shell-ascii > %t.out
+# FIXME: Temporarily dump test output so we can debug failing tests on
+# buildbots.
+# RUN: cat %t.out
+# RUN: FileCheck --input-file %t.out %s
+#
+# END.
+
+# CHECK: -- Testing:
+
+# CHECK: PASS: shtest-shell-ascii :: stdout-encoding.txt
+# CHECK: $ "cat" "diff-in.bin"
+# CHECK: # command output:
+# CHECK-NEXT: {{^.f.o.o.$}}
+# CHECK-NEXT: {{^.b.a.r.$}}
+# CHECK-NEXT: {{^.b.a.z.$}}
+# CHECK-NOT: error
+# CHECK: ***
+
+# CHECK-NOT: Failed Tests
Index: llvm/utils/lit/tests/Inputs/shtest-shell-ascii/stdout-encoding.txt
===================================================================
--- /dev/null
+++ llvm/utils/lit/tests/Inputs/shtest-shell-ascii/stdout-encoding.txt
@@ -0,0 +1,4 @@
+# Check that lit doesn't fail when printing special characters in its test
+# results.
+
+# RUN: cat diff-in.bin
Index: llvm/utils/lit/tests/Inputs/shtest-shell-ascii/lit.cfg
===================================================================
--- /dev/null
+++ llvm/utils/lit/tests/Inputs/shtest-shell-ascii/lit.cfg
@@ -0,0 +1,7 @@
+import lit.formats
+config.name = 'shtest-shell-ascii'
+config.suffixes = ['.txt']
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
+config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
Index: llvm/utils/lit/lit/display.py
===================================================================
--- llvm/utils/lit/lit/display.py
+++ llvm/utils/lit/lit/display.py
@@ -86,7 +86,9 @@
                                      errors="replace")
                 except UnicodeDecodeError:
                     pass
-                out = out.decode(encoding=sys.stdout.encoding)
+                # Python 2 can raise UnicodeDecodeError when the stdout
+                # encoding is ASCII. Ignore decode errors in this case
+                out = out.decode(encoding=sys.stdout.encoding, errors="ignore")
             print(out)
             print("*" * 20)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82754.276096.patch
Type: text/x-patch
Size: 2305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200707/187f8c06/attachment.bin>


More information about the llvm-commits mailing list