Revert "[lit] Handle plain negations directly in the internal shell"

This reverts commit d09adfd399.

That commit caused failures in
clang-tidy/infrastructure/validate-check-names.cpp on windows
buildbots.

That change exposed a surprising issue, not directly related to
this change in itself, but in how TestRunner quotes command line
arguments that later are going to be interpreted by a msys based
tool (like grep.exe, when provided by Git for Windows). This
worked accidentally before, when grep was invoked via not.exe
which took a more conservative approach to windows argument quoting.
This commit is contained in:
Martin Storsjö 2021-03-19 12:30:08 +02:00
parent 7dd76cccca
commit f3dd783b23
1 changed files with 1 additions and 19 deletions

View File

@ -608,7 +608,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
assert isinstance(cmd, ShUtil.Pipeline) assert isinstance(cmd, ShUtil.Pipeline)
procs = [] procs = []
negate_procs = []
default_stdin = subprocess.PIPE default_stdin = subprocess.PIPE
stderrTempFiles = [] stderrTempFiles = []
opened_files = [] opened_files = []
@ -654,12 +653,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
if not args: if not args:
raise InternalShellError(j, "Error: 'not' requires a" raise InternalShellError(j, "Error: 'not' requires a"
" subcommand") " subcommand")
elif args[0] == '!':
not_args.append(args.pop(0))
not_count += 1
if not args:
raise InternalShellError(j, "Error: '!' requires a"
" subcommand")
else: else:
break break
@ -706,15 +699,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
# the assumptions that (1) environment variables are not intended to be # the assumptions that (1) environment variables are not intended to be
# relevant to 'not' commands and (2) the 'env' command should always # relevant to 'not' commands and (2) the 'env' command should always
# blindly pass along the status it receives from any command it calls. # blindly pass along the status it receives from any command it calls.
args = not_args + args
# For plain negations, either 'not' without '--crash', or the shell
# operator '!', leave them out from the command to execute and
# invert the result code afterwards.
if not_crash:
args = not_args + args
not_count = 0
else:
not_args = []
stdin, stdout, stderr = processRedirects(j, default_stdin, cmd_shenv, stdin, stdout, stderr = processRedirects(j, default_stdin, cmd_shenv,
opened_files) opened_files)
@ -778,7 +763,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
stderr = stderr, stderr = stderr,
env = cmd_shenv.env, env = cmd_shenv.env,
close_fds = kUseCloseFDs)) close_fds = kUseCloseFDs))
negate_procs.append((not_count % 2) != 0)
# Let the helper know about this process # Let the helper know about this process
timeoutHelper.addProcess(procs[-1]) timeoutHelper.addProcess(procs[-1])
except OSError as e: except OSError as e:
@ -831,8 +815,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
# Detect Ctrl-C in subprocess. # Detect Ctrl-C in subprocess.
if res == -signal.SIGINT: if res == -signal.SIGINT:
raise KeyboardInterrupt raise KeyboardInterrupt
if negate_procs[i]:
res = not res
# Ensure the resulting output is always of string type. # Ensure the resulting output is always of string type.
try: try: