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

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
# declare the buffers to a default
stdin_buffer = None
# ***** IMPORTANT *****
# 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()
stdin_file = io.open(stdin, 'rb') if stdin else None
stdout_buffer = b''
stderr_buffer = b''
......@@ -1815,12 +1807,14 @@ def runCmd(cmd, stdin=None, stdout=None, stderr=None, timeout_multiplier=1.0, pr
# to invoke the Bourne shell
r = subprocess.Popen([timeout_prog, timeout, cmd],
stdin=subprocess.PIPE,
stdin=stdin_file,
stdout=subprocess.PIPE,
stderr=hStdErr)
stdout_buffer, stderr_buffer = r.communicate(stdin_buffer)
stdout_buffer, stderr_buffer = r.communicate()
finally:
if stdin_file:
stdin_file.close()
if config.verbose >= 1 and print_output >= 1:
if 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