Commit 36a4c194 authored by Krzysztof Gogolewski's avatar Krzysztof Gogolewski

Testsuite driver: fix encoding issue when calling ghc-pkg

In Python 3, subprocess.communicate() returns a pair of bytes, which
need to be decoded. In, 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:
parent 29dfb636
......@@ -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))
......@@ -189,7 +189,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'))
......@@ -10,8 +10,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:],
......@@ -22,7 +21,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 lndir(srcdir, dstdir):
# Create symlinks for all files in src directory.
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