[commit: ghc] master: Testsuite: allow spaces in TEST_HC passed in by the user (272e1cc)

git at git.haskell.org git at git.haskell.org
Thu Dec 17 20:25:35 UTC 2015


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/272e1cc811e5d693d8a36e63c90a1ece68a0495a/ghc

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

commit 272e1cc811e5d693d8a36e63c90a1ece68a0495a
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Wed Oct 28 10:35:08 2015 +0100

    Testsuite: allow spaces in TEST_HC passed in by the user
    
    Don't use the GNU make function 'realpath' (reverting e66a81c6),
    because it doesn't handle spaces in paths. Instead, use 'cygpath' to
    convert Windows style paths (e.g. C:/foo/) to mingw style paths (e.g.
    c/foo/), and then call 'which'.
    
    Tests:
     * make TEST_HC=ghc
     * make TEST_HC=/d/home/thomie/ghc-validate/bindisttest/install\ \ \ dir/bin/ghc
     * make TEST_HC=D:/home/thomie/ghc-validate/bindisttest/install\ \ \ dir/bin/ghc
    
    Reviewed by: Phyx
    
    Differential Revision: https://phabricator.haskell.org/D1431


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

272e1cc811e5d693d8a36e63c90a1ece68a0495a
 testsuite/mk/boilerplate.mk | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/testsuite/mk/boilerplate.mk b/testsuite/mk/boilerplate.mk
index 3039879..5f4a3e9 100644
--- a/testsuite/mk/boilerplate.mk
+++ b/testsuite/mk/boilerplate.mk
@@ -24,7 +24,9 @@ show:
 
 define canonicalise
 # $1 = path variable
-$1_CYGPATH := $$(shell $(SHELL) -c "cygpath -m '$$($1)'" 2> /dev/null)
+# Don't use 'cygpath -m', because it doesn't change drive letters to
+# something 'which' can understand.
+$1_CYGPATH := $$(shell $(SHELL) -c "cygpath '$$($1)'" 2> /dev/null)
 ifneq "$$($1_CYGPATH)" ""
 # We use 'override' in case we are trying to update a value given on
 # the commandline (e.g. TEST_HC)
@@ -121,25 +123,19 @@ else
 IMPLICIT_COMPILER = NO
 endif
 IN_TREE_COMPILER = NO
-# We want to support both "ghc" and "/usr/bin/ghc" as values of TEST_HC
-# passed in by the user, but
-#     which ghc          == /usr/bin/ghc
-#     which /usr/bin/ghc == /usr/bin/ghc
-# so on unix-like platforms we can just always 'which' it.
-# However, on cygwin, we can't just use which:
-#     $ which c:/ghc/ghc-7.4.1/bin/ghc.exe
-#     which: no ghc.exe in (./c:/ghc/ghc-7.4.1/bin)
-# so we start off by using realpath, and if that succeeds then we use
-# that value. Otherwise we fall back on 'which'.
-#
+
+# As values of TEST_HC passed in by the user, we want to support:
+#  * both "ghc" and "/usr/bin/ghc"
+#      We use 'which' to convert the former to the latter.
+#  * both "C:/path/to/ghc.exe" and "/c/path/to/ghc.exe"
+#      We use 'cygpath' to convert the former to the latter, because
+#      'which' can't handle paths starting with a drive letter.
+#  * paths that contain spaces
+#      So we can't use the GNU make function 'realpath'.
 # Note also that we need to use 'override' in order to override a
 # value given on the commandline.
-TEST_HC_REALPATH := $(realpath $(TEST_HC))
-ifeq "$(TEST_HC_REALPATH)" ""
+$(eval $(call canonicaliseExecutable,TEST_HC))
 override TEST_HC := $(shell which '$(TEST_HC)')
-else
-override TEST_HC := $(TEST_HC_REALPATH)
-endif
 endif # "$(TEST_HC)" ""
 
 # We can't use $(dir ...) here as TEST_HC might be in a path



More information about the ghc-commits mailing list