Skip to content

--enable-tests, --enable-documentation defaults #5255

Closed

Description

@mcandre

Unit tests and haddock break when the cabal flags --enable-tests, --enable-documentation are off, which is the default behavior unfortunately. I think --enable-tests should be on by default when running cabal install against a local *.cabal development package, and --enable-documentation should generally be on by default, in order to fix haddock.

As a workaround, I am explicitly supplying --enable-tests to my local cabal install runs against *.cabal files; and doing a lot of ghc-check ... cabal install --force-reinstalls --enable-documentation... to fix haddock for the dependency packages that were already installed.

Activity

  1. changed the title [-]--enable-tests, --enable-documentation should be on by default[/-] [+]--enable-tests, --enable-documentation defaults[/+] on Apr 5, 2018
  2. hvr commented on Apr 5, 2018

    @hvr
    Member

    Can you be more specific in which way "Unit tests and haddock break"?

  3. gbaz commented on Apr 5, 2018

    @gbaz
    Collaborator

    Also note that you can set these defaults yourself in ~/.cabal/config?

  4. 23Skidoo commented on Apr 10, 2018

    @23Skidoo
    Member

    --enable-documentation

    Is this about doctest? See also the experimental cabal doctest command (#4480).

  5. gelisam commented on Apr 11, 2018

    @gelisam
    Collaborator

    I think --enable-tests should be on by default

    Fun fact: --disable-tests is not the default either! At least, that's what I conclude from my experimentations. There seems to be a third option, "leave the tests be", which is used when neither --enable-tests nor --disable-tests is specified. If --enable-tests was the default, there would be no way to specify this third option. Which would make me sad, because it's the only configuration under which my project builds at the moment :(

  6. gelisam commented on Apr 15, 2018

    @gelisam
    Collaborator

    Upon further investigation:

    • by default, cabal new-configure will pick a build plan which does include the tests, if possible. It might not be possible if the only working build plan includes the library's dependencies but not the test suite's. If that's the case, cabal new-configure will silently disable the test, while cabal new-configure --enable-tests will complain that it cannot find a build plan. cabal new-build --disable-tests disables all the tests.
    • by default, cabal new-build and cabal new-build all only build the libraries and the executables; but if --enable-tests was passed to cabal new-configure, or if tests: True is in ~/.cabal/config, then it will also build the tests.
    • you can build the tests with cabal new-build all:tests. if cabal new-configure disabled some of the tests, those won't get built.

    In my project, I am downloading a local copy of several dependencies and compiling them as local packages. I only want to run my project's tests, not the tests of my dependencies. Some of my dependencies have tests which aren't compatible with my project's build plan. With cabal's current behaviour, I can use cabal new-configure, which will disable those incompatible tests, and then cabal new-build myproject:test:mytest to build my project's test suite. If --enable-tests was the default, I couldn't do that, because cabal new-configure wouldn't find a build plan and cabal new-configure --disable-tests would disable my project's test suite too.

    I see three possibilities:

    • make --enable-tests the default, and add a new flag (--only-buildable-tests?) to tell cabal new-configure to disable the tests for which a build plan cannot be found. I think such a flag should be added anyway.
    • keep the current default for cabal new-configure, but change the default for cabal new-build and/or cabal new-build all so that it also builds the (enabled) tests, or add a cabal new-build ALL which builds more than all. This is being considered.
    • leave the defaults as is, and add tests: True to your ~/.cabal/config
  7. added
    cabal-install: v2-build system
    on Jun 8, 2018
  8. 23Skidoo commented on Jun 8, 2018

    @23Skidoo
    Member

    Related: #5079.

  9. ulysses4ever commented on Jul 11, 2022

    @ulysses4ever
    Collaborator

    From the OP description:

    Unit tests and haddock break when the cabal flags --enable-tests, --enable-documentation are off

    cabal haddock now implies --enable-documentation (#8259), so the second part is addressed now, I think. For the first part (--enable-tests), there's #5079. Should we close this ticket?

  10. ulysses4ever commented on Jul 25, 2022

    @ulysses4ever
    Collaborator

    As no one objected, I'm closing this for reasons described in the previous comment. Please, feel free to re-open if you think it's necessary. Thank you everyone for insightful discussion!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cabal-install: v2-build systemtype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions