Skip to content

Passing --nocapture to rustdoc behaves in strange ways #10792

Closed as not planned
Closed as not planned
@RalfJung

Description

@RalfJung

Problem

I am debugging a diverging doctest by adding some printing. For example:

/// ```rust
/// eprintln!("stderr");
/// println!("stdout");
/// loop {}
/// ```
pub fn uwu() {}

Steps

I would expect cargo test --doc -- --nocapture to show the stderr and stdout of running the test. However, that does not seem to be the case; it only shows stderr and stdour of rustc as it builds the test.

I found that RUSTDOCFLAGS="-Zunstable-options --nocapture" cargo test --doc does what I want.

Strangely, RUSTDOCFLAGS="-Zunstable-options --nocapture" cargo test --doc -- --nocapture says that "Option 'nocapture' given more than once", but removing the one in RUSTDOCFLAGS does not have the same result as removing the one after --.

Possible Solution(s)

No response

Notes

I don't quite know what is going on here. cargo test --doc -- --help seems to show the help page of a libtest runner, not of rustdoc. The "Option 'nocapture' given more than once" error shows that cargo is forwarding its --nocapture argument to rustdoc, but somehow it is doing that in a way that doesn't actually have any effect?

Version

cargo 1.64.0-nightly (a5e08c470 2022-06-23)
release: 1.64.0-nightly
commit-hash: a5e08c4703f202e30cdaf80ca3e7c00baa59c496
commit-date: 2022-06-23
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1n)
os: Debian testing (bookworm) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions