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 cabal init golden test exercising --libandexe behaviour. #6705

Merged
merged 1 commit into from
Apr 13, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import Language.Haskell.Extension ( Language(..) )
tests :: [TestTree]
tests = [ testGroup "cabal init goldens"
[ checkCabalFileGolden exeFlags "exe-only-golden.cabal"
, checkCabalFileGolden libAndExeFlags "lib-and-exe-golden.cabal"
, checkCabalFileGolden libExeAndTestFlags "lib-exe-and-test-golden.cabal"
]
]
Expand Down Expand Up @@ -109,6 +110,29 @@ exeFlags = baseFlags {
}


-- ==================================================
-- Simple lib and exe (as created by `cabal init --libandexe`).
--
-- Specifically, having 'exposedModules = Just ["MyLib"]' is a special
-- case which results in the executable depending on the library from
-- the same package, i.e. 'build-depends = foo' with no version
-- constraints.

libAndExeFlags :: InitFlags
libAndExeFlags = baseFlags {
-- Create a library and executable
packageType = Flag LibraryAndExecutable

-- Main living in app/Main.hs.
, mainIs = Flag "Main.hs"
, applicationDirs = Just ["app"]

-- Library sources live in src/ and expose the module MyLib.
, sourceDirs = Just ["src"]
, exposedModules = Just (map ModuleName.fromString ["MyLib"])
}


-- ==================================================
-- Lib, exe, and test suite

Expand Down
22 changes: 22 additions & 0 deletions tests/fixtures/init/lib-and-exe-golden.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cabal-version: 2.4
name: foo
version: 3.2.1
synopsis: The foo package
homepage: https://github.com/foo/foo
license: NONE
author: me
maintainer: [email protected]
category: SomeCat
extra-source-files: CHANGELOG.md

library
exposed-modules: MyLib
build-depends: base ^>=4.13.0.0, containers ^>=5.7.0.0, unordered-containers ^>=2.7.0.0
hs-source-dirs: src
default-language: Haskell2010

executable foo
main-is: Main.hs
build-depends: base ^>=4.13.0.0, containers ^>=5.7.0.0, unordered-containers ^>=2.7.0.0, foo
hs-source-dirs: app
default-language: Haskell2010