Commit 4a0c940b authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Make testPrefixDir non-IO.



Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent accb42f3
......@@ -15,7 +15,7 @@ module Test.Cabal.Monad (
-- * Derived values from 'TestEnv'
testCurrentDir,
testWorkDir,
testPrefixDirIO,
testPrefixDir,
testDistDir,
testPackageDbDir,
-- * Skipping tests
......@@ -264,11 +264,9 @@ testWorkDir :: TestEnv -> FilePath
testWorkDir env =
testSourceDir env </> (testSubName env ++ ".dist")
-- | The prefix where installs go. This lives in the IO monad
-- because, conventionally, absolute paths must be specified
-- when doing installations.
testPrefixDirIO :: MonadIO m => TestEnv -> m FilePath
testPrefixDirIO env = liftIO $ makeAbsolute (testWorkDir env </> "usr")
-- | The absolute prefix where installs go.
testPrefixDir :: TestEnv -> FilePath
testPrefixDir env = testWorkDir env </> "usr"
-- | The absolute path to the build directory that should be used
-- for the current package in a test.
......
......@@ -117,7 +117,6 @@ setup' cmd args = do
env <- getTestEnv
when ((cmd == "register" || cmd == "copy") && not (testHavePackageDb env)) $
error "Cannot register/copy without using 'withPackageDb'"
prefix_dir <- testPrefixDirIO env
ghc_path <- programPathM ghcProgram
let args' = case cmd of
"configure" ->
......@@ -131,7 +130,7 @@ setup' cmd args = do
-- , "--enable-executable-dynamic"
-- , "--disable-optimization"
-- Specify where we want our installed packages to go
, "--prefix=" ++ prefix_dir
, "--prefix=" ++ testPrefixDir env
] ++ packageDBParams (testPackageDBStack env)
++ args
_ -> args
......@@ -342,8 +341,7 @@ runInstalledExe exe_name args = void (runInstalledExe' exe_name args)
runInstalledExe' :: String -> [String] -> TestM Result
runInstalledExe' exe_name args = do
env <- getTestEnv
usr <- testPrefixDirIO env
runM (usr </> "bin" </> exe_name) args
runM (testPrefixDir env </> "bin" </> exe_name) args
-- | Run a shell command in the current directory.
shell :: String -> [String] -> TestM Result
......
Supports Markdown
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