1 import Test
.Cabal
.Prelude
2 import Control
.Monad
.IO.Class
3 import System
.Directory
5 -- Test that 'cabal v2-freeze' works with multiple versions of a build tool
8 -- The repository contains versions 1.0, 2.0, and 3.0 of the build tool. There
9 -- is one local package, which requires >= 2, and a library dependency of the
10 -- local package, which requires < 2, so cabal should pick versions 1.0 and 3.0
11 -- of the build tool when there are no constraints.
12 main
= cabalTest
$ withSourceCopy
$ do
14 cabal
' "v2-build" ["--dry-run"] >>= assertUsesLatestBuildTool
16 -- Force the project to use versions 1.0 and 2.0 of the build tool.
17 cabal
"v2-freeze" ["--constraint=any.my-build-tool-dep < 3"]
19 cwd
<- fmap testCurrentDir getTestEnv
20 let freezeFile
= cwd
</> "cabal.project.freeze"
22 -- The freeze file should specify a version range that includes both
23 -- versions of the build tool from the install plan. (This constraint will
24 -- be replaced with two exe qualified constraints once #3502 is fully
26 assertFileDoesContain freezeFile
"any.my-build-tool-dep ==1.0 || ==2.0"
28 -- The library dependency should have a constraint on an exact version.
29 assertFileDoesContain freezeFile
"any.my-library-dep ==1.0"
31 -- The local package should be unconstrained.
32 assertFileDoesNotContain freezeFile
"my-local-package"
34 -- cabal should be able to find an install plan that fits the constraints
35 -- from the freeze file.
36 cabal
' "v2-build" ["--dry-run"] >>= assertDoesNotUseLatestBuildTool
38 assertUsesLatestBuildTool out
= do
39 assertOutputContains
"my-build-tool-dep-3.0 (exe:my-build-tool)" out
40 assertOutputDoesNotContain
"my-build-tool-dep-2.0" out
42 assertDoesNotUseLatestBuildTool out
= do
43 assertOutputContains
"my-build-tool-dep-2.0 (exe:my-build-tool)" out
44 assertOutputDoesNotContain
"my-build-tool-dep-3.0" out