Add test cases that reproduce #7241.
[cabal.git] / cabal-testsuite / PackageTests / ExternalCommandEnv / cabal.test.hs
blob4344076398a93202ba1558ef2b03aadf9cc2427a
1 import Test.Cabal.Prelude
2 import qualified System.Process as Process
3 import Control.Concurrent (threadDelay)
4 import System.Directory (removeFile)
5 import Control.Exception (catch, throwIO)
6 import System.IO.Error (isDoesNotExistError)
7 import qualified Data.Time.Clock as Time
8 import qualified Data.Time.Format as Time
9 import Data.Maybe
10 import System.Environment
12 main = do
13 cabalTest $ do
14 res <- cabalWithStdin "v2-build" ["all"] ""
15 exe_path <- withPlan $ planExePath "setup-test" "cabal-aaaa"
16 env <- getTestEnv
17 let new_env = (("OTHER_VAR", Just "is set") : (testEnvironment env))
18 withEnv new_env $ addToPath (takeDirectory exe_path) $ do
19 res <- cabal_raw_action ["aaaa"] (\h -> () <$ Process.waitForProcess h)
20 assertOutputContains "cabal-install" res
21 assertOutputContains "is set" res
24 cabal_raw_action :: [String] -> (Process.ProcessHandle -> IO ()) -> TestM Result
25 cabal_raw_action args action = do
26 configured_prog <- requireProgramM cabalProgram
27 env <- getTestEnv
28 r <- liftIO $ runAction (testVerbosity env)
29 (Just (testCurrentDir env))
30 (testEnvironment env)
31 (programPath configured_prog)
32 args
33 Nothing
34 action
35 recordLog r
36 requireSuccess r