mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[lit] Fix the return code for "not not" after evaluating "not" internally
This fixes cases where "not not <command>" is supposed to return only the error codes 0 or 1, but after efee57925c3f46c74c6697, it passed the original error code through. This was visible on AIX in the shtest-output-printing.py testcase, where 'wc' returns 2, while it returns 1 on other platforms, and the test required "not not" to normalize it to 1.
This commit is contained in:
parent
fdef0cf249
commit
86db67416f
@ -614,7 +614,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
|
||||
assert isinstance(cmd, ShUtil.Pipeline)
|
||||
|
||||
procs = []
|
||||
negate_procs = []
|
||||
proc_not_counts = []
|
||||
default_stdin = subprocess.PIPE
|
||||
stderrTempFiles = []
|
||||
opened_files = []
|
||||
@ -784,7 +784,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
|
||||
stderr = stderr,
|
||||
env = cmd_shenv.env,
|
||||
close_fds = kUseCloseFDs))
|
||||
negate_procs.append((not_count % 2) != 0)
|
||||
proc_not_counts.append(not_count)
|
||||
# Let the helper know about this process
|
||||
timeoutHelper.addProcess(procs[-1])
|
||||
except OSError as e:
|
||||
@ -837,8 +837,10 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
|
||||
# Detect Ctrl-C in subprocess.
|
||||
if res == -signal.SIGINT:
|
||||
raise KeyboardInterrupt
|
||||
if negate_procs[i]:
|
||||
if proc_not_counts[i] % 2:
|
||||
res = not res
|
||||
elif proc_not_counts[i] > 1:
|
||||
res = 1 if res != 0 else 0
|
||||
|
||||
# Ensure the resulting output is always of string type.
|
||||
try:
|
||||
|
7
utils/lit/tests/Inputs/shtest-not/fail2.py
Normal file
7
utils/lit/tests/Inputs/shtest-not/fail2.py
Normal file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import print_environment
|
||||
import sys
|
||||
|
||||
print_environment.execute()
|
||||
sys.exit(2)
|
4
utils/lit/tests/Inputs/shtest-not/not-calls-fail2.txt
Normal file
4
utils/lit/tests/Inputs/shtest-not/not-calls-fail2.txt
Normal file
@ -0,0 +1,4 @@
|
||||
# Check that "not not" either returns 0 or 1, even if the original
|
||||
# program exited with a different code.
|
||||
|
||||
# RUN: not not %{python} fail2.py
|
@ -10,7 +10,7 @@
|
||||
|
||||
# Make sure not and env commands are included in printed commands.
|
||||
|
||||
# CHECK: -- Testing: 16 tests{{.*}}
|
||||
# CHECK: -- Testing: 17 tests{{.*}}
|
||||
|
||||
# CHECK: FAIL: shtest-not :: exclamation-args-nested-none.txt {{.*}}
|
||||
# CHECK: $ "!" "!" "!"
|
||||
@ -121,6 +121,13 @@
|
||||
# CHECK: $ "not" "not" "--crash" "env" "-u" "BAR" "not" "env" "-u" "FOO" "BAR=1" "{{[^"]*}}" "pass.py"
|
||||
|
||||
|
||||
# CHECK: FAIL: shtest-not :: not-calls-fail2.txt {{.*}}
|
||||
# CHECK-NEXT: {{.*}} TEST 'shtest-not :: not-calls-fail2.txt' FAILED {{.*}}
|
||||
# CHECK-NEXT: Script:
|
||||
# CHECK-NEXT: --
|
||||
# CHECK: --
|
||||
# CHECK-NEXT: Exit Code: 1
|
||||
|
||||
# CHECK: FAIL: shtest-not :: not-calls-mkdir.txt {{.*}}
|
||||
# CHECK: $ "not" "mkdir" {{.*}}
|
||||
# CHECK: $ "not" "--crash" "mkdir" "foobar"
|
||||
@ -134,5 +141,5 @@
|
||||
# CHECK: error: command failed with exit status: {{.*}}
|
||||
|
||||
# CHECK: Passed: 1
|
||||
# CHECK: Failed: 15
|
||||
# CHECK: Failed: 16
|
||||
# CHECK-NOT: {{.}}
|
||||
|
Loading…
Reference in New Issue
Block a user