Un-ignore .bat files
[cabal.git] / cabal-testsuite / PackageTests / NewFreeze / Flags / new_freeze.test.hs
blobf05f941b86c4948a3a651f1808355d912b89e522
1 import Test.Cabal.Prelude
2 import Control.Monad.IO.Class
3 import Data.Char
4 import System.Directory
6 -- Test that 'cabal v2-freeze' freezes flag choices. my-local-package depends
7 -- on my-library-dep. my-library-dep has a flag, my-flag, which defaults to
8 -- true.
9 main = cabalTest $
10 withRepo "repo" $ do
11 cabal' "v2-build" ["--dry-run"] >>= assertDependencyFlagChoice True
13 cabal "v2-freeze" ["--constraint=my-library-dep -my-flag"]
15 cwd <- fmap testCurrentDir getTestEnv
16 let freezeFile = cwd </> "cabal.project.freeze"
18 -- The freeze file should constrain the version and the flag.
19 -- TODO: The flag constraint should be qualified. See
20 -- https://github.com/haskell/cabal/issues/5134.
21 assertFileDoesContain freezeFile "any.my-library-dep ==1.0"
22 assertFileDoesContain freezeFile "my-library-dep -my-flag"
24 -- cabal should be able to find an install plan that fits the constraints
25 -- from the freeze file.
26 cabal' "v2-build" ["--dry-run"] >>= assertDependencyFlagChoice False
27 where
28 -- my-library-dep's flag controls whether it depends on true-dep or
29 -- false-dep, so this function uses the dependency to infer the flag choice.
30 assertDependencyFlagChoice True out = do
31 assertOutputContains "true-dep-1.0 (lib)" out
32 assertOutputDoesNotContain "false-dep" out
33 assertDependencyFlagChoice False out = do
34 assertOutputContains "false-dep-1.0 (lib)" out
35 assertOutputDoesNotContain "true-dep" out