Commit 6a28cc16 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Share the pwd program between tests

parent 5882c76b
TOP = .
include $(TOP)/mk/boilerplate.mk
SUBDIRS = timeout
SUBDIRS = timeout utils
CLEAN_FILES += mk/wordsize.mk
......
......@@ -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)) \
......
......@@ -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
#
......
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]
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
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]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment