Skip to content

Commit 71de533

Browse files
committed
Add tests for haskell#9799
Add tests for haskell#9799 about freeze qualifying all packages with 'any' constraint scope.
1 parent aaf16c4 commit 71de533

37 files changed

+171
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for T9799
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{-# LANGUAGE NoImplicitPrelude #-}
2+
main = _
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cabal-version: 3.0
2+
name: T9799
3+
version: 0.1.0.0
4+
license: NONE
5+
build-type: Custom
6+
extra-doc-files: CHANGELOG.md
7+
8+
custom-setup
9+
setup-depends: libA == 0.2.0.0
10+
11+
library
12+
exposed-modules: MyLib
13+
build-depends: libA == 0.1.0.0
14+
hs-source-dirs: src
15+
default-language: Haskell2010
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Test.Cabal.Prelude
2+
main = cabalTest $ do
3+
expectBroken 9799 $ withRepo "repo" $ do
4+
cabal "v2-freeze" []
5+
cwd <- fmap testCurrentDir getTestEnv
6+
-- Guarantee that freeze writes scope-qualified constraints, not 'any'
7+
-- qualified constraints.
8+
assertFileDoesNotContain (cwd </> "cabal.project.freeze") "any.libA"
9+
assertFileDoesContain (cwd </> "cabal.project.freeze") "setup.libA == 0.2.0.0"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for libA0100
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cabal-version: 3.0
2+
name: libA
3+
version: 0.1.0.0
4+
license: NONE
5+
build-type: Simple
6+
extra-doc-files: CHANGELOG.md
7+
8+
library
9+
exposed-modules: MyLib
10+
hs-source-dirs: src
11+
default-language: Haskell2010
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module MyLib (someFunc) where
2+
3+
someFunc :: IO ()
4+
someFunc = putStrLn "someFunc"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for libA0100
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cabal-version: 3.0
2+
name: libA
3+
version: 0.2.0.0
4+
license: NONE
5+
build-type: Simple
6+
extra-doc-files: CHANGELOG.md
7+
8+
library
9+
exposed-modules: MyLib
10+
hs-source-dirs: src
11+
default-language: Haskell2010
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module MyLib (someFunc) where
2+
3+
someFunc :: IO ()
4+
someFunc = putStrLn "someFunc"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module MyLib (someFunc) where
2+
3+
someFunc :: IO ()
4+
someFunc = putStrLn "someFunc"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for T9799
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import MyLib
2+
import Distribution.Simple
3+
main = do
4+
putStrLn $ "Setup: " ++ vers
5+
defaultMain
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cabal-version: 3.0
2+
name: T9799
3+
version: 0.1.0.0
4+
license: NONE
5+
build-type: Custom
6+
extra-doc-files: CHANGELOG.md
7+
8+
custom-setup
9+
setup-depends: libA, base, Cabal
10+
11+
library
12+
exposed-modules: None
13+
build-depends: libA, base, template-haskell
14+
hs-source-dirs: src
15+
default-language: Haskell2010
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Test.Cabal.Prelude
2+
main = cabalTest $ do
3+
expectBroken 9799 $ withRepo "repo" $ do
4+
5+
-- Show how using 'any' qualifiers always with relaxed bounds can violate that
6+
-- cabal freeze --constraint=... && cabal build
7+
-- should be equal to
8+
-- cabal build --constraint=...
9+
--
10+
-- Therefore, the packages in a cabal.project.freeze file must be properly qualified
11+
12+
out1 <- cabal' "v2-build" ["--constraint='setup.libA == 0.1.0.0'"]
13+
assertOutputContains "Setup: libA-0.1.0.0" out1
14+
assertOutputContains "Build: libA-0.2.0.0" out1
15+
16+
cabal "v2-freeze" ["--constraint=setup.libA == 0.1.0.0'"]
17+
out2 <- cabal' "v2-build" []
18+
assertOutputContains "Setup: libA-0.1.0.0" out2
19+
assertOutputContains "Building: libA-0.2.0.0" out2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for libA0100
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cabal-version: 3.0
2+
name: libA
3+
version: 0.1.0.0
4+
license: NONE
5+
build-type: Simple
6+
extra-doc-files: CHANGELOG.md
7+
8+
library
9+
exposed-modules: MyLib
10+
build-depends: base
11+
hs-source-dirs: src
12+
default-language: Haskell2010
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module MyLib where
2+
3+
vers :: String
4+
vers = "libA-0.1.0.0"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for libA0100
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cabal-version: 3.0
2+
name: libA
3+
version: 0.2.0.0
4+
license: NONE
5+
build-type: Simple
6+
extra-doc-files: CHANGELOG.md
7+
8+
library
9+
exposed-modules: MyLib
10+
build-depends: base
11+
hs-source-dirs: src
12+
default-language: Haskell2010
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module MyLib where
2+
3+
renamedVers :: String
4+
renamedVers = "libA-0.2.0.0"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{-# LANGUAGE TemplateHaskell #-}
2+
module None where
3+
4+
import MyLib
5+
import Language.Haskell.TH
6+
7+
$(do
8+
runIO $ putStrLn $ "Building: " ++ renamedVers
9+
[d| x = () |]
10+
)

0 commit comments

Comments
 (0)