Commit ce166a3a authored by thomie's avatar thomie

Testdriver: do not interfer with MinGW path magic (#10449)

This should fix the testsuite driver on Windows using the MinGW tools
with a native build of Python.

MinGW automagically converts MinGW-style paths (e.g.
'/c/programs/ghc/bin/ghc') into ordinary Windows paths (e.g.
'C:/programs/ghc/bin/ghc') when a native Windows program is invoked. But
it doesn't do so when those paths are wrapped with a pair of escaped
double quotes.

The fix is to not call `eval` on the paths in Python, which let's us use
one less pair of quotes, and makes MinGW happy.

Reviewers: Rufflewind, austin

Differential Revision: https://phabricator.haskell.org/D911
parent ef904660
......@@ -40,7 +40,8 @@ config = getConfig() # get it from testglobals
# cmd-line options
long_options = [
"config=", # config file
"configfile=", # config file
"config=", # config field
"rootdir=", # root of tree containing tests (default: .)
"output-summary=", # file in which to save the (human-readable) summary
"only=", # just this test (can be give multiple --only= flags)
......@@ -55,7 +56,7 @@ long_options = [
opts, args = getopt.getopt(sys.argv[1:], "e:", long_options)
for opt,arg in opts:
if opt == '--config':
if opt == '--configfile':
exec(open(arg).read())
# -e is a string to execute from the command line. For example:
......@@ -63,6 +64,10 @@ for opt,arg in opts:
if opt == '-e':
exec(arg)
if opt == '--config':
field, value = arg.split('=', 1)
setattr(config, field, value)
if opt == '--rootdir':
config.rootdirs.append(arg)
......
......@@ -194,7 +194,7 @@ endif
RUNTEST_OPTS += \
--rootdir=. \
--config=$(CONFIG) \
--configfile=$(CONFIG) \
-e 'config.confdir="$(CONFIGDIR)"' \
-e 'config.platform="$(TARGETPLATFORM)"' \
-e 'config.os="$(TargetOS_CPP)"' \
......@@ -205,17 +205,23 @@ RUNTEST_OPTS += \
-e 'config.exeext="$(exeext)"' \
-e 'config.top="$(TOP_ABS)"'
# Put an extra pair of quotes around non-empty program paths,
# so we don't have to in .T scripts or driver/testlib.py.
quote_path = $(if $1,"\"$1\"","")
# Wrap non-empty program paths in quotes, because they may contain spaces. Do
# it here, so we don't have to (and don't forget to do it) in the .T test
# scripts (search for '{compiler}' or '{hpc}'). This may or may not be a good
# idea.
# Use `--config` instead of `-e`, because `-e` (which calls Python's `eval`
# function) would require another pair of (escaped) quotes, which interfers
# with MinGW's magic path handling (see #10449, and
# http://www.mingw.org/wiki/Posix_path_conversion).
quote_path = $(if $1,"$1")
RUNTEST_OPTS += \
-e 'config.compiler=$(call quote_path,$(TEST_HC))' \
-e 'config.ghc_pkg=$(call quote_path,$(GHC_PKG))' \
-e 'config.haddock=$(call quote_path,$(HADDOCK))' \
-e 'config.hp2ps=$(call quote_path,$(HP2PS_ABS))' \
-e 'config.hpc=$(call quote_path,$(HPC))' \
-e 'config.gs=$(call quote_path,$(GS))' \
-e 'config.timeout_prog=$(call quote_path,$(TIMEOUT_PROGRAM))'
--config 'compiler=$(call quote_path,$(TEST_HC))' \
--config 'ghc_pkg=$(call quote_path,$(GHC_PKG))' \
--config 'haddock=$(call quote_path,$(HADDOCK))' \
--config 'hp2ps=$(call quote_path,$(HP2PS_ABS))' \
--config 'hpc=$(call quote_path,$(HPC))' \
--config 'gs=$(call quote_path,$(GS))' \
--config 'timeout_prog=$(call quote_path,$(TIMEOUT_PROGRAM))'
ifneq "$(OUTPUT_SUMMARY)" ""
RUNTEST_OPTS += \
......
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