Skip to content

doctest doesn't run under the same profile as the rest of the tests #139603

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

Closed
rickwebiii opened this issue Apr 9, 2025 · 1 comment
Closed
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@rickwebiii
Copy link

I have some code that is very optimization-sensitive when it comes to performance. As such, in CI I always run cargo test --release, but noticed my doctests take an order of magnitude or so longer to complete. I've always assumed that rustdoc builds the documentation tests under the same profile settings as the rest of the tests, but this doesn't seem to be the case as I verified in this playground repro.

/// Docs
///
/// ```rust
/// if cfg! (debug_assertions) {
///   panic!("debug");
/// } else {
///   // Ok
/// }
/// ```
pub fn horse() {
    println!("Hello, world!");
}

#[test]
fn cfg() {
    if cfg! (debug_assertions) {
        panic!("debug");
    } else {
        // Ok
    }
}

The unit test fails in debug mode and passes in release mode, while the doctest fails in both.

Meta

Issue occurs in stable, beta, nightly on playground

@rickwebiii rickwebiii added the C-bug Category: This is a bug. label Apr 9, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 9, 2025
@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-doctests Area: Documentation tests, run by rustdoc and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 9, 2025
@ehuss
Copy link
Contributor

ehuss commented Apr 9, 2025

Thanks for the report! I believe this is a duplicate of rust-lang/cargo#6570, so closing in favor of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
Development

No branches or pull requests

4 participants