Skip to content

Commit d220810

Browse files
authoredMay 15, 2020
Merge pull request #6802 from phadej/multilib-test
Resolve #6409: Add public multilib test(s)
2 parents b4a6090 + 9fef4c6 commit d220810

File tree

35 files changed

+242
-22
lines changed

35 files changed

+242
-22
lines changed
 

‎Cabal/Distribution/PackageDescription/Configuration.hs

+1-6
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ resolveWithFlags ::
185185
resolveWithFlags dom enabled os arch impl constrs trees checkDeps =
186186
either (Left . fromDepMapUnion) Right $ explore (build mempty dom)
187187
where
188-
extraConstrs = toDepMap
189-
[ Dependency pn ver mainLibSet
190-
| PackageVersionConstraint pn ver <- constrs
191-
]
192-
193188
-- simplify trees by (partially) evaluating all conditions and converting
194189
-- dependencies to dependency maps.
195190
simplifiedTrees :: [CondTree FlagName DependencyMap PDTagged]
@@ -208,7 +203,7 @@ resolveWithFlags dom enabled os arch impl constrs trees checkDeps =
208203
explore (Node flags ts) =
209204
let targetSet = TargetSet $ flip map simplifiedTrees $
210205
-- apply additional constraints to all dependencies
211-
first (`constrainBy` extraConstrs) .
206+
first (`constrainBy` constrs) .
212207
simplifyCondTree (env flags)
213208
deps = overallDependencies enabled targetSet
214209
in case checkDeps (fromDepMap deps) of

‎Cabal/Distribution/Types/DependencyMap.hs

+12-13
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ module Distribution.Types.DependencyMap (
55
constrainBy,
66
) where
77

8-
import Prelude ()
98
import Distribution.Compat.Prelude
9+
import Prelude ()
1010

1111
import Distribution.Types.Dependency
12-
import Distribution.Types.PackageName
1312
import Distribution.Types.LibraryName
13+
import Distribution.Types.PackageName
14+
import Distribution.Types.PackageVersionConstraint
1415
import Distribution.Version
1516

1617
import qualified Data.Map.Lazy as Map
@@ -45,14 +46,12 @@ fromDepMap m = [ Dependency p vr cs | (p,(vr,cs)) <- Map.toList (unDependencyMap
4546
-- Combines dependencies where the result will only contain keys from the left
4647
-- (first) map. If a key also exists in the right map, both constraints will
4748
-- be intersected.
48-
constrainBy :: DependencyMap -- ^ Input map
49-
-> DependencyMap -- ^ Extra constraints
50-
-> DependencyMap
51-
constrainBy left extra =
52-
DependencyMap $
53-
Map.foldrWithKey tightenConstraint (unDependencyMap left)
54-
(unDependencyMap extra)
55-
where tightenConstraint n c l =
56-
case Map.lookup n l of
57-
Nothing -> l
58-
Just vrcs -> Map.insert n (intersectVersionRangesAndJoinComponents vrcs c) l
49+
constrainBy
50+
:: DependencyMap
51+
-> [PackageVersionConstraint]
52+
-> DependencyMap
53+
constrainBy = foldl' tightenConstraint where
54+
tightenConstraint (DependencyMap l) (PackageVersionConstraint pn vr) = DependencyMap $
55+
case Map.lookup pn l of
56+
Nothing -> l
57+
Just (vr', cs) -> Map.insert pn (intersectVersionRanges vr' vr, cs) l

‎Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,4 @@ weeder :
200200
# tags
201201
.PHONY : tags
202202
tags :
203-
hasktags -b Cabal/Distribution Cabal/Cabal-described/src Cabal/Language cabal-install/Distribution
203+
hasktags -b Cabal/Distribution Cabal/Cabal-described/src Cabal/Language cabal-install/Distribution cabal-testsuite/src

‎cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Building library 'mylib' instantiated with
3434
Database = Includes2-0.1.0.0-inplace-postgresql:Database.PostgreSQL
3535
for Includes2-0.1.0.0..
3636
Configuring library for Includes2-0.1.0.0..
37-
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.
37+
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.
3838
Preprocessing library for Includes2-0.1.0.0..
3939
Building library for Includes2-0.1.0.0..
4040
Configuring executable 'exe' for Includes2-0.1.0.0..

‎cabal-testsuite/PackageTests/MultipleLibraries/cabal.out ‎cabal-testsuite/PackageTests/MultipleLibraries/Failing/cabal.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ Building library 'privatelib' for d-0.1.0.0..
1111
Warning: p.cabal:6:20: colon specifier is experimental feature (issue #5660)
1212
Configuring library for p-0.1.0.0..
1313
cabal: Encountered missing or private dependencies:
14-
d:{d, privatelib} ==0.1.0.0
14+
d:{privatelib} ==0.1.0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# cabal v2-run
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- pkg-def-0.1.0.0 (lib:publib) (first run)
6+
- pkg-abc-0.1.0.0 (exe:program) (first run)
7+
Warning: pkg-def.cabal:13:27: visibility is experimental feature (issue #5660)
8+
Configuring library 'publib' for pkg-def-0.1.0.0..
9+
Preprocessing library 'publib' for pkg-def-0.1.0.0..
10+
Building library 'publib' for pkg-def-0.1.0.0..
11+
Warning: pkg-abc.cabal:10:15: colon specifier is experimental feature (issue #5660)
12+
Configuring executable 'program' for pkg-abc-0.1.0.0..
13+
Preprocessing executable 'program' for pkg-abc-0.1.0.0..
14+
Building executable 'program' for pkg-abc-0.1.0.0..
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
packages:
2+
pkg-abc
3+
pkg-def
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Test.Cabal.Prelude
2+
main = cabalTest $ do
3+
-- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too?
4+
skipIf =<< ghcVersionIs (< mkVersion [8,8])
5+
6+
cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-def:publib"
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main (main) where
2+
import PkgDef (defValue)
3+
4+
main :: IO ()
5+
main = print defValue
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cabal-version: 3.0
2+
name: pkg-abc
3+
version: 0.1.0.0
4+
5+
executable program
6+
default-language: Haskell2010
7+
main-is: Main.hs
8+
build-depends:
9+
, base
10+
, pkg-def:publib
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cabal-version: 3.0
2+
name: pkg-def
3+
version: 0.1.0.0
4+
5+
library
6+
default-language: Haskell2010
7+
hs-source-dirs: src
8+
build-depends: base
9+
exposed-modules: PkgDef
10+
11+
library publib
12+
default-language: Haskell2010
13+
visibility: public
14+
hs-source-dirs: publib
15+
build-depends: base
16+
exposed-modules: PkgDef
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module PkgDef (defValue) where
2+
3+
defValue :: String
4+
defValue = "pkg-def:publib"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module PkgDef (defValue) where
2+
3+
defValue :: String
4+
defValue = "pkg-def:pkg-def"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# cabal v2-run
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- pkg-abc-0.1.0.0 (lib:pkg-def) (first run)
6+
- pkg-abc-0.1.0.0 (exe:program) (first run)
7+
Warning: pkg-abc.cabal:19:15: colon specifier is experimental feature (issue #5660)
8+
Configuring library 'pkg-def' for pkg-abc-0.1.0.0..
9+
Preprocessing library 'pkg-def' for pkg-abc-0.1.0.0..
10+
Building library 'pkg-def' for pkg-abc-0.1.0.0..
11+
Warning: pkg-abc.cabal:19:15: colon specifier is experimental feature (issue #5660)
12+
Configuring executable 'program' for pkg-abc-0.1.0.0..
13+
Preprocessing executable 'program' for pkg-abc-0.1.0.0..
14+
Building executable 'program' for pkg-abc-0.1.0.0..
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
packages:
2+
pkg-abc
3+
pkg-def
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Test.Cabal.Prelude
2+
3+
-- https://github.com/haskell/cabal/issues/6083
4+
-- see pkg-abc.cabal
5+
main = cabalTest $ do
6+
-- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too?
7+
skipIf =<< ghcVersionIs (< mkVersion [8,8])
8+
9+
cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-abc:pkg-def"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main (main) where
2+
import PkgDef (defValue)
3+
4+
main :: IO ()
5+
main = print defValue
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cabal-version: 3.0
2+
name: pkg-abc
3+
version: 0.1.0.0
4+
5+
library pkg-def
6+
default-language: Haskell2010
7+
hs-source-dirs: pkg-def
8+
build-depends: base
9+
exposed-modules: PkgDef
10+
11+
executable program
12+
default-language: Haskell2010
13+
hs-source-dirs: exe
14+
main-is: Main.hs
15+
16+
-- we want that to resolve to pkg-def main library.
17+
build-depends:
18+
, base
19+
, pkg-def:pkg-def
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module PkgDef (defValue) where
2+
3+
defValue :: String
4+
defValue = "pkg-abc:pkg-def"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cabal-version: 3.0
2+
name: pkg-def
3+
version: 0.1.0.0
4+
5+
library
6+
default-language: Haskell2010
7+
hs-source-dirs: src
8+
build-depends: base
9+
exposed-modules: PkgDef
10+
11+
library publib
12+
default-language: Haskell2010
13+
visibility: public
14+
hs-source-dirs: publib
15+
build-depends: base
16+
exposed-modules: PkgDef
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module PkgDef (defValue) where
2+
3+
defValue :: String
4+
defValue = "pkg-def:publib"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module PkgDef (defValue) where
2+
3+
defValue :: String
4+
defValue = "pkg-def:pkg-def"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# cabal v2-run
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- pkg-abc-0.1.0.0 (lib:pkg-def) (first run)
6+
- pkg-abc-0.1.0.0 (exe:program) (first run)
7+
Warning: pkg-abc.cabal:20:15: colon specifier is experimental feature (issue #5660)
8+
Configuring library 'pkg-def' for pkg-abc-0.1.0.0..
9+
Preprocessing library 'pkg-def' for pkg-abc-0.1.0.0..
10+
Building library 'pkg-def' for pkg-abc-0.1.0.0..
11+
Warning: pkg-abc.cabal:20:15: colon specifier is experimental feature (issue #5660)
12+
Configuring executable 'program' for pkg-abc-0.1.0.0..
13+
Preprocessing executable 'program' for pkg-abc-0.1.0.0..
14+
Building executable 'program' for pkg-abc-0.1.0.0..
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
packages:
2+
pkg-abc
3+
pkg-def
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Test.Cabal.Prelude
2+
3+
-- This is like T6083Pre, but also goes via mixins
4+
--
5+
main = cabalTest $ do
6+
-- https://github.com/haskell/cabal/pull/6047 should make this work for older GHCs too?
7+
skipIf =<< ghcVersionIs (< mkVersion [8,8])
8+
9+
cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-abc:pkg-def"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main (main) where
2+
import Mixin (defValue)
3+
4+
main :: IO ()
5+
main = print defValue
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cabal-version: 3.0
2+
name: pkg-abc
3+
version: 0.1.0.0
4+
5+
library pkg-def
6+
default-language: Haskell2010
7+
hs-source-dirs: pkg-def
8+
build-depends: base
9+
exposed-modules: PkgDef
10+
11+
executable program
12+
default-language: Haskell2010
13+
hs-source-dirs: exe
14+
main-is: Main.hs
15+
mixins: pkg-def (PkgDef as Mixin)
16+
17+
-- we want that to resolve to pkg-def main library.
18+
build-depends:
19+
, base
20+
, pkg-def:pkg-def
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module PkgDef (defValue) where
2+
3+
defValue :: String
4+
defValue = "pkg-abc:pkg-def"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cabal-version: 3.0
2+
name: pkg-def
3+
version: 0.1.0.0
4+
5+
library
6+
default-language: Haskell2010
7+
hs-source-dirs: src
8+
build-depends: base
9+
exposed-modules: PkgDef
10+
11+
library publib
12+
default-language: Haskell2010
13+
visibility: public
14+
hs-source-dirs: publib
15+
build-depends: base
16+
exposed-modules: PkgDef
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module PkgDef (defValue) where
2+
3+
defValue :: String
4+
defValue = "pkg-def:publib"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module PkgDef (defValue) where
2+
3+
defValue :: String
4+
defValue = "pkg-def:pkg-def"

0 commit comments

Comments
 (0)
Please sign in to comment.