Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for #9799 #9805

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/NewFreeze/T9799a/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{-# LANGUAGE NoImplicitPrelude #-}
main = _
14 changes: 14 additions & 0 deletions cabal-testsuite/PackageTests/NewFreeze/T9799a/T9799.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cabal-version: 3.0
name: T9799
version: 0.1.0.0
license: NONE
build-type: Custom

custom-setup
setup-depends: libA == 0.2.0.0

library
exposed-modules: MyLib
build-depends: libA == 0.1.0.0
hs-source-dirs: src
default-language: Haskell2010
11 changes: 11 additions & 0 deletions cabal-testsuite/PackageTests/NewFreeze/T9799a/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Test.Cabal.Prelude
main = cabalTest $ do
withRepo "repo" $ do
cabal "v2-freeze" []
cwd <- fmap testCurrentDir getTestEnv
-- Guarantee that freeze writes scope-qualified constraints, not 'any'
-- qualified constraints.
expectBroken 9799 $ do
assertFileDoesNotContain (cwd </> "cabal.project.freeze") "any.libA"
assertFileDoesContain (cwd </> "cabal.project.freeze") "libA == 0.1.0.0"
assertFileDoesContain (cwd </> "cabal.project.freeze") "setup.libA == 0.2.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cabal-version: 3.0
name: libA
version: 0.1.0.0
license: NONE
build-type: Simple

library
exposed-modules: MyLib
hs-source-dirs: src
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cabal-version: 3.0
name: libA
version: 0.2.0.0
license: NONE
build-type: Simple

library
exposed-modules: MyLib
hs-source-dirs: src
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/NewFreeze/T9799a/src/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
5 changes: 5 additions & 0 deletions cabal-testsuite/PackageTests/NewFreeze/T9799b/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import MyLib
import Distribution.Simple
main = do
putStrLn $ "Setup: " ++ vers
defaultMain
14 changes: 14 additions & 0 deletions cabal-testsuite/PackageTests/NewFreeze/T9799b/T9799.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cabal-version: 3.0
name: T9799
version: 0.1.0.0
license: NONE
build-type: Custom

custom-setup
setup-depends: libA, base, Cabal

library
exposed-modules: None
build-depends: libA, base, template-haskell
hs-source-dirs: src
default-language: Haskell2010
22 changes: 22 additions & 0 deletions cabal-testsuite/PackageTests/NewFreeze/T9799b/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Test.Cabal.Prelude
main = cabalTest $ do
withRepo "repo" $ do

-- Show how using 'any' qualifiers always with relaxed bounds can violate that
-- cabal freeze --constraint=... && cabal build
-- should be equal to
-- cabal build --constraint=...
--
-- Therefore, the packages in a cabal.project.freeze file must be properly qualified

out1 <- cabal' "v2-build" ["--constraint=setup.libA == 0.1.0.0"]
assertOutputContains "Setup: libA-0.1.0.0" out1
assertOutputContains "Building: libA-0.2.0.0" out1

cabal "v2-freeze" ["--constraint=setup.libA == 0.1.0.0"]

expectBroken 9799 $ do -- fails when building
out2 <- cabal' "v2-build" []
-- After #9799 is fixed, these two lines should be changed to `assertOutputContains`
assertOutputDoesNotContain "Setup: libA-0.1.0.0" out2
assertOutputDoesNotContain "Building: libA-0.2.0.0" out2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cabal-version: 3.0
name: libA
version: 0.1.0.0
license: NONE
build-type: Simple

library
exposed-modules: MyLib
build-depends: base
hs-source-dirs: src
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib where

vers :: String
vers = "libA-0.1.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cabal-version: 3.0
name: libA
version: 0.2.0.0
license: NONE
build-type: Simple

library
exposed-modules: MyLib
build-depends: base
hs-source-dirs: src
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib where

renamedVers :: String
renamedVers = "libA-0.2.0.0"
10 changes: 10 additions & 0 deletions cabal-testsuite/PackageTests/NewFreeze/T9799b/src/None.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE TemplateHaskell #-}
module None where

import MyLib
import Language.Haskell.TH

$(do
runIO $ putStrLn $ "Building: " ++ renamedVers
[d| x = () |]
)
Loading