-
Notifications
You must be signed in to change notification settings - Fork 696
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
Can't build with --enable-tests in presence of circular dependencies #960
Comments
You can see another instance of this bug in mwc-random issue 15. |
Yes, see #935 for the |
The |
I can certainly see that this is a problem, but does anyone have any reasonable suggestions for a fix? I mean, if you have cyclical dependencies that's (in itself) a huge problem for the integrity of your tests. Should cabal(-install) try to achieve some sort of fixed-point, or what? AFAICT this is generally an issue of a "lack of Backpack", i.e. there are really no library "interfaces" -- only implementations. As such I don't see how this can actually be (even theoretically) be solved given the current state of GHC/Cabal. Unless we get Backpack (or similar API separation) I don't see any other real solution other than breaking apart libraries appropriately such that types and instances are separate from implementation. (But even that may not be enough.) My pronouncement would therefore be: "Break the dependency, libraries!" (I know it's not necessarily simple.) EDIT: ... and that this isn't something that Cabal/cabal-install can (even theoretically) solve. Thus it should be closed. |
@BardurArantsson The solution to this is actually very simple to state: "sandboxes always". Rather than installing the library-to-be-tested into the in-place package database, it should be installed into a sandbox. Then, its test dependencies can be installed into the sandbox. Finally, the tests can be built and run using the sandbox version of the library. This would be intellectually simple to do, but there's just a lot of things that need to be moved about to do it. |
Ok... let's see it! What things need to be moved about and how would you do it? :) I understand that if the circularity is only because test-X-depends-on-impl-Y-which-depends-on-tests-for-X, it should be easy do to a sort of "tiered" compilation where the two impls are compiled first (without testing) and then tests are run afterwards. However, I didn't get the impression that that was the case from the discussion. My bad, if that was wrong. Especially since there should be no way for an impl-of-X to depend on Y-and-test-of-Y, only Y. If it's just a matter of not running tests in some circumstances, then I'm with you. I still maintain that you should "just" separate your tests into a separate project in that case. |
Cabal doesn't support tests-only packages, and cabal-install doesn't (yet) have features for working with multiple packages simultaneously. There are open tickets for both of these features. |
We think we've got a solution to this, see the last section of http://www.well-typed.com/blog/2015/07/cabal-setup-deps/ This would also lets us get rid of the fallback for when configure fails to find a solution. |
Anyone willing to implement? |
Yes it does. You just avoid calling it a "test" project. Instead you call it a "testkit" and make it a real (normal) project. Then you depend on it in your "real" project's "test" section. (I think the concept should be easily understood by looking a bit at the documentation for akka-testkit project.) The general approach is more general than just this use case, but unfortunately I don't have a Haskell (demo) project to publish just ATM. (I mean, I have it, but it's not quite ready for publication.) Does this make sense? Hopefully, I'll be able to publish my example soonish, but please look into akka-testkit in the mean time, or ask further questions! This really isn't that difficult (without extending Cabal or whatever). |
Added a test for the problem where a library package has a testsuite that depends on a packge that depends on it. We should be able to handle this by having separate build plans for the library and its testsuite. The ticket for separate build plans is haskell#1575
See also PR #3422 |
When per-component build merges #3662 the builder bits are all done; all we need to do is teach the solver how to make test suite deps private, and then propagate that through the nix-local-build code. |
I'm closing this in favor of #1575, which has more discussion. |
Update by @ezyang: when per-component build merges #3662 the builder bits are all done; all we need to do is teach the solver how to make test suite deps private, and then propagate that through the nix-local-build code.
The
text
library has atests
stanza that I can't use because I get an error of this form:I believe the problem is caused by the fact that a library that
text
's tests depend on usestext
itself.I realise that this is likely to be difficult to fix, but it's a problem for "core" libraries: @tibbe reports that
containers
faces the same difficulty.The text was updated successfully, but these errors were encountered: