-
Notifications
You must be signed in to change notification settings - Fork 0
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
doctests #5
Comments
Bonus
I propose to the team to looking into the possibility for |
If we can put as many doctests into a single binary as possible, that would also improve compilation times We also want to make it so its as natural to get coverage for doctests as other tests.
That is the direction I would want to go as well. |
Yeah we can push it further.
|
I'm very fine with this approach as it would remove code from rustdoc. Problem is that the code examples originally were written to allow crate writers to add code examples for their users, meaning they needed to import the crate as if it was a dependency. I think this approach is still good, but should not be the only one (for example we can't run doctest in binary crates, which is bad). If cargo can solve both issues, that'd be awesome. :) |
Crazy idea: could we change the compilation of
Challenges
|
Unfortunately, it would require some new attributes for it to work as you can add a lot of different checks on doctests such as a specific edition or even to ensure that the compilation fails. More information here. |
Would it be possible to resolve how the doctest should be built with a new attribute? Maybe something like |
Yeah, I was aware of and called out Likely switching to this style of doctests would require an opt-in with it being the default in a new edition, so we could get away with changing things. |
btw rust-lang/rust#123974 is a nice improvement to performance. |
It's not finished yet. A few things need to be added:
Once done, I plan to work on binary doctests: I want to replace them with what we do for |
Sounds like this is because the tests were building and running as separate processes and now they are being combined, causing changes in behavior through any interactions with globals?
Could you clarify what you mean here? Overall, I'm excited by these changes. The changes in performance will hopefully mean people will stop avoiding doctests. That said, I still feel like we need to do something to make these less special. The more we align with how things are normally built and run, the easier it is to take part in a more unified CLI, reporting, and coverage tracking. |
Exactly! Should have precised. That's also why we'll need to add a new code attribute (named
Absolutely: if your crate is a binary, then I plan to apply the same transformation to doctests as we do for Don't hesitate if my explanations are not clear enough. |
Is this a variant of the idea mentioned earlier of generating |
Not that I know.
Me doing it. First I want to finish the first PR (the speed up of doctests by merging them). |
FYI @GuillaumeGomez posted a status update on bins: rust-lang/rust#50784 (comment) |
For overriding file/line, lang is interested, it just needs someone to champion and workout corner cases, particularly if we also support column. We need to harvest Internals for feedback and respond. e.g. https://internals.rust-lang.org/t/pre-rfc-enable-setting-of-source-file-line-column/19156 One idea: punt on column and code-generate to the right column |
@GuillaumeGomez in your update at rust-lang/rust#50784 (comment) you mention either having rustc translate doc-comments into The part I don't remember is how much we talked about |
Doesn't have to be in the first release but an interesting spin off from that is if rustdoc emits json messages for these generated files, some of those could include that they are compile_fail and cargo could do the compile-fail part. |
We talked about doctests being an area for improvement
The text was updated successfully, but these errors were encountered: