-
Notifications
You must be signed in to change notification settings - Fork 843
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
Warn when a test-suite / executable / benchmark also builds the library code? #1008
Comments
This avoids unnecessary recompilation, and fixes the "stack test --coverage" results for this package. commercialhaskell/stack#1008 commercialhaskell/stack#1009
This is especially true when using CPP to expose new identifiers for the test suite. I think this change is too invasive for stack to make, though perhaps if we add a lint option in the future, this could be part of it. |
Makes sense! I've closed this in favor of the issue about the lint command, and added a comment to #1009. The message to the user will mention that this case might be the cause. |
Another common case I just thought of is that when the test-suite also builds the library, it can access non exposed modules. |
Some other cases where the test suite doesn't depend on the library:
|
Yes, this is an unfortunate compromise. We could work around https://ghc.haskell.org/trac/ghc/ticket/1853 , but it would require a lot of hacks:
My preference is to fix it for 8.0 rather than do anything complicated in stack to fix this. |
Cabal now has a notion of |
Could you please share some example hpack package.yaml for the package that contains an executable, a library and the test that tests this library? However I am moving things around, the |
It's not so uncommon to see test-suite / executable / benchmark stanzas which don't depend on the library, and instead compile it when they are built. This tends to happens when there isn't an
hs-source-dirs
on both the library and the other stanza.Why is it good to avoid this?
--coverage
support to correctly distinguish library code and test code (see Detect when hpc report (--coverage) is giving a trivial "100%" #1009)I was hoping that we could catch this case just by checking if the
build-depends
of the non-library stanza includes the library. However, it looks like it's not an error to have it both depend on the library and build all the library's source files. So, the implementation of this would need to detect when thehs-source-dirs
of the auxiliary stanza overlaps with thehs-source-dirs
of the library.Maybe there are legitimate cases for having these auxiliary stanzas also build the main library code? The only one I can think of is that it might be desirable for a test or benchmark to rebuild the library code with a different set of flags.
The text was updated successfully, but these errors were encountered: