[lit] Fix shtest-format external_shell failures
authorReid Kleckner <rnk@google.com>
Fri, 28 Jul 2017 16:13:02 +0000 (16:13 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 28 Jul 2017 16:13:02 +0000 (16:13 +0000)
When using win32 cmd.exe, turn off command echoing at the beginning of
the script (@echo off).

Replace a bash shell script with a python script for the
fail_with_bad_encoding test.

llvm-svn: 309399

llvm/utils/lit/lit/TestRunner.py
llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt
llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh [deleted file]

index 404b8f6..c2fbb84 100644 (file)
@@ -711,6 +711,7 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
       mode += 'b'  # Avoid CRLFs when writing bash scripts.
     f = open(script, mode)
     if isWin32CMDEXE:
+        f.write('@echo off\n')
         f.write('\nif %ERRORLEVEL% NEQ 0 EXIT\n'.join(commands))
     else:
         if test.config.pipefail:
diff --git a/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py
new file mode 100644 (file)
index 0000000..32ff2d8
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+import sys
+
+sys.stdout.write(b"a line with bad encoding: \xc2.")
+sys.stdout.flush()
diff --git a/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh
deleted file mode 100755 (executable)
index 6b622cb..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-echo "a line with bad encoding: Â."