summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbindisttest/install3
-rw-r--r--ghc.mk6
-rwxr-xr-xinplace/test3
l---------inplace/test spaces1
-rw-r--r--mk/tree.mk3
-rw-r--r--testsuite/.gitignore2
-rw-r--r--testsuite/mk/boilerplate.mk61
-rw-r--r--testsuite/tests/cabal/Makefile4
8 files changed, 71 insertions, 12 deletions
diff --git a/bindisttest/install b/bindisttest/install
new file mode 100755
index 0000000000..cccdc75d88
--- /dev/null
+++ b/bindisttest/install
@@ -0,0 +1,3 @@
+# See Note [Spaces in TEST_HC].
+echo
+echo 'Possible fix: put quotes around $(TEST_HC) in your Makefile.'
diff --git a/ghc.mk b/ghc.mk
index 595356a93b..bf521b2008 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -1380,8 +1380,10 @@ distclean : clean
# Not sure why this is being cleaned here.
$(call removeTrees,includes/dist-derivedconstants)
-# Finally, clean the inplace tree.
- $(call removeTrees,inplace)
+# Also clean Windows-only inplace directories.
+# Don't delete 'inplace' itself, it contains source files.
+ $(call removeTrees,inplace/mingw)
+ $(call removeTrees,inplace/perl)
maintainer-clean : distclean
$(call removeFiles,configure mk/config.h.in)
diff --git a/inplace/test b/inplace/test
new file mode 100755
index 0000000000..cccdc75d88
--- /dev/null
+++ b/inplace/test
@@ -0,0 +1,3 @@
+# See Note [Spaces in TEST_HC].
+echo
+echo 'Possible fix: put quotes around $(TEST_HC) in your Makefile.'
diff --git a/inplace/test spaces b/inplace/test spaces
new file mode 120000
index 0000000000..c5e82d7458
--- /dev/null
+++ b/inplace/test spaces
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/mk/tree.mk b/mk/tree.mk
index 887e643340..b333e64bef 100644
--- a/mk/tree.mk
+++ b/mk/tree.mk
@@ -27,6 +27,9 @@ INPLACE_PERL = $(INPLACE)/perl
#
################################################################################
+# See Note [Spaces in TEST_HC].
+# Directory contains multiple spaces, to test that multiple spaces aren't
+# getting collapsed into a single space.
BIN_DIST_INST_SUBDIR = "install dir"
BIN_DIST_INST_DIR = bindisttest/$(BIN_DIST_INST_SUBDIR)
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index d9f7dccabd..9c3f91f210 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -57,6 +57,8 @@ tmp.d
*bindisttest_install___dir_bin_ghc.exe.mk
mk/ghcconfig*_bin_ghc*.mk
mk/ghcconfig*_bin_ghc*.exe.mk
+mk/ghcconfig*_test___spaces_ghc*.mk
+mk/ghcconfig*_test___spaces_ghc*.exe.mk
*.imports
# -----------------------------------------------------------------------------
diff --git a/testsuite/mk/boilerplate.mk b/testsuite/mk/boilerplate.mk
index 8872e52fef..055c85659a 100644
--- a/testsuite/mk/boilerplate.mk
+++ b/testsuite/mk/boilerplate.mk
@@ -44,15 +44,59 @@ endef
ifeq "$(TEST_HC)" ""
-STAGE1_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage1)
-STAGE2_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage2)
-STAGE3_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage3)
-
-ifneq "$(wildcard $(STAGE1_GHC) $(STAGE1_GHC).exe)" ""
-
+# Note [Spaces in TEST_HC]
+#
+# Tests should be able to handle paths with spaces.
+#
+# One of the things ./validate (without --fast) does is check if binary
+# distributions can succesfully be installed and used in paths containing
+# spaces.
+#
+# It does so in the following way:
+# * create a binary distribution in 'bindistprep/'.
+# * install that binary distribution in 'bindisttest/install dir/'
+# * run the testsuite with BINDIST=YES
+#
+# BINDIST=YES tells the testsuite driver to use
+# 'bindisttest/install dir/bin/ghc' instead of 'inplace/bin/ghc-stage2' as
+# TEST_HC.
+#
+# Before, if a GHC developer forgot to quote TEST_HC in their Makefile when
+# adding a new test, the test would fail with a puzzling "command not found:
+# bindisttest/install" error (but only when validating).
+#
+# Therefore, we now:
+# * make sure 'bindisttest/install' does exist, and show a nice message when
+# it is executed.
+# * let the default value of TEST_HC also contain spaces
+# (i.e. 'inplace/test spaces/ghc-stage2'), such that the test always
+# fails, also without BINDIST=YES, and again show a nice message when it
+# indeed does so, through 'inplace/test'.
+
+# The `wildcard` function requires spaces to be escaped. Other gnu make
+# functions can't seem to handle spaces at all (e.g. `abspath`).
+STAGE1_TEST_SPACES := $(TOP)/../inplace/test\ \ \ spaces/ghc-stage1
+STAGE1_NORMAL := $(TOP)/../inplace/bin/ghc-stage1
+
+ifneq "$(wildcard $(STAGE1_TEST_SPACES) $(STAGE1_NORMAL))" ""
IMPLICIT_COMPILER = NO
IN_TREE_COMPILER = YES
+
+ifneq "$(wildcard $(STAGE1_TEST_SPACES))" ""
+# See Note [Spaces in TEST_HC].
+STAGE1_GHC := $(abspath $(TOP)/../)/inplace/test spaces/ghc-stage1
+STAGE2_GHC := $(abspath $(TOP)/../)/inplace/test spaces/ghc-stage2
+STAGE3_GHC := $(abspath $(TOP)/../)/inplace/test spaces/ghc-stage3
+else
+# Maybe we're on Windows (no symlink support), or in a bindist or sdist, which
+# don't have the 'test spaces' symlink.
+STAGE1_GHC := $(abspath $(TOP)/../)/inplace/bin/ghc-stage1
+STAGE2_GHC := $(abspath $(TOP)/../)/inplace/bin/ghc-stage2
+STAGE3_GHC := $(abspath $(TOP)/../)/inplace/bin/ghc-stage3
+endif
+
ifeq "$(BINDIST)" "YES"
+# See Note [Spaces in TEST_HC].
TEST_HC := $(abspath $(TOP)/../)/bindisttest/install dir/bin/ghc
else ifeq "$(stage)" "1"
TEST_HC := $(STAGE1_GHC)
@@ -69,7 +113,8 @@ IN_TREE_COMPILER = NO
TEST_HC := $(shell which ghc)
endif
-else
+else # neq "$(TEST_HC)" ""
+
ifeq "$(TEST_HC)" "ghc"
IMPLICIT_COMPILER = YES
else
@@ -95,7 +140,7 @@ override TEST_HC := $(shell which '$(TEST_HC)')
else
override TEST_HC := $(TEST_HC_REALPATH)
endif
-endif
+endif # "$(TEST_HC)" ""
# We can't use $(dir ...) here as TEST_HC might be in a path
# containing spaces
diff --git a/testsuite/tests/cabal/Makefile b/testsuite/tests/cabal/Makefile
index 7644bd8467..635a94b0ea 100644
--- a/testsuite/tests/cabal/Makefile
+++ b/testsuite/tests/cabal/Makefile
@@ -240,9 +240,9 @@ ghcpkg02:
rm -rf $(PACKAGE_CONF_ghcpkg02)
$(GHC_PKG_ghcpkg02) init $(PACKAGE_CONF_ghcpkg02)
set -e; \
- for i in `$(GHC_PKG) list --global --simple-output -v0`; do \
+ for i in `'$(GHC_PKG)' list --global --simple-output -v0`; do \
echo Updating $$i; \
- $(GHC_PKG) describe --global $$i | $(GHC_PKG_ghcpkg02) update --global --force -; \
+ '$(GHC_PKG)' describe --global $$i | $(GHC_PKG_ghcpkg02) update --global --force -; \
done
PKGCONF07=local07.package.conf