summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-07-20 08:40:49 -0400
committerBen Gamari <ben@smart-cactus.org>2017-07-20 08:40:50 -0400
commitc9c762dc0a782cf66aa3bf5cccfa7f0d16a37696 (patch)
tree19dbebc126a083f7cef54399d4eae9b8238eb3c0
parent8e51bfc33c17aef41677a2b6189e3d4f31454cbc (diff)
downloadhaskell-c9c762dc0a782cf66aa3bf5cccfa7f0d16a37696.tar.gz
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
-rw-r--r--testsuite/driver/testlib.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 42122145f5..26e3d17679 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -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)