(cabal check) Add "No internal name clash" test
[cabal.git] / cabal-testsuite / PackageTests / NewFreeze / FreezeFile / new_freeze.test.hs
blob912649bba8c43cee66ed278069abf49473f7895d
1 import Test.Cabal.Prelude
2 import Control.Monad.IO.Class
3 import Data.Char
4 import System.Directory
6 -- Test for 'cabal v2-freeze' with only a single library dependency.
7 -- my-local-package depends on my-library-dep, which has versions 1.0 and 2.0.
8 main = withShorterPathForNewBuildStore $ \storeDir ->
9 cabalTest $ withSourceCopy $
10 withRepo "repo" $ do
11 cwd <- fmap testCurrentDir getTestEnv
12 let freezeFile = cwd </> "cabal.project.freeze"
14 shouldNotExist freezeFile
16 -- v2-build should choose the latest version for the dependency.
17 cabalG' ["--store-dir=" ++ storeDir] "v2-build" ["--dry-run"] >>= assertUsesLatestDependency
19 -- should not create freeze file with --dry-run or --only-download flags
20 cabalG' ["--store-dir=" ++ storeDir] "v2-freeze" ["--dry-run"]
21 cabalG' ["--store-dir=" ++ storeDir] "v2-freeze" ["--only-download"]
22 shouldNotExist freezeFile
24 -- Freeze a dependency on the older version.
25 cabalG ["--store-dir=" ++ storeDir] "v2-freeze" ["--constraint=my-library-dep==1.0"]
27 -- The file should constrain the dependency, but not the local package.
28 shouldExist freezeFile
29 assertFileDoesContain freezeFile "any.my-library-dep ==1.0"
30 assertFileDoesNotContain freezeFile "my-local-package"
32 -- cabal should be able to build the package using the constraint from the
33 -- freeze file.
34 cabalG' ["--store-dir=" ++ storeDir] "v2-build" [] >>= assertDoesNotUseLatestDependency
36 -- Re-running v2-freeze should not change the constraints, because cabal
37 -- should use the existing freeze file when choosing the new install plan.
38 cabalG ["--store-dir=" ++ storeDir] "v2-freeze" []
39 assertFileDoesContain freezeFile "any.my-library-dep ==1.0"
41 -- cabal should choose the latest version again after the freeze file is
42 -- removed.
43 liftIO $ removeFile freezeFile
44 cabalG' ["--store-dir=" ++ storeDir] "v2-build" ["--dry-run"] >>= assertUsesLatestDependency
46 -- Re-running v2-freeze with no constraints or freeze file should constrain
47 -- the dependency to the latest version.
48 cabalG ["--store-dir=" ++ storeDir] "v2-freeze" []
49 assertFileDoesContain freezeFile "any.my-library-dep ==2.0"
50 assertFileDoesNotContain freezeFile "my-local-package"
51 where
52 assertUsesLatestDependency out = do
53 assertOutputContains "my-library-dep-2.0 (lib)" out
54 assertOutputDoesNotContain "my-library-dep-1.0" out
56 assertDoesNotUseLatestDependency out = do
57 assertOutputContains "my-library-dep-1.0 (lib)" out
58 assertOutputDoesNotContain "my-library-dep-2.0" out