Create changelogs for 3.14.1.0 (#10591)
[cabal.git] / cabal-testsuite / PackageTests / ExternalCommand / cabal.test.hs
blobb6a0667899065f1a7cf747a3954d2fbf84353037
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
13 main = do
14 cabalTest $ do
15 res <- cabalWithStdin "v2-build" ["all"] ""
16 exe_path <- withPlan $ planExePath "setup-test" "cabal-aaaa"
17 addToPath (takeDirectory exe_path) $ do
18 -- Test that the thing works at all
19 res <- cabal_raw_action ["aaaa"] (\h -> () <$ Process.waitForProcess h)
20 assertOutputContains "aaaa" res
22 -- Test that the extra arguments are passed on
23 res <- cabal_raw_action ["aaaa", "--foobaz"] (\h -> () <$ Process.waitForProcess h)
24 assertOutputContains "--foobaz" res
26 -- Test what happens with "global" flags
27 res <- cabal_raw_action ["aaaa", "--version"] (\h -> () <$ Process.waitForProcess h)
28 assertOutputContains "--version" res
30 -- Test what happens with "global" flags
31 res <- cabal_raw_action ["aaaa", "--config-file", "abc"] (\h -> () <$ Process.waitForProcess h)
32 assertOutputContains "--config-file" res
35 cabal_raw_action :: [String] -> (Process.ProcessHandle -> IO ()) -> TestM Result
36 cabal_raw_action args action = do
37 configured_prog <- requireProgramM cabalProgram
38 env <- getTestEnv
39 r <- liftIO $ runAction (testVerbosity env)
40 (Just $ testCurrentDir env)
41 (testEnvironment env)
42 (programPath configured_prog)
43 args
44 Nothing
45 action
46 recordLog r
47 requireSuccess r