[commit: ghc] master: Testsuite: suggest quoting $(TEST_HC) (59e728b)

git at git.haskell.org git at git.haskell.org
Fri Oct 30 19:45:39 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/59e728bc0b47116e3c9a8b21b14dc3198531b9a9/ghc

>---------------------------------------------------------------

commit 59e728bc0b47116e3c9a8b21b14dc3198531b9a9
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Fri Oct 30 20:22:24 2015 +0100

    Testsuite: suggest quoting $(TEST_HC)
    
    Test Plan: it works
    
    Reviewers: bgamari, rwbarton, austin
    
    Reviewed By: austin
    
    Subscribers: rwbarton
    
    Differential Revision: https://phabricator.haskell.org/D1377


>---------------------------------------------------------------

59e728bc0b47116e3c9a8b21b14dc3198531b9a9
 bindisttest/install            |  3 +++
 ghc.mk                         |  6 +++--
 inplace/test                   |  3 +++
 inplace/test   spaces          |  1 +
 mk/tree.mk                     |  3 +++
 testsuite/.gitignore           |  2 ++
 testsuite/mk/boilerplate.mk    | 61 ++++++++++++++++++++++++++++++++++++------
 testsuite/tests/cabal/Makefile |  4 +--
 8 files changed, 71 insertions(+), 12 deletions(-)

diff --git a/bindisttest/install b/bindisttest/install
new file mode 100755
index 0000000..cccdc75
--- /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 595356a..bf521b2 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 0000000..cccdc75
--- /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 0000000..c5e82d7
--- /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 887e643..b333e64 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 d9f7dcc..9c3f91f 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 8872e52..055c856 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 7644bd8..635a94b 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



More information about the ghc-commits mailing list