From 432914bba001c2d381734b1017eeb0bae2d850e5 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 28 Jul 2017 16:13:02 +0000 Subject: [PATCH] [lit] Fix shtest-format external_shell failures 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 | 1 + .../Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt | 2 +- .../tests/Inputs/shtest-format/external_shell/write-bad-encoding.py | 6 ++++++ .../tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh | 3 --- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py delete mode 100755 llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index 404b8f6..c2fbb84 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -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/fail_with_bad_encoding.txt b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt index f6157e6..12bbfc2 100644 --- a/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt +++ b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt @@ -1,5 +1,5 @@ # Run a command that fails with error on stdout. # -# RUN: %S/write-bad-encoding.sh +# RUN: python %S/write-bad-encoding.py # RUN: false 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 index 0000000..32ff2d8 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py @@ -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 index 6b622cb..0000000 --- a/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "a line with bad encoding: Â." -- 2.7.4