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

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

Closed
mcandre opened this issue Apr 5, 2018 · 8 comments
Closed

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

mcandre opened this issue Apr 5, 2018 · 8 comments

Comments

@mcandre
Copy link

mcandre commented Apr 5, 2018

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.

@mcandre mcandre changed the title --enable-tests, --enable-documentation should be on by default --enable-tests, --enable-documentation defaults Apr 5, 2018
@hvr
Copy link
Member

hvr commented Apr 5, 2018

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

@gbaz
Copy link
Collaborator

gbaz commented Apr 5, 2018

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

@23Skidoo
Copy link
Member

--enable-documentation

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

@gelisam
Copy link
Collaborator

gelisam commented Apr 11, 2018

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 :(

@gelisam
Copy link
Collaborator

gelisam commented Apr 15, 2018

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

@23Skidoo
Copy link
Member

23Skidoo commented Jun 8, 2018

Related: #5079.

@ulysses4ever
Copy link
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?

@ulysses4ever
Copy link
Collaborator

ulysses4ever commented Jul 25, 2022

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
Projects
None yet
Development

No branches or pull requests

6 participants