-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Set cfg(test) when rustdoc is running with --test option #59940
Conversation
I'm not sure what the rustdoc team procedures are here, but you might want to consider this as a normal public API addition. That is, if you accept this change and it makes it to stable Rust, then removing this would be a breaking change AIUI. For example, one thing I think this would allow you to do is to write doc tests using code that is gated behind a |
There is some discussion about this in #45599. |
(Sorry about closing this, i misclicked the button when typing my initial comment. 😓) This looks like it's not the same as #45599 - this is about setting |
Ah, sorry for misinterpreting. |
So is it ok to merge it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine to me, though i'm a little worried that there will be some subtle ramifications that we haven't thought about. I'd like someone from @rust-lang/docs or @rust-lang/rustdoc to see whether i'm overthinking this, but in the meantime there doesn't seem to be much harm from landing it into nightly for now - we have plenty of time to revert it if things go awry.
@bors r+ |
📌 Commit 1ce17e6392a0bcb4d99cd2e8cd6249d015f43e6d has been approved by |
I'm a bit worried that doctests on items marked Also can we add a // compile-pass
// compile-flags:--test
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
/// this doctest will be ignored:
///
/// ```
/// assert!(false);
/// ```
#[cfg(not(test))]
pub struct Foo;
/// this doctest will be tested:
///
/// ```
/// assert!(true);
/// ```
#[cfg(test)]
pub struct Foo; |
1ce17e6
to
459d677
Compare
Updated! |
r? @ollie27 (since @QuietMisdreavus was ok with the changes, I guess it's up to you to validate the tests :p) |
@bors r+ |
📌 Commit 459d677 has been approved by |
@bors retry yielding to r0llup |
⌛ Testing commit 459d677 with merge 3ae1afdb0a6df45f29f9829968419ff7fde0cc3a... |
Set cfg(test) when rustdoc is running with --test option Following a [discussion on twitter](https://twitter.com/burntsushi5/status/1117091914199785473), I proposed this change. What do you think about it? r? @QuietMisdreavus cc @BurntSushi
@bors retry |
Rollup of 12 pull requests Successful merges: - #59734 (Prevent failure in case no space left on device in rustdoc) - #59940 (Set cfg(test) when rustdoc is running with --test option) - #60134 (Fix index-page generation) - #60165 (Add Pin::{into_inner,into_inner_unchecked}) - #60183 (Chalkify: Add builtin Copy/Clone) - #60225 (Introduce hir::ExprKind::Use and employ in for loop desugaring.) - #60247 (Implement Debug for Place using Place::iterate) - #60259 (Derive Default instead of new in applicable lint) - #60267 (Add feature-gate for f16c target feature) - #60284 (Do not allow const generics to depend on type parameters) - #60285 (Do not ICE when checking types against foreign fn) - #60289 (Make `-Z allow-features` work for stdlib features) Failed merges: r? @ghost
The rustdoc program now sets `cfg(test)` if run with `--test`. Hence, the r-efi-string crate will now compile properly under all circumstances. Therefore, re-enable the doctests for better test coverage. Note that this will be released with rust-1.36. For details, see: rust-lang/rust#59940 Signed-off-by: David Rheinsberg <[email protected]>
I should have checked before merging this but there are doctests in this repository that are behind Lines 50 to 51 in f492693
I've submitted a revert: #61199 |
Revert "Set test flag when rustdoc is running with --test option" Reverts #59940. It caused doctests in this repository to no longer be tested including all of the core crate.
…sdreavus Revert "Set test flag when rustdoc is running with --test option" Reverts rust-lang#59940. It caused doctests in this repository to no longer be tested including all of the core crate.
…sdreavus Revert "Set test flag when rustdoc is running with --test option" Reverts rust-lang#59940. It caused doctests in this repository to no longer be tested including all of the core crate.
…sdreavus Revert "Set test flag when rustdoc is running with --test option" Reverts rust-lang#59940. It caused doctests in this repository to no longer be tested including all of the core crate.
…sdreavus Revert "Set test flag when rustdoc is running with --test option" Reverts rust-lang#59940. It caused doctests in this repository to no longer be tested including all of the core crate.
Following a discussion on twitter, I proposed this change. What do you think about it?
r? @QuietMisdreavus
cc @BurntSushi