Skip to content

Commit

Permalink
Fix issue ' cargo t --doc does not respect --color when a compilation…
Browse files Browse the repository at this point in the history
… error occurs rust-lang#14403 '
  • Loading branch information
ShashiSugrim committed Aug 18, 2024
1 parent 8b04759 commit 844600e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::core::compiler::{Compilation, CompileKind, Doctest, Metadata, Unit, UnitOutput};
use crate::core::profiles::PanicStrategy;
use crate::core::shell::ColorChoice;
use crate::core::shell::Verbosity;
use crate::core::{TargetKind, Workspace};
use crate::ops;
Expand Down Expand Up @@ -176,6 +177,7 @@ fn run_doc_tests(
let gctx = ws.gctx();
let mut errors = Vec::new();
let doctest_xcompile = gctx.cli_unstable().doctest_xcompile;
let color = gctx.shell().color_choice();

for doctest_info in &compilation.to_doc_test {
let Doctest {
Expand Down Expand Up @@ -212,6 +214,13 @@ fn run_doc_tests(
gctx.shell().status("Doc-tests", unit.target.name())?;
let mut p = compilation.rustdoc_process(unit, *script_meta)?;

let color_arg = match color {
ColorChoice::Always => "always",
ColorChoice::Never => "never",
ColorChoice::CargoAuto => "auto",
};
p.arg("--color").arg(color_arg);

for (var, value) in env {
p.env(var, value);
}
Expand Down

0 comments on commit 844600e

Please sign in to comment.