-
Notifications
You must be signed in to change notification settings - Fork 704
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
Make cabal new-doctest #4500
Comments
I assume we are talking about nix-style builds, and the need for |
Yes. |
If this can be fixed on the cabal-install side only, the fix can still make it into cabal-install 2.0 (or 2.0.1). |
I think that the design of the current
|
@quasicomputational I do like your approach. Note that I'm on the fence though if doctest should be considered a test-suite, if it is though we should rather have a That said, on the whole I'm not convinced that treating doctest special in any form is the right approach anymore. I'd rather see some form of wrapping doctest into a proper cabal test-suite and treat it in a more generic fashion. |
I think I'm coming around to the idea of doctests being a full-blown How about with a new
A doctest
I also realised that we likely don't want special-cased time-saving mechanisms for doctests: other test suites run unconditionally, and if we give users the power to toggle doctests on and off they can come up with schemes of their own (e.g., a The fun thing here is that it requires practically no I can see a path to implementing this. @angerman, are you still intent on working on this, or should I put together a 1.0 myself and see what people think? This is missing the boat for 2.4, but if we can get it in for 3.0 and I can start getting rid of |
And yes, implementing this is simple:
There should be a BONUS: for interested people, I'm working on another HACK solution
In short: it's kind of |
Good shout on N test suites for N doctestable components simplifying things; I'd been attracted to the ease of use of having a "doctest everything" default, but that would definitely be more complex. Also, yeah, Can we get away without |
Yes, |
Discussion in #3788 suggests that a new |
Still thinking aloud, but a the |
Why it does need to agree with |
Oh yeah, you're right. I had it in my head that the runner binary needed to be linked against it, but it actually only touches it in interpreted code. |
I've been having a look at this issue, and can't really figure out what a solution to this would look like. I am currently using |
Over the last few days I stumbled into an intersection of Cabal, doctests, and also the impact on some build ecosystems like Nix. Since
Regarding both points, I feel like there's a bias towards compromising to the legacy of what we have over giving users more features. In some ways, this feels inverted from how I see Haskell the language. But at this point, if resources were finite and fungible (definitely not fungible in real life), I'd trade off progressive language features for progressive tooling. With respect to the argument that "does not compile tests" are limited to just a few projects like Servant, I'd like to consider that we might have far more of these if they were better supported by tooling. We're often trying to make typesafe DSLs in Haskell, and free theorems, though amazing, are never comprehensive enough in practice. To really know if something is typesafe, I need to test more than the happy path, especially with a system with as much complexity as GHC. Regarding building components one at a time, I feel we can use all the help we can get to have a better caching story in Haskell. Build times can be really bad, which affects developer productivity more than I think we admit to ourselves. Every little step helps. I think building components one-at-a-time is one of those steps. I know what we have is cached locally, but not necessarily in a distributable way (Nix- or Bazel-style). So I agree that So I think for me, this is in part about doctests, which I do think are great, for the reasons I mentioned above. But it's also larger than doctests for me. I'm interested in thinking about how to begin a process of constraining the freedom So I haven't said much technical here. Part of that is because I think there are devils in the details that I don't know about yet, and I don't want to speak out of turn. But I would like to help where I can. Mostly I wanted to see if I could get my sentiment to have some traction. And also learn more about these details where devils are, so I can see how I can contribute best. |
Related to |
doctests (or tests in general) in cross-compilation setting is problematic to begin with. How to run them? |
I think @michaelpj's comment alludes to the kernel of a solution.
But it's certainly work to get there. I think this is where the Haskell.nix folk have a perspective I'd be really interested in, because I think they actually cross-compile a non-trivial number of packages, and have a better sense for what went well and where there are problems. I'm not sure who in that project would be worth tagging into this conversation. Maybe they are already already watching/participating in this thread. |
that's why we have On to the With that said, I believe we could make doctest work in a cross compilation setting (where we have The most practical way forward for now would be to test native -> native, and hope for the best with cross compiation without testing. That's not very satisfactory and as layed out above I believe we have most of the infrastructure in place to make cross testing more viable; I don't see myself being able to spend much time on this this right now though. |
I envision some metaprogramming thing to extract the doctests, after which they can be compiled at run like any other test suite. Today's GHCi monster confused the metaprogramming and test running parts, breaking cross. Even simpler than |
migrating a comment from the above linked ticket: One strawman idea -- what if instead of a doctest stanza as such, we extended the test stanza with a code generation step that invoked an executable that took the code directory itself as an argument? So we have a test stanza, with a Note, this stanza would still need to duplicate the build-depends of the library, and also the extensions. With common stanzas this seems not particularly onerous, but maaaaybe a little confusing? I can't think of a way to avoid this that doesn't violate least expectations and make things even further confusing however. |
I'm playing with implementing the above, and I ran into a question. Why do doctest drivers prefer to run things through ghci (either as a library, or as an executable) rather than just generating and compiling code? Is there any particular reason for this, or is it just a historical decision that's continued indefinitely... |
PR for this approach here: #7688 |
With
The If we want to improve on this, adding two new flags could help:
At that point I could simply say something like
to run The big difference here, apart from being more concise, is that you don't end up with a globally installed |
Examples like: >>> :t traversed % to not
... or >>> :kind! SomeTypeFamily 1 2 3
Result For example in https://hackage.haskell.org/package/symbols-0.3.0.0/docs/Data-Symbol-Ascii.html |
That's clever. |
@gbaz doctests are That said, going through |
If you refer to |
Glad you two have chimed in. I'd appreciate it if you took a look at #7688 and let me know if it might be useful. I think it could provide the same functionality (via a different route) as the --with-repl flag suggested above. |
@angerman should we unassign you from this or do you still plan to work on it? |
I'm going to close as obsoleted by #7688 -- if you feel there's a use-case not covered by that, feel free to reopen. |
I don't feel like #7688 really solves this ticket. The approach along the lines of The comment by @quasicomputational seems to lay out the design considerations for the command quite nicely (#4500 (comment)) It seems there has been quite a variety of mental gymnastics over the years to try to work out other solutions but is there a convincing explanation about why |
My belief is 7688 solves the ticket because the demos show that existing doctest runners can be retrofitted to work with it. I.e. from a feature-completeness standpoint, it subsumes this. One reason |
I don't think #7688 is right on the conceptual level ( see #9238 ). There have been tickets for years about adding cabal support for running doctests. Perhaps another solution is to have a |
I don't think that issue points to the "wrong conceptual level" -- its easy to set the flags you want in the test stanza. |
@gbaz at the risk of repeating myself, the documented way to run doctests is:
This is more lengthy than I would hope it to be, but it is robust. If somebody wants to do something on the Regarding any alternative approaches to running doctests (including #7688), people are of cause free to experiment. However, I'm not prepared to provide support for those alternatives approaches. I also want to avoid the situation where people open issues on the |
Thanks sol, that's very clear. I appreciate you don't want to take on the burden of supporting alternative approaches -- I hope in time others will provide solutions that do support such approaches. We had some further discussion on IRC and I think what it comes down to is that "wrapping that up" is no more than dropping it into a more elegantly named shell-script -- perhaps one named What an approach along the lines of code-generators provides is that doctests can be executed just like other tests with |
cabal doctest
doesn't work with nix builds:The text was updated successfully, but these errors were encountered: