summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite/driver/runtests.py2
-rw-r--r--testsuite/driver/testlib.py42
-rw-r--r--testsuite/tests/cabal/cabal01/Makefile2
-rw-r--r--testsuite/tests/ghci/linking/dyn/all.T4
-rw-r--r--testsuite/tests/rename/prog006/Makefile2
5 files changed, 29 insertions, 23 deletions
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index c62c5a76d2..39689c6255 100644
--- a/testsuite/driver/runtests.py
+++ b/testsuite/driver/runtests.py
@@ -276,7 +276,7 @@ else:
# set stdout to unbuffered (is this the best way to do it?)
sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w", 0)
-tempdir = normalise_slashes_(tempfile.mkdtemp('', 'ghctest-'))
+tempdir = tempfile.mkdtemp('', 'ghctest-')
def cleanup_and_exit(exitcode):
if config.cleanup:
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 62f50ff537..2abac3538f 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -546,6 +546,14 @@ def executeSetups(fs, name, opts):
# The current directory of tests
def newTestDir(tempdir, dir):
+ # testdir should be quoted when used, to make sure the testsuite
+ # keeps working when testdir contains backward slashes, for example
+ # from using os.path.join. Windows native and mingw* python set
+ # `os.path.sep = '\\'`, while msys2 python sets `os.path.sep = '/'`.
+ # To catch usage of unquoted testdir early, insert some spaces into
+ # tempdir.
+ tempdir = os.path.join(tempdir, 'test spaces')
+
# Hack. A few tests depend on files in ancestor directories
# (e.g. extra_files(['../../../../libraries/base/dist-install/haddock.t']))
# Make sure tempdir is sufficiently "deep", such that copying/linking those
@@ -564,6 +572,7 @@ def newTestDir(tempdir, dir):
def _newTestDir(name, opts, tempdir, dir):
+ opts.dir = dir
opts.srcdir = os.path.join(os.getcwd(), dir)
opts.testdir = os.path.join(tempdir, dir, name)
opts.compiler_always_flags = config.compiler_always_flags
@@ -710,7 +719,7 @@ def test_common_work (name, opts, func, args):
files = set((f for f in os.listdir(opts.srcdir)
if f.startswith(name)))
for filename in (opts.extra_files + extra_src_files.get(name, [])):
- if filename.startswith('../../../../../'):
+ if filename.startswith('../../../../../../'):
framework_fail(name, 'whole-test',
'add extra level to testlib.py:newTestDir for: ' + filename)
@@ -836,7 +845,7 @@ def do_test(name, way, func, args, files):
try:
preCmd = getTestOpts().pre_cmd
if preCmd != None:
- result = runCmdFor(name, 'cd ' + getTestOpts().testdir + ' && ' + preCmd)
+ result = runCmdFor(name, 'cd "{opts.testdir}" && {preCmd}'.format(**locals()))
if result != 0:
framework_fail(name, way, 'pre-command failed: ' + str(result))
except:
@@ -880,7 +889,7 @@ def do_test(name, way, func, args, files):
else:
if_verbose(1, '*** unexpected failure for %s' % full_name)
t.n_unexpected_failures = t.n_unexpected_failures + 1
- addFailingTestInfo(t.unexpected_failures, getTestOpts().testdir, name, reason, way)
+ addFailingTestInfo(t.unexpected_failures, getTestOpts().dir, name, reason, way)
else:
if getTestOpts().expect == 'missing-lib':
t.n_missing_libs = t.n_missing_libs + 1
@@ -1245,7 +1254,7 @@ def simple_build( name, way, extra_hc_opts, should_fail, top_mod, link, addsuf,
flags = ' '.join(get_compiler_flags(override_flags, noforce) +
config.way_flags(name)[way])
- cmd = ('cd {opts.testdir} && {cmd_prefix} '
+ cmd = ('cd "{opts.testdir}" && {cmd_prefix} '
'{{compiler}} {to_do} {srcname} {flags} {extra_hc_opts} '
'> {errname} 2>&1'
).format(**locals())
@@ -1327,7 +1336,7 @@ def simple_run(name, way, prog, extra_run_opts):
if opts.cmd_wrapper != None:
cmd = opts.cmd_wrapper(cmd) + redirection_append
- cmd = 'cd ' + opts.testdir + ' && ' + cmd
+ cmd = 'cd "{opts.testdir}" && {cmd}'.format(**locals())
# run the command
result = runCmdFor(name, cmd, timeout_multiplier=opts.run_timeout_multiplier)
@@ -1434,7 +1443,7 @@ def interpreter_run( name, way, extra_hc_opts, compile_only, top_mod ):
if getTestOpts().cmd_wrapper != None:
cmd = getTestOpts().cmd_wrapper(cmd) + redirection_append;
- cmd = 'cd ' + getTestOpts().testdir + " && " + cmd
+ cmd = 'cd "{opts.testdir}" && {cmd}'.format(**locals())
result = runCmdFor(name, cmd, timeout_multiplier=opts.run_timeout_multiplier)
@@ -1553,9 +1562,10 @@ def write_file(file, str):
h.close
def check_hp_ok(name):
+ opts = getTestOpts()
# do not qualify for hp2ps because we should be in the right directory
- hp2psCmd = "cd " + getTestOpts().testdir + " && {hp2ps} " + name
+ hp2psCmd = 'cd "{opts.testdir}" && {{hp2ps}} {name}'.format(**locals())
hp2psResult = runCmdExitCode(hp2psCmd)
@@ -1638,14 +1648,14 @@ def compare_outputs(way, kind, normaliser, expected_file, actual_file,
if config.verbose >= 1 and _expect_pass(way):
# See Note [Output comparison].
- r = os.system('diff -uw {0} {1}'.format(expected_normalised_path,
- actual_normalised_path))
+ r = os.system('diff -uw "{0}" "{1}"'.format(expected_normalised_path,
+ actual_normalised_path))
# If for some reason there were no non-whitespace differences,
# then do a full diff
if r == 0:
- r = os.system('diff -u {0} {1}'.format(expected_normalised_path,
- actual_normalised_path))
+ r = os.system('diff -u "{0}" "{1}"'.format(expected_normalised_path,
+ actual_normalised_path))
if config.accept and (getTestOpts().expect == 'fail' or
way in getTestOpts().expect_fail_for):
@@ -1656,7 +1666,7 @@ def compare_outputs(way, kind, normaliser, expected_file, actual_file,
write_file(expected_path, actual_raw)
return 1
elif config.accept:
- if_verbose(1, 'No output. Deleting {0}.'.format(expected_path))
+ if_verbose(1, 'No output. Deleting "{0}".'.format(expected_path))
os.remove(expected_path)
return 1
else:
@@ -1973,17 +1983,13 @@ def in_srcdir(name, suffix=''):
#
def find_expected_file(name, suff):
basename = add_suffix(name, suff)
- basepath = in_srcdir(basename)
files = [basename + ws + plat
for plat in ['-' + config.platform, '-' + config.os, '']
for ws in ['-ws-' + config.wordsize, '']]
- dir = glob.glob(basepath + '*')
- dir = [normalise_slashes_(d) for d in dir]
-
for f in files:
- if in_srcdir(f) in dir:
+ if os.path.exists(in_srcdir(f)):
return f
return basename
@@ -2003,7 +2009,7 @@ def findTFiles(roots):
def findTFiles_(path):
if os.path.isdir(path):
- paths = [path + '/' + x for x in os.listdir(path)]
+ paths = [os.path.join(path, x) for x in os.listdir(path)]
return findTFiles(paths)
elif path[-2:] == '.T':
return [path]
diff --git a/testsuite/tests/cabal/cabal01/Makefile b/testsuite/tests/cabal/cabal01/Makefile
index ff7f130f62..8aff27e2df 100644
--- a/testsuite/tests/cabal/cabal01/Makefile
+++ b/testsuite/tests/cabal/cabal01/Makefile
@@ -28,7 +28,7 @@ cabal01:
# we get a warning if dynlibs are enabled by default that:
# Warning: -rtsopts and -with-rtsopts have no effect with -shared.
# so we filter the flag out
- ./setup configure -v0 --prefix=$(PREFIX) --with-compiler='$(TEST_HC)' --ghc-options='$(filter-out -rtsopts,$(TEST_HC_OPTS))' --with-hc-pkg='$(GHC_PKG)' --package-db=local.db $(VANILLA) $(PROF) $(DYN) --libsubdir='$$pkgid'
+ ./setup configure -v0 --prefix="$(PREFIX)" --with-compiler='$(TEST_HC)' --ghc-options='$(filter-out -rtsopts,$(TEST_HC_OPTS))' --with-hc-pkg='$(GHC_PKG)' --package-db=local.db $(VANILLA) $(PROF) $(DYN) --libsubdir='$$pkgid'
./setup build -v0
./setup copy -v0
echo install1:
diff --git a/testsuite/tests/ghci/linking/dyn/all.T b/testsuite/tests/ghci/linking/dyn/all.T
index b8ef670830..94ebdc9e98 100644
--- a/testsuite/tests/ghci/linking/dyn/all.T
+++ b/testsuite/tests/ghci/linking/dyn/all.T
@@ -8,7 +8,7 @@ test('T1407',
[unless(doing_ghci, skip),
extra_clean(['T1407dir/libAS.*']),
pre_cmd('$MAKE -s --no-print-directory compile_libT1407'),
- extra_hc_opts('-L$PWD/T1407dir')],
+ extra_hc_opts('-L"$PWD/T1407dir"')],
run_command, ['$MAKE --no-print-directory -s T1407'])
test('T3242',
@@ -32,7 +32,7 @@ test('T10458',
[unless(doing_ghci, skip),
extra_clean(['T10458dir/libAS.*']),
pre_cmd('$MAKE -s --no-print-directory compile_libT10458'),
- extra_hc_opts('-L$PWD/T10458dir -lAS')],
+ extra_hc_opts('-L"$PWD/T10458dir" -lAS')],
ghci_script, ['T10458.script'])
test('T11072gcc',
diff --git a/testsuite/tests/rename/prog006/Makefile b/testsuite/tests/rename/prog006/Makefile
index 8d4777d5f0..f7a5f75afe 100644
--- a/testsuite/tests/rename/prog006/Makefile
+++ b/testsuite/tests/rename/prog006/Makefile
@@ -34,7 +34,7 @@ rn.prog006:
echo "version: 1.0" >>pkg.conf
echo "id: test-1.0-XXX" >>pkg.conf
echo "key: test-1.0-XXX" >>pkg.conf
- echo "import-dirs: `./pwd`" >>pkg.conf
+ echo "import-dirs: \"`./pwd`\"" >>pkg.conf
echo "exposed-modules: B.C" >>pkg.conf
rm -rf $(LOCAL_PKGCONF)
'$(GHC_PKG)' init $(LOCAL_PKGCONF)