Skip to content

Commit

Permalink
Resolve haskell#6409: Add public multilib test(s)
Browse files Browse the repository at this point in the history
Also add a test for current behaviour
of haskell#6083

And variant with mixin, for haskell#6281

The tests are disable for GHC older than 8.8
Should they work?
  • Loading branch information
phadej committed May 14, 2020
1 parent 9c148f7 commit f0ca0dc
Show file tree
Hide file tree
Showing 32 changed files with 227 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# cabal v2-run
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -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..
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages:
pkg-abc
pkg-def

Original file line number Diff line number Diff line change
@@ -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"

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Main (main) where
import PkgDef (defValue)

main :: IO ()
main = print defValue
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PkgDef (defValue) where

defValue :: String
defValue = "pkg-def:publib"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PkgDef (defValue) where

defValue :: String
defValue = "pkg-def:pkg-def"
14 changes: 14 additions & 0 deletions cabal-testsuite/PackageTests/MultipleLibraries/T6083Pre/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# cabal v2-run
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -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..
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages:
pkg-abc
pkg-def

Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Main (main) where
import PkgDef (defValue)

main :: IO ()
main = print defValue
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PkgDef (defValue) where

defValue :: String
defValue = "pkg-abc:pkg-def"
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PkgDef (defValue) where

defValue :: String
defValue = "pkg-def:publib"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PkgDef (defValue) where

defValue :: String
defValue = "pkg-def:pkg-def"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# cabal v2-run
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -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..
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages:
pkg-abc
pkg-def

Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Main (main) where
import Mixin (defValue)

main :: IO ()
main = print defValue
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PkgDef (defValue) where

defValue :: String
defValue = "pkg-abc:pkg-def"
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PkgDef (defValue) where

defValue :: String
defValue = "pkg-def:publib"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PkgDef (defValue) where

defValue :: String
defValue = "pkg-def:pkg-def"

0 comments on commit f0ca0dc

Please sign in to comment.