You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
changed the title [-]--enable-tests, --enable-documentation should be on by default[/-][+]--enable-tests, --enable-documentation defaults[/+]on Apr 5, 2018
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 :(
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
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?
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!
Activity
[-]--enable-tests, --enable-documentation should be on by default[/-][+]--enable-tests, --enable-documentation defaults[/+]hvr commentedon Apr 5, 2018
Can you be more specific in which way "Unit tests and haddock break"?
gbaz commentedon Apr 5, 2018
Also note that you can set these defaults yourself in ~/.cabal/config?
23Skidoo commentedon Apr 10, 2018
Is this about
doctest? See also the experimentalcabal doctestcommand (#4480).gelisam commentedon Apr 11, 2018
Fun fact:
--disable-testsis 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-testsnor--disable-testsis specified. If--enable-testswas 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 commentedon Apr 15, 2018
Upon further investigation:
cabal new-configurewill 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-configurewill silently disable the test, whilecabal new-configure --enable-testswill complain that it cannot find a build plan.cabal new-build --disable-testsdisables all the tests.cabal new-buildandcabal new-build allonly build the libraries and the executables; but if--enable-testswas passed tocabal new-configure, or iftests: Trueis in~/.cabal/config, then it will also build the tests.cabal new-build all:tests. ifcabal new-configuredisabled 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 thencabal new-build myproject:test:mytestto build my project's test suite. If--enable-testswas the default, I couldn't do that, becausecabal new-configurewouldn't find a build plan andcabal new-configure --disable-testswould disable my project's test suite too.I see three possibilities:
--enable-teststhe default, and add a new flag (--only-buildable-tests?) to tellcabal new-configureto disable the tests for which a build plan cannot be found. I think such a flag should be added anyway.cabal new-configure, but change the default forcabal new-buildand/orcabal new-build allso that it also builds the (enabled) tests, or add acabal new-build ALLwhich builds more thanall. This is being considered.tests: Trueto your~/.cabal/config23Skidoo commentedon Jun 8, 2018
Related: #5079.
ulysses4ever commentedon Jul 11, 2022
From the OP description:
cabal haddocknow 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 commentedon 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!