Commit 7d2df320 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

testsuite/driver: More Unicode awareness

Explicitly specify utf8 encoding in a few spots which were failing on
Windows with Python 3.

Test Plan: Validate

Reviewers: austin, thomie

Differential Revision:

GHC Trac Issues: #9184
parent 17d696f1
......@@ -208,7 +208,7 @@ from testlib import *
# 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 = getStdout([config.ghc_pkg, 'dump'])
pkginfo = str(getStdout([config.ghc_pkg, 'dump']))
topdir = config.libdir
if windows:
mingw = os.path.join(topdir, '../mingw/bin')
......@@ -303,7 +303,12 @@ for file in t_files:
if_verbose(2, '====> Scanning %s' % file)
newTestDir(tempdir, os.path.dirname(file))
src =, encoding='utf8').read()
src = open(file).read()
except Exception as e:
framework_fail(file, '', str(e))
......@@ -826,9 +826,9 @@ def do_test(name, way, func, args, files):
src_makefile = in_srcdir('Makefile')
dst_makefile = in_testdir('Makefile')
if os.path.exists(src_makefile):
with open(src_makefile, 'r') as src:
with, 'r', encoding='utf8') as src:
makefile = re.sub('TOP=.*', 'TOP=' +,, 1)
with open(dst_makefile, 'w') as dst:
with, 'w', encoding='utf8') as dst:
if config.use_threads:
......@@ -1289,20 +1289,20 @@ def interpreter_run(name, way, extra_hc_opts, top_mod):
delimiter = '===== program output begins here\n'
with open(script, 'w') as f:
with, 'w', encoding='utf8') as f:
# set the prog name and command-line args to match the compiled
# environment.
f.write(':set prog ' + name + '\n')
f.write(':set args ' + opts.extra_run_opts + '\n')
f.write(u':set prog ' + name + u'\n')
f.write(u':set args ' + opts.extra_run_opts + u'\n')
# Add marker lines to the stdout and stderr output files, so we
# can separate GHCi's output from the program's.
f.write(':! echo ' + delimiter)
f.write(':! echo 1>&2 ' + delimiter)
f.write(u':! echo ' + delimiter)
f.write(u':! echo 1>&2 ' + delimiter)
# Set stdout to be line-buffered to match the compiled environment.
f.write('System.IO.hSetBuffering System.IO.stdout System.IO.LineBuffering\n')
f.write(u'System.IO.hSetBuffering System.IO.stdout System.IO.LineBuffering\n')
# wrapping in GHC.TopHandler.runIO ensures we get the same output
# in the event of an exception as for the compiled program.
f.write('GHC.TopHandler.runIOFastExit Main.main Prelude.>> Prelude.return ()\n')
f.write(u'GHC.TopHandler.runIOFastExit Main.main Prelude.>> Prelude.return ()\n')
stdin = in_testdir(opts.stdin if opts.stdin else add_suffix(name, 'stdin'))
if os.path.exists(stdin):
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