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 support for generating test-suite. #5761

Merged
merged 3 commits into from
Jan 25, 2019
Merged

Conversation

m-renaud
Copy link
Collaborator

@m-renaud m-renaud commented Dec 3, 2018

Overview

Support generating a test-suite for libraries from cabal init.

Partially addresses #5705.

Changes

Two new flags:
--tests :: Bool
--test-dir :: [String] (same behaviour as srcDirs)

Interactive Prompt Behaviour

You will only get asked about generating a test suite if it is a Library or LibraryAndExecutable. The rationale for this is because testing modules that are only part of an executable is more complicated to set up then just depending on the library.

If you select "no" for generating a test suite, you won't be asked for the test directory.

Example Invocation

$ cabal init -n --is-libandexe --tests --test-dir=test --source-dir=src

Guessing dependencies...

Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating CHANGELOG.md...
Generating src/Main.hs...
Generating test/MyLibTest.hs...
Generating initsample.cabal...

initsample.cabal

cabal-version:       >=1.10
-- Initial package description 'initsample.cabal' generated by 'cabal
-- init'.  For further documentation, see
-- http://haskell.org/cabal/users-guide/

name:                initsample
version:             0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file:        LICENSE
author:              Matt Renaud
maintainer:          [email protected]
-- copyright:
-- category:
build-type:          Simple
extra-source-files:  CHANGELOG.md

library
  -- exposed-modules:
  -- other-modules:
  -- other-extensions:
  build-depends:       base >=4.11 && <4.12
  hs-source-dirs:      src
  default-language:    Haskell2010

executable initsample
  main-is:             Main.hs
  -- other-modules:
  -- other-extensions:
  build-depends:       base >=4.11 && <4.12
  hs-source-dirs:      src
  default-language:    Haskell2010

test-suite initsample-test
  default-language:    Haskell2010
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  main-is:             MyLibTest.hs
  build-depends:       base >=4.11 && <4.12

TODO


Please include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • If the change is docs-only, [ci skip] is used to avoid triggering the build bots.

Please also shortly describe how you tested your change. Bonus points for added tests!

Two new flags:
--tests
--test-dir

- Only valid to generate tests for a "Library" or "LibraryAndExecutable".
Copy link
Member

@23Skidoo 23Skidoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, feel free to merge once it's green.

@23Skidoo 23Skidoo merged commit 64ece51 into haskell:master Jan 25, 2019
@23Skidoo
Copy link
Member

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants