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

Accumulate environment in 'withEnv'.


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent be218c72
......@@ -193,6 +193,8 @@ getExtraPathEnv env extras = do
return [("PATH", Just path')]
-- | Return the current environment extended with the given overrides.
-- If an entry is specified twice in @overrides@, the second entry takes
-- precedence.
--
getEffectiveEnvironment :: [(String, Maybe String)]
-> NoCallStackIO (Maybe [(String, String)])
......
......@@ -669,14 +669,11 @@ whenGhcVersion p m = do
withPackage :: FilePath -> TestM a -> TestM a
withPackage f = withReaderT (\(suite, test) -> (suite, test { testCurrentPackage = f }))
-- TODO: Really should accumulate... but I think to do this
-- properly we can't just append
-- We append to the environment list, as per 'getEffectiveEnvironment'
-- which prefers the latest override.
withEnv :: [(String, Maybe String)] -> TestM a -> TestM a
withEnv e m = do
(_, test0) <- ask
when (not (null (testEnvironment test0)))
$ error "nested withEnv (not yet) supported"
withReaderT (\(suite, test) -> (suite, test { testEnvironment = e })) m
withReaderT (\(suite, test) -> (suite, test { testEnvironment = testEnvironment test ++ e })) m
withPackageDb :: TestM a -> TestM a
withPackageDb m = do
......
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