diff --git a/libcxx/test/libcxx/selftest/sh.cpp/run-error.sh.cpp b/libcxx/test/libcxx/selftest/sh.cpp/run-error.sh.cpp --- a/libcxx/test/libcxx/selftest/sh.cpp/run-error.sh.cpp +++ b/libcxx/test/libcxx/selftest/sh.cpp/run-error.sh.cpp @@ -10,4 +10,4 @@ // Make sure the test DOES NOT pass if it fails to run -// RUN: exit 1 +// RUN: false diff --git a/libcxx/test/libcxx/selftest/sh.cpp/run-success.sh.cpp b/libcxx/test/libcxx/selftest/sh.cpp/run-success.sh.cpp --- a/libcxx/test/libcxx/selftest/sh.cpp/run-success.sh.cpp +++ b/libcxx/test/libcxx/selftest/sh.cpp/run-success.sh.cpp @@ -8,4 +8,4 @@ // Make sure the test passes if it succeeds to run -// RUN: exit 0 +// RUN: true diff --git a/libcxx/test/libcxx/selftest/shell-escape.sh.cpp b/libcxx/test/libcxx/selftest/shell-escape.sh.cpp --- a/libcxx/test/libcxx/selftest/shell-escape.sh.cpp +++ b/libcxx/test/libcxx/selftest/shell-escape.sh.cpp @@ -11,8 +11,3 @@ // shell would look for a matching `"`. // RUN: %{exec} echo '"' - -// Also make sure that we don't escape Shell builtins like `!`, because the -// shell otherwise thinks it's a command and it can't find it. - -// RUN: ! false diff --git a/libcxx/test/libcxx/selftest/shell-escape-pipes.sh.cpp b/libcxx/test/libcxx/selftest/shell-quote-pipes.sh.cpp rename from libcxx/test/libcxx/selftest/shell-escape-pipes.sh.cpp rename to libcxx/test/libcxx/selftest/shell-quote-pipes.sh.cpp --- a/libcxx/test/libcxx/selftest/shell-escape-pipes.sh.cpp +++ b/libcxx/test/libcxx/selftest/shell-quote-pipes.sh.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// -// Make sure manually escaped pipes are handled properly by the shell. -// Specifically, we want to make sure that if we escape a pipe after %{exec}, -// it gets executed by the %{exec} substitution, as opposed to the result of -// the %{exec} substitution being piped into the following command. +// Make sure that quoted pipes are handled properly by the shell. Specifically, +// we want to make sure that if we quote a pipe after %{exec}, it gets executed +// by the %{exec} substitution, as opposed to the result of the %{exec} +// substitution being piped into the following command. // // This is a bit tricky to test. To test this, we basically want to ensure // that both sides of the pipe are executed inside %{exec}. When we're inside @@ -17,5 +17,5 @@ // directory with all file dependencies satisfied, so that's what we use. // RUN: touch %t.foobar -// RUN: %{exec} echo \| ls > %t.out +// RUN: %{exec} echo "|" ls > %t.out // RUN: grep -e ".foobar" %t.out diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp --- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp @@ -13,7 +13,7 @@ // istream cin; // RUN: %{build} -// RUN: %{exec} echo "123" \| %t.exe > %t.out +// RUN: %{exec} "echo" "123" "|" "%t.exe" > %t.out // RUN: grep -e 'The number is 123!' %t.out #include diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp @@ -13,7 +13,7 @@ // istream wcin; // RUN: %{build} -// RUN: %{exec} echo "123" \| %t.exe > %t.out +// RUN: %{exec} "echo" "123" "|" "%t.exe" > %t.out // RUN: grep -e 'The number is 123!' %t.out #include diff --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py --- a/libcxx/utils/libcxx/test/format.py +++ b/libcxx/utils/libcxx/test/format.py @@ -64,9 +64,7 @@ # Get the default substitutions tmpDir, tmpBase = _getTempPaths(test) - useExternalSh = True - substitutions = lit.TestRunner.getDefaultSubstitutions(test, tmpDir, tmpBase, - normalize_slashes=useExternalSh) + substitutions = lit.TestRunner.getDefaultSubstitutions(test, tmpDir, tmpBase) # Check base substitutions and add the %{build} and %{run} convenience substitutions _checkBaseSubstitutions(substitutions) @@ -241,7 +239,7 @@ return self._executeShTest(test, litConfig, steps) elif filename.endswith('.compile.fail.cpp'): steps = [ - "%dbg(COMPILED WITH) ! %{cxx} %s %{flags} %{compile_flags} -fsyntax-only" + "%dbg(COMPILED WITH) not %{cxx} %s %{flags} %{compile_flags} -fsyntax-only" ] return self._executeShTest(test, litConfig, steps) elif filename.endswith('.link.pass.cpp'): @@ -252,13 +250,16 @@ elif filename.endswith('.link.fail.cpp'): steps = [ "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -c -o %t.o", - "%dbg(LINKED WITH) ! %{cxx} %t.o %{flags} %{link_flags} -o %t.exe" + "%dbg(LINKED WITH) not %{cxx} %t.o %{flags} %{link_flags} -o %t.exe" ] return self._executeShTest(test, litConfig, steps) elif filename.endswith('.run.fail.cpp'): steps = [ "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe", - "%dbg(EXECUTED AS) %{exec} ! %t.exe" + # Note: This is technically incorrect -- we should instead run + # `not` inside the executor, but that requires the target + # to be able to run `not`, which isn't always the case. + "%dbg(EXECUTED AS) not %{exec} %t.exe" ] return self._executeShTest(test, litConfig, steps) elif filename.endswith('.verify.cpp'): @@ -289,7 +290,7 @@ ] else: steps = [ - "%dbg(COMPILED WITH) ! %{cxx} %s %{flags} %{compile_flags} -fsyntax-only" + "%dbg(COMPILED WITH) not %{cxx} %s %{flags} %{compile_flags} -fsyntax-only" ] return self._executeShTest(test, litConfig, steps) else: @@ -312,5 +313,5 @@ return lit.Test.Result(lit.Test.XFAIL if test.isExpectedToFail() else lit.Test.PASS) else: _, tmpBase = _getTempPaths(test) - useExternalSh = True + useExternalSh = False return lit.TestRunner._runShTest(test, litConfig, useExternalSh, script, tmpBase)