From 2c052b16b98ef15b8f08f6a6beaadca785dc2a56 Mon Sep 17 00:00:00 2001 From: Rodrigo Mesquita Date: Thu, 14 Mar 2024 12:04:57 +0000 Subject: [PATCH] Add tests for #9799 Add tests for #9799 about freeze qualifying all packages with 'any' constraint scope. --- .../PackageTests/NewFreeze/T9799a/Setup.hs | 2 ++ .../PackageTests/NewFreeze/T9799a/T9799.cabal | 14 ++++++++++++ .../NewFreeze/T9799a/cabal.test.hs | 11 ++++++++++ .../T9799a/repo/libA-0.1.0.0/libA.cabal | 10 +++++++++ .../T9799a/repo/libA-0.1.0.0/src/MyLib.hs | 4 ++++ .../T9799a/repo/libA-0.2.0.0/libA.cabal | 10 +++++++++ .../T9799a/repo/libA-0.2.0.0/src/MyLib.hs | 4 ++++ .../NewFreeze/T9799a/src/MyLib.hs | 4 ++++ .../PackageTests/NewFreeze/T9799b/Setup.hs | 5 +++++ .../PackageTests/NewFreeze/T9799b/T9799.cabal | 14 ++++++++++++ .../NewFreeze/T9799b/cabal.test.hs | 22 +++++++++++++++++++ .../T9799b/repo/libA-0.1.0.0/libA.cabal | 11 ++++++++++ .../T9799b/repo/libA-0.1.0.0/src/MyLib.hs | 4 ++++ .../T9799b/repo/libA-0.2.0.0/libA.cabal | 11 ++++++++++ .../T9799b/repo/libA-0.2.0.0/src/MyLib.hs | 4 ++++ .../PackageTests/NewFreeze/T9799b/src/None.hs | 10 +++++++++ 16 files changed, 140 insertions(+) create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799a/Setup.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799a/T9799.cabal create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799a/cabal.test.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.1.0.0/libA.cabal create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.1.0.0/src/MyLib.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.2.0.0/libA.cabal create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.2.0.0/src/MyLib.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799a/src/MyLib.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799b/Setup.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799b/T9799.cabal create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799b/cabal.test.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.1.0.0/libA.cabal create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.1.0.0/src/MyLib.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.2.0.0/libA.cabal create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.2.0.0/src/MyLib.hs create mode 100644 cabal-testsuite/PackageTests/NewFreeze/T9799b/src/None.hs diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799a/Setup.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799a/Setup.hs new file mode 100644 index 00000000000..b051c0c79cf --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799a/Setup.hs @@ -0,0 +1,2 @@ +{-# LANGUAGE NoImplicitPrelude #-} +main = _ diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799a/T9799.cabal b/cabal-testsuite/PackageTests/NewFreeze/T9799a/T9799.cabal new file mode 100644 index 00000000000..5b4c127b749 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799a/T9799.cabal @@ -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 diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799a/cabal.test.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799a/cabal.test.hs new file mode 100644 index 00000000000..b83eb516f86 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799a/cabal.test.hs @@ -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" diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.1.0.0/libA.cabal b/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.1.0.0/libA.cabal new file mode 100644 index 00000000000..a69a937fa44 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.1.0.0/libA.cabal @@ -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 diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.1.0.0/src/MyLib.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.1.0.0/src/MyLib.hs new file mode 100644 index 00000000000..e657c4403f6 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.1.0.0/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.2.0.0/libA.cabal b/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.2.0.0/libA.cabal new file mode 100644 index 00000000000..490cded7241 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.2.0.0/libA.cabal @@ -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 diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.2.0.0/src/MyLib.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.2.0.0/src/MyLib.hs new file mode 100644 index 00000000000..e657c4403f6 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799a/repo/libA-0.2.0.0/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799a/src/MyLib.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799a/src/MyLib.hs new file mode 100644 index 00000000000..e657c4403f6 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799a/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799b/Setup.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799b/Setup.hs new file mode 100644 index 00000000000..25c3e594db8 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799b/Setup.hs @@ -0,0 +1,5 @@ +import MyLib +import Distribution.Simple +main = do + putStrLn $ "Setup: " ++ vers + defaultMain diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799b/T9799.cabal b/cabal-testsuite/PackageTests/NewFreeze/T9799b/T9799.cabal new file mode 100644 index 00000000000..33fa8b143e6 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799b/T9799.cabal @@ -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 diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799b/cabal.test.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799b/cabal.test.hs new file mode 100644 index 00000000000..64cb9a2541a --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799b/cabal.test.hs @@ -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 diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.1.0.0/libA.cabal b/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.1.0.0/libA.cabal new file mode 100644 index 00000000000..e6485eb23ef --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.1.0.0/libA.cabal @@ -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 diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.1.0.0/src/MyLib.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.1.0.0/src/MyLib.hs new file mode 100644 index 00000000000..bef50f2bb00 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.1.0.0/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib where + +vers :: String +vers = "libA-0.1.0.0" diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.2.0.0/libA.cabal b/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.2.0.0/libA.cabal new file mode 100644 index 00000000000..90f595b7215 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.2.0.0/libA.cabal @@ -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 diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.2.0.0/src/MyLib.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.2.0.0/src/MyLib.hs new file mode 100644 index 00000000000..0ff3e21284d --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799b/repo/libA-0.2.0.0/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib where + +renamedVers :: String +renamedVers = "libA-0.2.0.0" diff --git a/cabal-testsuite/PackageTests/NewFreeze/T9799b/src/None.hs b/cabal-testsuite/PackageTests/NewFreeze/T9799b/src/None.hs new file mode 100644 index 00000000000..f4c629a9329 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewFreeze/T9799b/src/None.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TemplateHaskell #-} +module None where + +import MyLib +import Language.Haskell.TH + +$(do + runIO $ putStrLn $ "Building: " ++ renamedVers + [d| x = () |] + )