Add “Ignore warning” option to cabal check
[cabal.git] / cabal-testsuite / PackageTests / ExternalCommand / cabal.test.hs
blobd9535b60507a0f86a7cf1a194fd33d10235c8989
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