[llvm] r188416 - [lit] Ensure test output is converted to strings where possible.
Daniel Dunbar
daniel at zuster.org
Wed Aug 14 15:21:02 PDT 2013
Author: ddunbar
Date: Wed Aug 14 17:21:01 2013
New Revision: 188416
URL: http://llvm.org/viewvc/llvm-project?rev=188416&view=rev
Log:
[lit] Ensure test output is converted to strings where possible.
- This cleans up the text output of failing tests when run under PY3.
Added:
llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt
- copied, changed from r188398, llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt
llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh (with props)
Modified:
llvm/trunk/utils/lit/lit/TestRunner.py
llvm/trunk/utils/lit/lit/util.py
llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt
llvm/trunk/utils/lit/tests/Inputs/shtest-format/fail.txt
llvm/trunk/utils/lit/tests/shtest-format.py
Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=188416&r1=188415&r2=188416&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Wed Aug 14 17:21:01 2013
@@ -198,6 +198,16 @@ def executeShCmd(cmd, cfg, cwd, results)
if res == -signal.SIGINT:
raise KeyboardInterrupt
+ # Ensure the resulting output is always of string type.
+ try:
+ out = str(out.decode('ascii'))
+ except:
+ out = str(out)
+ try:
+ err = str(err.decode('ascii'))
+ except:
+ err = str(err)
+
results.append((cmd.commands[i], out, err, res))
if cmd.pipe_err:
# Python treats the exit code as a signed char.
Modified: llvm/trunk/utils/lit/lit/util.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/util.py?rev=188416&r1=188415&r2=188416&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/util.py (original)
+++ llvm/trunk/utils/lit/lit/util.py Wed Aug 14 17:21:01 2013
@@ -156,4 +156,14 @@ def executeCommand(command, cwd=None, en
if exitCode == -signal.SIGINT:
raise KeyboardInterrupt
+ # Ensure the resulting output is always of string type.
+ try:
+ out = str(out.decode('ascii'))
+ except:
+ out = str(out)
+ try:
+ err = str(err.decode('ascii'))
+ except:
+ err = str(err)
+
return out, err, exitCode
Modified: llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt?rev=188416&r1=188415&r2=188416&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt (original)
+++ llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt Wed Aug 14 17:21:01 2013
@@ -1,3 +1,5 @@
# Run a command that fails with error on stdout.
#
+# RUN: echo "line 1: failed test output on stdout"
+# RUN: echo "line 2: failed test output on stdout"
# RUN: cat "does-not-exist"
Copied: llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt (from r188398, llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt?p2=llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt&p1=llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt&r1=188398&r2=188416&rev=188416&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt (original)
+++ llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt Wed Aug 14 17:21:01 2013
@@ -1,3 +1,5 @@
# Run a command that fails with error on stdout.
#
-# RUN: cat "does-not-exist"
+# RUN: %S/write-bad-encoding.sh
+# RUN: false
+
Added: llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh?rev=188416&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh (added)
+++ llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh Wed Aug 14 17:21:01 2013
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo "a line with bad encoding: Â."
Propchange: llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh
------------------------------------------------------------------------------
svn:executable = *
Modified: llvm/trunk/utils/lit/tests/Inputs/shtest-format/fail.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-format/fail.txt?rev=188416&r1=188415&r2=188416&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/shtest-format/fail.txt (original)
+++ llvm/trunk/utils/lit/tests/Inputs/shtest-format/fail.txt Wed Aug 14 17:21:01 2013
@@ -1 +1,2 @@
+# RUN: printf "line 1: failed test output on stdout\nline 2: failed test output on stdout"
# RUN: false
Modified: llvm/trunk/utils/lit/tests/shtest-format.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/shtest-format.py?rev=188416&r1=188415&r2=188416&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/shtest-format.py (original)
+++ llvm/trunk/utils/lit/tests/shtest-format.py Wed Aug 14 17:21:01 2013
@@ -8,14 +8,41 @@
# CHECK: -- Testing:
# CHECK: FAIL: shtest-format :: external_shell/fail.txt
-# CHECK: *** TEST 'shtest-format :: external_shell/fail.txt' FAILED ***
+# CHECK-NEXT: *** TEST 'shtest-format :: external_shell/fail.txt' FAILED ***
+# CHECK: Command Output (stdout):
+# CHECK-NEXT: --
+# CHECK-NEXT: line 1: failed test output on stdout
+# CHECK-NEXT: line 2: failed test output on stdout
# CHECK: Command Output (stderr):
-# CHECK: cat: does-not-exist: No such file or directory
+# CHECK-NEXT: --
+# CHECK-NEXT: cat: does-not-exist: No such file or directory
+# CHECK: --
+
+# CHECK: FAIL: shtest-format :: external_shell/fail_with_bad_encoding.txt
+# CHECK-NEXT: *** TEST 'shtest-format :: external_shell/fail_with_bad_encoding.txt' FAILED ***
+# CHECK: Command Output (stdout):
+# CHECK-NEXT: --
+# CHECK-NEXT: a line with bad encoding:
# CHECK: --
# CHECK: PASS: shtest-format :: external_shell/pass.txt
# CHECK: FAIL: shtest-format :: fail.txt
+# CHECK-NEXT: *** TEST 'shtest-format :: fail.txt' FAILED ***
+# CHECK-NEXT: Script:
+# CHECK-NEXT: --
+# CHECK-NEXT: printf "line 1
+# CHECK-NEXT: false
+# CHECK-NEXT: --
+# CHECK-NEXT: Exit Code: 1
+#
+# CHECK: Command Output (stdout):
+# CHECK-NEXT: --
+# CHECK-NEXT: Command 0: "printf"
+# CHECK-NEXT: Command 0 Result: 0
+# CHECK-NEXT: Command 0 Output:
+# CHECK-NEXT: line 1: failed test output on stdout
+# CHECK-NEXT: line 2: failed test output on stdout
# CHECK: UNRESOLVED: shtest-format :: no-test-line.txt
# CHECK: PASS: shtest-format :: pass.txt
@@ -31,8 +58,9 @@
# CHECK: Unexpected Passing Tests (1)
# CHECK: shtest-format :: xpass.txt
-# CHECK: Failing Tests (2)
+# CHECK: Failing Tests (3)
# CHECK: shtest-format :: external_shell/fail.txt
+# CHECK: shtest-format :: external_shell/fail_with_bad_encoding.txt
# CHECK: shtest-format :: fail.txt
# CHECK: Expected Passes : 3
@@ -40,4 +68,4 @@
# CHECK: Unsupported Tests : 2
# CHECK: Unresolved Tests : 1
# CHECK: Unexpected Passes : 1
-# CHECK: Unexpected Failures: 2
+# CHECK: Unexpected Failures: 3
More information about the llvm-commits
mailing list