From 9fef4c67d56a3edbbbb6a1e9904d31f1e9d3a7df Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Thu, 14 May 2020 20:57:41 +0300 Subject: [PATCH] Resolve #6409: Add public multilib test(s) Also add a test for current behaviour of https://github.com/haskell/cabal/issues/6083 And variant with mixin, for https://github.com/haskell/cabal/issues/6281 The tests are disable for GHC older than 8.8 Should they work? --- .../PackageDescription/Configuration.hs | 7 +----- Cabal/Distribution/Types/DependencyMap.hs | 25 +++++++++---------- Makefile | 2 +- .../Backpack/Includes2/cabal-internal.out | 2 +- .../MultipleLibraries/{ => Failing}/cabal.out | 2 +- .../{ => Failing}/cabal.project | 0 .../{ => Failing}/cabal.test.hs | 0 .../MultipleLibraries/{ => Failing}/d/d.cabal | 0 .../MultipleLibraries/{ => Failing}/p/p.cabal | 0 .../MultipleLibraries/Successful/cabal.out | 14 +++++++++++ .../Successful/cabal.project | 4 +++ .../Successful/cabal.test.hs | 7 ++++++ .../Successful/pkg-abc/Main.hs | 5 ++++ .../Successful/pkg-abc/pkg-abc.cabal | 10 ++++++++ .../Successful/pkg-def/pkg-def.cabal | 17 +++++++++++++ .../Successful/pkg-def/publib/PkgDef.hs | 4 +++ .../Successful/pkg-def/src/PkgDef.hs | 4 +++ .../MultipleLibraries/T6083Pre/cabal.out | 14 +++++++++++ .../MultipleLibraries/T6083Pre/cabal.project | 4 +++ .../MultipleLibraries/T6083Pre/cabal.test.hs | 9 +++++++ .../T6083Pre/pkg-abc/exe/Main.hs | 5 ++++ .../T6083Pre/pkg-abc/pkg-abc.cabal | 19 ++++++++++++++ .../T6083Pre/pkg-abc/pkg-def/PkgDef.hs | 4 +++ .../T6083Pre/pkg-def/pkg-def.cabal | 17 +++++++++++++ .../T6083Pre/pkg-def/publib/PkgDef.hs | 4 +++ .../T6083Pre/pkg-def/src/PkgDef.hs | 4 +++ .../MultipleLibraries/T6083PreMixin/cabal.out | 14 +++++++++++ .../T6083PreMixin/cabal.project | 4 +++ .../T6083PreMixin/cabal.test.hs | 9 +++++++ .../T6083PreMixin/pkg-abc/exe/Main.hs | 5 ++++ .../T6083PreMixin/pkg-abc/pkg-abc.cabal | 20 +++++++++++++++ .../T6083PreMixin/pkg-abc/pkg-def/PkgDef.hs | 4 +++ .../T6083PreMixin/pkg-def/pkg-def.cabal | 17 +++++++++++++ .../T6083PreMixin/pkg-def/publib/PkgDef.hs | 4 +++ .../T6083PreMixin/pkg-def/src/PkgDef.hs | 4 +++ 35 files changed, 242 insertions(+), 22 deletions(-) rename cabal-testsuite/PackageTests/MultipleLibraries/{ => Failing}/cabal.out (94%) rename cabal-testsuite/PackageTests/MultipleLibraries/{ => Failing}/cabal.project (100%) rename cabal-testsuite/PackageTests/MultipleLibraries/{ => Failing}/cabal.test.hs (100%) rename cabal-testsuite/PackageTests/MultipleLibraries/{ => Failing}/d/d.cabal (100%) rename cabal-testsuite/PackageTests/MultipleLibraries/{ => Failing}/p/p.cabal (100%) create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.out create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.project create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.test.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-abc/Main.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-abc/pkg-abc.cabal create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/pkg-def.cabal create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/publib/PkgDef.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/src/PkgDef.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.out create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.project create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.test.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/exe/Main.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/pkg-abc.cabal create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/pkg-def/PkgDef.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/pkg-def.cabal create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/publib/PkgDef.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/src/PkgDef.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.out create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.project create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.test.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/exe/Main.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/pkg-abc.cabal create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/pkg-def/PkgDef.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/pkg-def.cabal create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/publib/PkgDef.hs create mode 100644 cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/src/PkgDef.hs diff --git a/Cabal/Distribution/PackageDescription/Configuration.hs b/Cabal/Distribution/PackageDescription/Configuration.hs index 54600577b8e..f01d05bcfc1 100644 --- a/Cabal/Distribution/PackageDescription/Configuration.hs +++ b/Cabal/Distribution/PackageDescription/Configuration.hs @@ -185,11 +185,6 @@ resolveWithFlags :: resolveWithFlags dom enabled os arch impl constrs trees checkDeps = either (Left . fromDepMapUnion) Right $ explore (build mempty dom) where - extraConstrs = toDepMap - [ Dependency pn ver mainLibSet - | PackageVersionConstraint pn ver <- constrs - ] - -- simplify trees by (partially) evaluating all conditions and converting -- dependencies to dependency maps. simplifiedTrees :: [CondTree FlagName DependencyMap PDTagged] @@ -208,7 +203,7 @@ resolveWithFlags dom enabled os arch impl constrs trees checkDeps = explore (Node flags ts) = let targetSet = TargetSet $ flip map simplifiedTrees $ -- apply additional constraints to all dependencies - first (`constrainBy` extraConstrs) . + first (`constrainBy` constrs) . simplifyCondTree (env flags) deps = overallDependencies enabled targetSet in case checkDeps (fromDepMap deps) of diff --git a/Cabal/Distribution/Types/DependencyMap.hs b/Cabal/Distribution/Types/DependencyMap.hs index 3e89b8ffd04..823857d8e24 100644 --- a/Cabal/Distribution/Types/DependencyMap.hs +++ b/Cabal/Distribution/Types/DependencyMap.hs @@ -5,12 +5,13 @@ module Distribution.Types.DependencyMap ( constrainBy, ) where -import Prelude () import Distribution.Compat.Prelude +import Prelude () import Distribution.Types.Dependency -import Distribution.Types.PackageName import Distribution.Types.LibraryName +import Distribution.Types.PackageName +import Distribution.Types.PackageVersionConstraint import Distribution.Version import qualified Data.Map.Lazy as Map @@ -45,14 +46,12 @@ fromDepMap m = [ Dependency p vr cs | (p,(vr,cs)) <- Map.toList (unDependencyMap -- Combines dependencies where the result will only contain keys from the left -- (first) map. If a key also exists in the right map, both constraints will -- be intersected. -constrainBy :: DependencyMap -- ^ Input map - -> DependencyMap -- ^ Extra constraints - -> DependencyMap -constrainBy left extra = - DependencyMap $ - Map.foldrWithKey tightenConstraint (unDependencyMap left) - (unDependencyMap extra) - where tightenConstraint n c l = - case Map.lookup n l of - Nothing -> l - Just vrcs -> Map.insert n (intersectVersionRangesAndJoinComponents vrcs c) l +constrainBy + :: DependencyMap + -> [PackageVersionConstraint] + -> DependencyMap +constrainBy = foldl' tightenConstraint where + tightenConstraint (DependencyMap l) (PackageVersionConstraint pn vr) = DependencyMap $ + case Map.lookup pn l of + Nothing -> l + Just (vr', cs) -> Map.insert pn (intersectVersionRanges vr' vr, cs) l diff --git a/Makefile b/Makefile index f3c54eb041e..189e53d284e 100644 --- a/Makefile +++ b/Makefile @@ -200,4 +200,4 @@ weeder : # tags .PHONY : tags tags : - hasktags -b Cabal/Distribution Cabal/Cabal-described/src Cabal/Language cabal-install/Distribution + hasktags -b Cabal/Distribution Cabal/Cabal-described/src Cabal/Language cabal-install/Distribution cabal-testsuite/src diff --git a/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out b/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out index 1f7c41475bc..cb4412b3808 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out +++ b/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out @@ -34,7 +34,7 @@ Building library 'mylib' instantiated with Database = Includes2-0.1.0.0-inplace-postgresql:Database.PostgreSQL for Includes2-0.1.0.0.. Configuring library for Includes2-0.1.0.0.. -Warning: The package has an extraneous version range for a dependency on an internal library: Includes2 >=0 && ==0.1.0.0 && ==0.1.0.0 && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used. +Warning: The package has an extraneous version range for a dependency on an internal library: Includes2 ((>=0 && ==0.1.0.0) && ==0.1.0.0) && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used. Preprocessing library for Includes2-0.1.0.0.. Building library for Includes2-0.1.0.0.. Configuring executable 'exe' for Includes2-0.1.0.0.. diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/cabal.out b/cabal-testsuite/PackageTests/MultipleLibraries/Failing/cabal.out similarity index 94% rename from cabal-testsuite/PackageTests/MultipleLibraries/cabal.out rename to cabal-testsuite/PackageTests/MultipleLibraries/Failing/cabal.out index e65ff4bb627..1cb30898b58 100644 --- a/cabal-testsuite/PackageTests/MultipleLibraries/cabal.out +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Failing/cabal.out @@ -11,4 +11,4 @@ Building library 'privatelib' for d-0.1.0.0.. Warning: p.cabal:6:20: colon specifier is experimental feature (issue #5660) Configuring library for p-0.1.0.0.. cabal: Encountered missing or private dependencies: - d:{d, privatelib} ==0.1.0.0 + d:{privatelib} ==0.1.0.0 diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/cabal.project b/cabal-testsuite/PackageTests/MultipleLibraries/Failing/cabal.project similarity index 100% rename from cabal-testsuite/PackageTests/MultipleLibraries/cabal.project rename to cabal-testsuite/PackageTests/MultipleLibraries/Failing/cabal.project diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/cabal.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/Failing/cabal.test.hs similarity index 100% rename from cabal-testsuite/PackageTests/MultipleLibraries/cabal.test.hs rename to cabal-testsuite/PackageTests/MultipleLibraries/Failing/cabal.test.hs diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/d/d.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/Failing/d/d.cabal similarity index 100% rename from cabal-testsuite/PackageTests/MultipleLibraries/d/d.cabal rename to cabal-testsuite/PackageTests/MultipleLibraries/Failing/d/d.cabal diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/p/p.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/Failing/p/p.cabal similarity index 100% rename from cabal-testsuite/PackageTests/MultipleLibraries/p/p.cabal rename to cabal-testsuite/PackageTests/MultipleLibraries/Failing/p/p.cabal diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.out b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.out new file mode 100644 index 00000000000..d40e62c30a2 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.out @@ -0,0 +1,14 @@ +# cabal v2-run +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following will be built: + - pkg-def-0.1.0.0 (lib:publib) (first run) + - pkg-abc-0.1.0.0 (exe:program) (first run) +Warning: pkg-def.cabal:13:27: visibility is experimental feature (issue #5660) +Configuring library 'publib' for pkg-def-0.1.0.0.. +Preprocessing library 'publib' for pkg-def-0.1.0.0.. +Building library 'publib' for pkg-def-0.1.0.0.. +Warning: pkg-abc.cabal:10:15: colon specifier is experimental feature (issue #5660) +Configuring executable 'program' for pkg-abc-0.1.0.0.. +Preprocessing executable 'program' for pkg-abc-0.1.0.0.. +Building executable 'program' for pkg-abc-0.1.0.0.. diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.project b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.project new file mode 100644 index 00000000000..9b5dc06cd42 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.project @@ -0,0 +1,4 @@ +packages: + pkg-abc + pkg-def + diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.test.hs new file mode 100644 index 00000000000..393ca17b51c --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/cabal.test.hs @@ -0,0 +1,7 @@ +import Test.Cabal.Prelude +main = cabalTest $ do + -- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too? + skipIf =<< ghcVersionIs (< mkVersion [8,8]) + + cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-def:publib" + diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-abc/Main.hs b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-abc/Main.hs new file mode 100644 index 00000000000..b9cf6f41954 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-abc/Main.hs @@ -0,0 +1,5 @@ +module Main (main) where +import PkgDef (defValue) + +main :: IO () +main = print defValue diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-abc/pkg-abc.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-abc/pkg-abc.cabal new file mode 100644 index 00000000000..feed99fd047 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-abc/pkg-abc.cabal @@ -0,0 +1,10 @@ +cabal-version: 3.0 +name: pkg-abc +version: 0.1.0.0 + +executable program + default-language: Haskell2010 + main-is: Main.hs + build-depends: + , base + , pkg-def:publib diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/pkg-def.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/pkg-def.cabal new file mode 100644 index 00000000000..a4d95cf4a01 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/pkg-def.cabal @@ -0,0 +1,17 @@ +cabal-version: 3.0 +name: pkg-def +version: 0.1.0.0 + +library + default-language: Haskell2010 + hs-source-dirs: src + build-depends: base + exposed-modules: PkgDef + +library publib + default-language: Haskell2010 + visibility: public + hs-source-dirs: publib + build-depends: base + exposed-modules: PkgDef + diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/publib/PkgDef.hs b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/publib/PkgDef.hs new file mode 100644 index 00000000000..06ad039f434 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/publib/PkgDef.hs @@ -0,0 +1,4 @@ +module PkgDef (defValue) where + +defValue :: String +defValue = "pkg-def:publib" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/src/PkgDef.hs b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/src/PkgDef.hs new file mode 100644 index 00000000000..8c7d547cf70 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/Successful/pkg-def/src/PkgDef.hs @@ -0,0 +1,4 @@ +module PkgDef (defValue) where + +defValue :: String +defValue = "pkg-def:pkg-def" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.out b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.out new file mode 100644 index 00000000000..301fd4eadf1 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.out @@ -0,0 +1,14 @@ +# cabal v2-run +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following will be built: + - pkg-abc-0.1.0.0 (lib:pkg-def) (first run) + - pkg-abc-0.1.0.0 (exe:program) (first run) +Warning: pkg-abc.cabal:19:15: colon specifier is experimental feature (issue #5660) +Configuring library 'pkg-def' for pkg-abc-0.1.0.0.. +Preprocessing library 'pkg-def' for pkg-abc-0.1.0.0.. +Building library 'pkg-def' for pkg-abc-0.1.0.0.. +Warning: pkg-abc.cabal:19:15: colon specifier is experimental feature (issue #5660) +Configuring executable 'program' for pkg-abc-0.1.0.0.. +Preprocessing executable 'program' for pkg-abc-0.1.0.0.. +Building executable 'program' for pkg-abc-0.1.0.0.. diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.project b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.project new file mode 100644 index 00000000000..9b5dc06cd42 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.project @@ -0,0 +1,4 @@ +packages: + pkg-abc + pkg-def + diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.test.hs new file mode 100644 index 00000000000..5819f9cb2ec --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.test.hs @@ -0,0 +1,9 @@ +import Test.Cabal.Prelude + +-- https://github.com/haskell/cabal/issues/6083 +-- see pkg-abc.cabal +main = cabalTest $ do + -- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too? + skipIf =<< ghcVersionIs (< mkVersion [8,8]) + + cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-abc:pkg-def" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/exe/Main.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/exe/Main.hs new file mode 100644 index 00000000000..b9cf6f41954 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/exe/Main.hs @@ -0,0 +1,5 @@ +module Main (main) where +import PkgDef (defValue) + +main :: IO () +main = print defValue diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/pkg-abc.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/pkg-abc.cabal new file mode 100644 index 00000000000..12262b359ef --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/pkg-abc.cabal @@ -0,0 +1,19 @@ +cabal-version: 3.0 +name: pkg-abc +version: 0.1.0.0 + +library pkg-def + default-language: Haskell2010 + hs-source-dirs: pkg-def + build-depends: base + exposed-modules: PkgDef + +executable program + default-language: Haskell2010 + hs-source-dirs: exe + main-is: Main.hs + + -- we want that to resolve to pkg-def main library. + build-depends: + , base + , pkg-def:pkg-def diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/pkg-def/PkgDef.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/pkg-def/PkgDef.hs new file mode 100644 index 00000000000..4379d53caa4 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-abc/pkg-def/PkgDef.hs @@ -0,0 +1,4 @@ +module PkgDef (defValue) where + +defValue :: String +defValue = "pkg-abc:pkg-def" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/pkg-def.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/pkg-def.cabal new file mode 100644 index 00000000000..a4d95cf4a01 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/pkg-def.cabal @@ -0,0 +1,17 @@ +cabal-version: 3.0 +name: pkg-def +version: 0.1.0.0 + +library + default-language: Haskell2010 + hs-source-dirs: src + build-depends: base + exposed-modules: PkgDef + +library publib + default-language: Haskell2010 + visibility: public + hs-source-dirs: publib + build-depends: base + exposed-modules: PkgDef + diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/publib/PkgDef.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/publib/PkgDef.hs new file mode 100644 index 00000000000..06ad039f434 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/publib/PkgDef.hs @@ -0,0 +1,4 @@ +module PkgDef (defValue) where + +defValue :: String +defValue = "pkg-def:publib" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/src/PkgDef.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/src/PkgDef.hs new file mode 100644 index 00000000000..8c7d547cf70 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/pkg-def/src/PkgDef.hs @@ -0,0 +1,4 @@ +module PkgDef (defValue) where + +defValue :: String +defValue = "pkg-def:pkg-def" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.out b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.out new file mode 100644 index 00000000000..a99e51ecea7 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.out @@ -0,0 +1,14 @@ +# cabal v2-run +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following will be built: + - pkg-abc-0.1.0.0 (lib:pkg-def) (first run) + - pkg-abc-0.1.0.0 (exe:program) (first run) +Warning: pkg-abc.cabal:20:15: colon specifier is experimental feature (issue #5660) +Configuring library 'pkg-def' for pkg-abc-0.1.0.0.. +Preprocessing library 'pkg-def' for pkg-abc-0.1.0.0.. +Building library 'pkg-def' for pkg-abc-0.1.0.0.. +Warning: pkg-abc.cabal:20:15: colon specifier is experimental feature (issue #5660) +Configuring executable 'program' for pkg-abc-0.1.0.0.. +Preprocessing executable 'program' for pkg-abc-0.1.0.0.. +Building executable 'program' for pkg-abc-0.1.0.0.. diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.project b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.project new file mode 100644 index 00000000000..9b5dc06cd42 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.project @@ -0,0 +1,4 @@ +packages: + pkg-abc + pkg-def + diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.test.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.test.hs new file mode 100644 index 00000000000..246480accfc --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/cabal.test.hs @@ -0,0 +1,9 @@ +import Test.Cabal.Prelude + +-- This is like T6083Pre, but also goes via mixins +-- +main = cabalTest $ do + -- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too? + skipIf =<< ghcVersionIs (< mkVersion [8,8]) + + cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-abc:pkg-def" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/exe/Main.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/exe/Main.hs new file mode 100644 index 00000000000..8e287385c6b --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/exe/Main.hs @@ -0,0 +1,5 @@ +module Main (main) where +import Mixin (defValue) + +main :: IO () +main = print defValue diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/pkg-abc.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/pkg-abc.cabal new file mode 100644 index 00000000000..e794130bd2e --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/pkg-abc.cabal @@ -0,0 +1,20 @@ +cabal-version: 3.0 +name: pkg-abc +version: 0.1.0.0 + +library pkg-def + default-language: Haskell2010 + hs-source-dirs: pkg-def + build-depends: base + exposed-modules: PkgDef + +executable program + default-language: Haskell2010 + hs-source-dirs: exe + main-is: Main.hs + mixins: pkg-def (PkgDef as Mixin) + + -- we want that to resolve to pkg-def main library. + build-depends: + , base + , pkg-def:pkg-def diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/pkg-def/PkgDef.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/pkg-def/PkgDef.hs new file mode 100644 index 00000000000..4379d53caa4 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-abc/pkg-def/PkgDef.hs @@ -0,0 +1,4 @@ +module PkgDef (defValue) where + +defValue :: String +defValue = "pkg-abc:pkg-def" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/pkg-def.cabal b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/pkg-def.cabal new file mode 100644 index 00000000000..a4d95cf4a01 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/pkg-def.cabal @@ -0,0 +1,17 @@ +cabal-version: 3.0 +name: pkg-def +version: 0.1.0.0 + +library + default-language: Haskell2010 + hs-source-dirs: src + build-depends: base + exposed-modules: PkgDef + +library publib + default-language: Haskell2010 + visibility: public + hs-source-dirs: publib + build-depends: base + exposed-modules: PkgDef + diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/publib/PkgDef.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/publib/PkgDef.hs new file mode 100644 index 00000000000..06ad039f434 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/publib/PkgDef.hs @@ -0,0 +1,4 @@ +module PkgDef (defValue) where + +defValue :: String +defValue = "pkg-def:publib" diff --git a/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/src/PkgDef.hs b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/src/PkgDef.hs new file mode 100644 index 00000000000..8c7d547cf70 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultipleLibraries/T6083PreMixin/pkg-def/src/PkgDef.hs @@ -0,0 +1,4 @@ +module PkgDef (defValue) where + +defValue :: String +defValue = "pkg-def:pkg-def"