[commit: ghc] ghc-8.6: Testsuite driver: fix encoding issue when calling ghc-pkg (2bbff4d)

git at git.haskell.org git at git.haskell.org
Tue Aug 7 12:30:36 UTC 2018


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

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/2bbff4dccc05a82492458c113ba24b8cd6caf41d/ghc

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

commit 2bbff4dccc05a82492458c113ba24b8cd6caf41d
Author: Krzysztof Gogolewski <krz.gogolewski at gmail.com>
Date:   Mon Aug 6 21:38:52 2018 +0200

    Testsuite driver: fix encoding issue when calling ghc-pkg
    
    Summary:
    In Python 3, subprocess.communicate() returns a pair of bytes, which
    need to be decoded. In runtests.py, we were just calling str() instead,
    which converts b'x' to "b'x'". As a result, the loop that was checking
    pkginfo for lines starting with 'library-dirs' couldn't work.
    
    Reviewers: bgamari, thomie, Phyx
    
    Reviewed By: thomie
    
    Subscribers: Phyx, rwbarton, carter
    
    Differential Revision: https://phabricator.haskell.org/D5046
    
    (cherry picked from commit 36a4c19494e2cb7e968f1d0e0c09926a660e1a56)


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

2bbff4dccc05a82492458c113ba24b8cd6caf41d
 testsuite/config/ghc         | 4 ++--
 testsuite/driver/runtests.py | 2 +-
 testsuite/driver/testutil.py | 5 ++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/testsuite/config/ghc b/testsuite/config/ghc
index f41f372..5e442b6 100644
--- a/testsuite/config/ghc
+++ b/testsuite/config/ghc
@@ -158,10 +158,10 @@ llvm_ways     = [x[0] for x in config.way_flags.items()
                       if '-fflvm' in x[1]]
 
 def get_compiler_info():
-    s = getStdout([config.compiler, '--info']).decode('utf8')
+    s = getStdout([config.compiler, '--info'])
     s = re.sub('[\r\n]', '', s)
     compilerInfoDict = dict(eval(s))
-    s = getStdout([config.compiler, '+RTS', '--info']).decode('utf8')
+    s = getStdout([config.compiler, '+RTS', '--info'])
     s = re.sub('[\r\n]', '', s)
     rtsInfoDict = dict(eval(s))
 
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index 4e275c5..05f934e 100644
--- a/testsuite/driver/runtests.py
+++ b/testsuite/driver/runtests.py
@@ -193,7 +193,7 @@ def format_path(path):
 # On Windows we need to set $PATH to include the paths to all the DLLs
 # in order for the dynamic library tests to work.
 if windows or darwin:
-    pkginfo = str(getStdout([config.ghc_pkg, 'dump']))
+    pkginfo = getStdout([config.ghc_pkg, 'dump'])
     topdir = config.libdir
     if windows:
         mingw = os.path.abspath(os.path.join(topdir, '../mingw/bin'))
diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py
index dcba177..7c2efa8 100644
--- a/testsuite/driver/testutil.py
+++ b/testsuite/driver/testutil.py
@@ -11,8 +11,7 @@ def strip_quotes(s):
     return s.strip('\'"')
 
 def getStdout(cmd_and_args):
-    # Can't use subprocess.check_output as it's not available in Python 2.6;
-    # It's also not quite the same as check_output, since we also verify that
+    # Can't use subprocess.check_output, since we also verify that
     # no stderr was produced
     p = subprocess.Popen([strip_quotes(cmd_and_args[0])] + cmd_and_args[1:],
                          stdout=subprocess.PIPE,
@@ -23,7 +22,7 @@ def getStdout(cmd_and_args):
         raise Exception("Command failed: " + str(cmd_and_args))
     if stderr:
         raise Exception("stderr from command: %s\nOutput:\n%s\n" % (cmd_and_args, stderr))
-    return stdout
+    return stdout.decode('utf-8')
 
 def mkdirp(path):
     try:



More information about the ghc-commits mailing list