Commit c9c762dc authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

testsuite: Pipe stdin directly to process

Previously the driver would read the stdin content from the source file
and then write it to the subprocess' stdin. We now simply open the stdin
file and provide that handle to the subprocess as its stdin

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie, goldfire

Differential Revision: https://phabricator.haskell.org/D3735
parent 8e51bfc3
...@@ -1792,15 +1792,7 @@ def runCmd(cmd, stdin=None, stdout=None, stderr=None, timeout_multiplier=1.0, pr ...@@ -1792,15 +1792,7 @@ def runCmd(cmd, stdin=None, stdout=None, stderr=None, timeout_multiplier=1.0, pr
# declare the buffers to a default # declare the buffers to a default
stdin_buffer = None stdin_buffer = None
# ***** IMPORTANT ***** stdin_file = io.open(stdin, 'rb') if stdin else None
# We have to treat input and output as
# just binary data here. Don't try to decode
# it to a string, since we have tests that actually
# feed malformed utf-8 to see how GHC handles it.
if stdin:
with io.open(stdin, 'rb') as f:
stdin_buffer = f.read()
stdout_buffer = b'' stdout_buffer = b''
stderr_buffer = b'' stderr_buffer = b''
...@@ -1815,12 +1807,14 @@ def runCmd(cmd, stdin=None, stdout=None, stderr=None, timeout_multiplier=1.0, pr ...@@ -1815,12 +1807,14 @@ def runCmd(cmd, stdin=None, stdout=None, stderr=None, timeout_multiplier=1.0, pr
# to invoke the Bourne shell # to invoke the Bourne shell
r = subprocess.Popen([timeout_prog, timeout, cmd], r = subprocess.Popen([timeout_prog, timeout, cmd],
stdin=subprocess.PIPE, stdin=stdin_file,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=hStdErr) stderr=hStdErr)
stdout_buffer, stderr_buffer = r.communicate(stdin_buffer) stdout_buffer, stderr_buffer = r.communicate()
finally: finally:
if stdin_file:
stdin_file.close()
if config.verbose >= 1 and print_output >= 1: if config.verbose >= 1 and print_output >= 1:
if stdout_buffer: if stdout_buffer:
sys.stdout.buffer.write(stdout_buffer) sys.stdout.buffer.write(stdout_buffer)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment