[commit: ghc] master: testsuite: Pipe stdin directly to process (c9c762d)

git at git.haskell.org git at git.haskell.org
Thu Jul 20 16:04:57 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c9c762dc0a782cf66aa3bf5cccfa7f0d16a37696/ghc

>---------------------------------------------------------------

commit c9c762dc0a782cf66aa3bf5cccfa7f0d16a37696
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Thu Jul 20 08:40:49 2017 -0400

    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


>---------------------------------------------------------------

c9c762dc0a782cf66aa3bf5cccfa7f0d16a37696
 testsuite/driver/testlib.py | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 4212214..26e3d17 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)



More information about the ghc-commits mailing list