Commit fa6d8ee2 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Make the dynlib tests work on Windows

parent f1fb386d
...@@ -23,6 +23,11 @@ from testglobals import * ...@@ -23,6 +23,11 @@ from testglobals import *
# value. # value.
os.environ['TERM'] = 'vt100' os.environ['TERM'] = 'vt100'
if sys.platform == "cygwin":
cygwin = True
else:
cygwin = False
global config global config
config = getConfig() # get it from testglobals config = getConfig() # get it from testglobals
...@@ -104,7 +109,7 @@ if config.use_threads == 1: ...@@ -104,7 +109,7 @@ if config.use_threads == 1:
# Try to use UTF8 # Try to use UTF8
if windows: if windows:
if sys.platform == "cygwin": if cygwin:
# Is this actually right? Which calling convention does it use? # Is this actually right? Which calling convention does it use?
# As of the time of writing, ctypes.windll doesn't exist in the # As of the time of writing, ctypes.windll doesn't exist in the
# cygwin python, anyway. # cygwin python, anyway.
...@@ -149,6 +154,33 @@ get_compiler_info() ...@@ -149,6 +154,33 @@ get_compiler_info()
# enabled or not # enabled or not
from testlib import * 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:
if have_subprocess:
libs = getStdout([config.ghc_pkg, 'list', '--simple-output'])
for lib in libs.split(' '):
path = getStdout([config.ghc_pkg, 'field', lib, 'library-dirs'])
# We assume there is only 1 path, and make some assumptions
# about what it looks like. Unquoted strings we leave alone,
# and we assume that a \ escapes the following char if it's
# quoted. The common case here is "c:\\foo bar\\baz" where
# we want to undouble the backslashes.
path = path.rstrip();
path = re.sub('^library-dirs: ', '', path)
if path.startswith('"'):
path = re.sub('^"(.*)"$', '\\1', path)
path = re.sub('\\\\(.)', '\\1', path)
if cygwin:
# On cygwin we can't put "c:\foo" in $PATH, as : is a
# field separator. So convert to /cygdrive/c/foo instead.
# Other pythons use ; as the separator, so no problem.
path = re.sub('([a-zA-Z]):', '/cygdrive/\\1', path)
path = re.sub('\\\\', '/', path)
os.environ['PATH'] = os.pathsep.join([path, os.environ.get("PATH", "")])
else:
raise Exception("Need subprocess on Windows, but don't have it")
global testopts_local global testopts_local
testopts_local.x = TestOptions() testopts_local.x = TestOptions()
......
...@@ -1537,3 +1537,19 @@ def summary(t, file): ...@@ -1537,3 +1537,19 @@ def summary(t, file):
file.write(' ' + test + '(' + \ file.write(' ' + test + '(' + \
join(t.unexpected_failures[test],',') + ')\n') join(t.unexpected_failures[test],',') + ')\n')
file.write('\n') file.write('\n')
def getStdout(cmd):
if have_subprocess:
p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
r = p.wait()
if r != 0:
raise Exception("Command failed: " + str(cmd))
if stderr != '':
raise Exception("stderr from command: " + str(cmd))
return stdout
else:
raise Exception("Need subprocess to get stdout, but don't have it")
...@@ -324,8 +324,7 @@ test('shared001', ...@@ -324,8 +324,7 @@ test('shared001',
['$MAKE -s --no-print-directory shared001']) ['$MAKE -s --no-print-directory shared001'])
test('dynHelloWorld', test('dynHelloWorld',
[only_ways(['dyn']), only_ways(['dyn']),
if_platform('i386-unknown-mingw32',expect_broken(3861))],
compile_and_run, compile_and_run,
['']) [''])
......
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