Skip to content

Inconsistent status messages when running cargo doc #9076

Open
@ehuss

Description

@ehuss

Problem
When running cargo doc, Cargo is inconsistent about whether it prints "checking" or "compiling", particularly for proc-macro dependencies.

The issue is that there are two parallel dependency trees. The trees for building proc-macros, and the tree for documenting it. Parts of these trees get built in parallel, and there is a race as to whether the check or build comes first. There is code in note_working_on to attempt to avoid some of these inconsistencies, but it doesn't handle this scenario, and I'm not sure how feasible it would be to avoid.

The main problem is that this makes it harder to work with Cargo's testsuite, since tests can't check the output.

Steps
Here is a cargo test which demonstrates the problem:

#[cargo_test]
fn inconsistent_status_report() {
    let p = project()
        .file(
            "Cargo.toml",
            r#"
                [package]
                name = "foo"
                version = "1.0.0"

                [dependencies]
                pm = { path = "pm" }
            "#,
        )
        .file("src/lib.rs", "")
        .file(
            "pm/Cargo.toml",
            r#"
                [package]
                name = "pm"
                version = "0.1.0"

                [lib]
                proc-macro = true

                [dependencies]
                pm-dep = { path = "../pm-dep" }
            "#,
        )
        .file("pm/src/lib.rs", "")
        .file("pm-dep/Cargo.toml", &basic_manifest("pm-dep", "1.0.0"))
        .file("pm-dep/src/lib.rs", "")
        .build();

    // This sometimes says "compiling pm-dep" and sometimes "checking pm-dep".
    p.cargo("doc")
        .with_stderr_unordered(
            "\
[COMPILING] pm-dep v1.0.0 [..]
[DOCUMENTING] pm-dep v1.0.0 [..]
[COMPILING] pm v0.1.0 [..]
[DOCUMENTING] pm v0.1.0 [..]
[DOCUMENTING] foo v1.0.0 [..]
[FINISHED] [..]
",
        )
        .run();
}

cargo 1.51.0-nightly (329895f 2021-01-06)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-console-outputArea: Terminal output, colors, progress bar, etc.C-bugCategory: bugCommand-docS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions