Share the pwd program between tests
authorIan Lynagh <igloo@earth.li>
Sat, 21 Jul 2007 21:58:16 +0000 (21:58 +0000)
committerIan Lynagh <igloo@earth.li>
Sat, 21 Jul 2007 21:58:16 +0000 (21:58 +0000)
testsuite/Makefile
testsuite/mk/test.mk
testsuite/tests/ghc-regress/rename/prog006/Makefile
testsuite/tests/ghc-regress/rename/prog006/pwd.hs [deleted file]
testsuite/utils/Makefile [new file with mode: 0644]
testsuite/utils/pwd.hs [new file with mode: 0644]

index 9359a3c..39648e7 100644 (file)
@@ -1,7 +1,7 @@
 TOP = .
 include $(TOP)/mk/boilerplate.mk
 
-SUBDIRS = timeout
+SUBDIRS = timeout utils
 
 CLEAN_FILES += mk/wordsize.mk
 
index ec24854..b3e7c10 100644 (file)
@@ -141,7 +141,13 @@ $(TOP)/timeout/timeout$(exeext) :
        @echo "Looks like you don't have timeout, building it first..."
        cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all
 
-test: timeout
+pwd : $(TOP)/utils/pwd$(exeext)
+
+$(TOP)/utils/pwd$(exeext) :
+       @echo "Looks like you don't have pwd, building utils first..."
+       cd $(TOP)/utils && $(MAKE) $(MFLAGS) all
+
+test: timeout pwd
        $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
                $(patsubst %, --only=%, $(TEST)) \
                $(patsubst %, --only=%, $(TESTS)) \
index 3f45f4f..54bf675 100644 (file)
@@ -16,9 +16,8 @@ include $(TOP)/mk/test.mk
 # using the supplied Cabal configuration.
 
 rn.prog006:
-       $(TEST_HC) -v0 pwd.hs -o pwd
        $(TEST_HC) --make -package-name test-1.0 B.C -no-recomp -v0
-       sed "s@__IMPORT__@`./pwd`@" <pkg.conf.in >pkg.conf
+       sed "s@__IMPORT__@`$(TOP)/utils/pwd quadruple-backslash`@" <pkg.conf.in >pkg.conf
        $(TEST_HC) -c -package-conf pkg.conf -package test -no-recomp A.hs -i
 # The -i clears the search path, so A.hs will find B.C from package test
 #
diff --git a/testsuite/tests/ghc-regress/rename/prog006/pwd.hs b/testsuite/tests/ghc-regress/rename/prog006/pwd.hs
deleted file mode 100644 (file)
index f587d08..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-
-module Main where
-
-import System.Directory
-
-main :: IO ()
-main = do d <- getCurrentDirectory
-          putStr $ concatMap escape d
-
--- We have to escape \ twice, once to get through sed and again to get
--- through parsing pkg.conf
-escape :: Char -> String
-escape '\\' = "\\\\\\\\"
-escape c = [c]
-
diff --git a/testsuite/utils/Makefile b/testsuite/utils/Makefile
new file mode 100644 (file)
index 0000000..9255b00
--- /dev/null
@@ -0,0 +1,14 @@
+TOP = ..
+include $(TOP)/mk/boilerplate.mk
+
+HC = $(GHC_INPLACE)
+
+all ::
+       $(HC) --make pwd
+
+clean ::
+       rm -f *.o
+       rm -f *.hi
+       rm -f pwd
+
+include $(TOP)/mk/target.mk
diff --git a/testsuite/utils/pwd.hs b/testsuite/utils/pwd.hs
new file mode 100644 (file)
index 0000000..264cc98
--- /dev/null
@@ -0,0 +1,26 @@
+
+module Main where
+
+import System.Directory
+import System.Environment
+
+main :: IO ()
+main = do args <- getArgs
+          let escape = case args of
+                       ["quadruple-backslash"] -> escape_quadruple_backslash
+                       ["forwardslash"] -> escape_forwardslash
+                       _ -> error ("pwd: Bad args: " ++ show args)
+          d <- getCurrentDirectory
+          putStr $ concatMap escape d
+
+-- In prog006 we have to escape \ twice, once to get through sed and
+-- again to get through parsing pkg.conf
+escape_quadruple_backslash :: Char -> String
+escape_quadruple_backslash '\\' = "\\\\\\\\"
+escape_quadruple_backslash c = [c]
+
+-- Normally we can get away with just replacing backslashes with forwardslashes
+escape_forwardslash :: Char -> String
+escape_forwardslash '\\' = "/"
+escape_forwardslash c = [c]
+