Un-ignore .bat files
[cabal.git] / cabal-testsuite / PackageTests / ExternalCommandExitCode / cabal.test.hs
blob7fc79d75815d73e710ce441e37d147ec776f62e9
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
11 import System.FilePath
12 import System.Exit
14 main = do
15 cabalTest $ do
16 res <- cabalWithStdin "v2-build" ["all"] ""
17 exe_path <- withPlan $ planExePath "setup-test" "cabal-aaaa"
18 addToPath (takeDirectory exe_path) $ do
19 -- Test that the thing works at all
20 res <- fails $ cabal_raw_action ["aaaa"] (\h -> () <$ Process.waitForProcess h)
21 assertOutputContains "aaaa" res
22 -- Check the exit code is the one returned by subcommand
23 unless (resultExitCode res == ExitFailure 99) (assertFailure $ "Incorrect exit code: " ++ show (resultExitCode res))
26 cabal_raw_action :: [String] -> (Process.ProcessHandle -> IO ()) -> TestM Result
27 cabal_raw_action args action = do
28 configured_prog <- requireProgramM cabalProgram
29 env <- getTestEnv
30 r <- liftIO $ runAction (testVerbosity env)
31 (Just $ testCurrentDir env)
32 (testEnvironment env)
33 (programPath configured_prog)
34 args
35 Nothing
36 action
37 recordLog r
38 requireSuccess r