Skip to content
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

fix: doctest respects Cargo's color options #14425

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

ShashiSugrim
Copy link
Contributor

What does this PR try to resolve?

Explain the motivation behind this change.

This commit fixes the issue where cargo's test command doesn't respect the color parameter when it gets passed in like this command: cargo t --color never --doc -- --color never

Fixes #14403

How should we test and review this PR?

Test on a basic rust project, with a file called lib.rs that looks like this

/// ```
/// bar
/// ```
pub fn foo() {}
#[cfg(test)]
mod tests {
    #[test]
    fn foo() {
        bar
    }
}

You can try to replicate the same commands @zacknewman used in the description of this issue.
cargo t --color never --doc -- --color never

You will see that compared to the official build of cargo, this build will respect the --color argument

@rustbot
Copy link
Collaborator

rustbot commented Aug 18, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added Command-test S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 18, 2024
src/cargo/ops/cargo_test.rs Outdated Show resolved Hide resolved
@ShashiSugrim
Copy link
Contributor Author

Sorry for the problems. I am trying to fix my branch commits

@ShashiSugrim ShashiSugrim force-pushed the shashi/issue14403 branch 2 times, most recently from 616fcf9 to 4e62a57 Compare August 19, 2024 21:18
@ShashiSugrim
Copy link
Contributor Author

Hello, please review the latest changes, thank you

ColorChoice::Never => "never",
ColorChoice::CargoAuto => "auto",
};
p.arg("--color").arg(color_arg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to call out that this may break others' builds if they already have --color in their RUSTDOCFLAGS. rustdoc doesn't allow more then one occurrence of the --color flag. While we don't consider this a breaking change, this is worth mentioning in changelog.

@weihanglo weihanglo changed the title Fix issue ' cargo t --doc does not respect --color when a compilation error occurs fix: doctest respects Cargo's color options Aug 20, 2024
@epage
Copy link
Contributor

epage commented Aug 20, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Aug 20, 2024

📌 Commit 4657015 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 20, 2024
@bors
Copy link
Contributor

bors commented Aug 20, 2024

⌛ Testing commit 4657015 with merge 3ef3f61...

@bors
Copy link
Contributor

bors commented Aug 20, 2024

☀️ Test successful - checks-actions
Approved by: epage
Pushing 3ef3f61 to master...

@bors bors merged commit 3ef3f61 into rust-lang:master Aug 20, 2024
22 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 22, 2024
Update cargo

12 commits in ba8b39413c74d08494f94a7542fe79aa636e1661..8f40fc59fb0c8df91c97405785197f3c630304ea
2024-08-16 22:48:57 +0000 to 2024-08-21 22:37:06 +0000
- Tests rely on absence of RUST_BACKTRACE (rust-lang/cargo#14441)
- fix: -Cmetadata includes whether extra rustflags is same as host (rust-lang/cargo#14432)
- [mdman] Normalize newlines when rendering options (rust-lang/cargo#14428)
- fix: doctest respects Cargo's color options (rust-lang/cargo#14425)
- Be more permissive while packaging unpublishable crates. (rust-lang/cargo#14408)
- fix: Limiting pre-release match semantics to use only on `OptVersionReq::Req` (rust-lang/cargo#14412)
- test: add a regression test for Issue 14409 (rust-lang/cargo#14430)
- chore: update label trigger for Command-info (rust-lang/cargo#14422)
- doc: add lockfile-path unstable doc section (rust-lang/cargo#14423)
- doc: update lockfile-path tracking issue (rust-lang/cargo#14424)
- fix: remove list owners feature of info subcommand (rust-lang/cargo#14418)
- Lockfile path tests (follow-up) (rust-lang/cargo#14417)
@rustbot rustbot added this to the 1.82.0 milestone Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interacts-with-crates.io Area: interaction with registries Command-info Command-test S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo t --doc does not respect --color when a compilation error occurs
5 participants