mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Fix issue ' cargo t --doc does not respect --color when a compilation error occurs #14403 '
This commit is contained in:
parent
4494032dbc
commit
465701526b
@ -1,5 +1,6 @@
|
|||||||
use crate::core::compiler::{Compilation, CompileKind, Doctest, Metadata, Unit, UnitOutput};
|
use crate::core::compiler::{Compilation, CompileKind, Doctest, Metadata, Unit, UnitOutput};
|
||||||
use crate::core::profiles::PanicStrategy;
|
use crate::core::profiles::PanicStrategy;
|
||||||
|
use crate::core::shell::ColorChoice;
|
||||||
use crate::core::shell::Verbosity;
|
use crate::core::shell::Verbosity;
|
||||||
use crate::core::{TargetKind, Workspace};
|
use crate::core::{TargetKind, Workspace};
|
||||||
use crate::ops;
|
use crate::ops;
|
||||||
@ -176,6 +177,7 @@ fn run_doc_tests(
|
|||||||
let gctx = ws.gctx();
|
let gctx = ws.gctx();
|
||||||
let mut errors = Vec::new();
|
let mut errors = Vec::new();
|
||||||
let doctest_xcompile = gctx.cli_unstable().doctest_xcompile;
|
let doctest_xcompile = gctx.cli_unstable().doctest_xcompile;
|
||||||
|
let color = gctx.shell().color_choice();
|
||||||
|
|
||||||
for doctest_info in &compilation.to_doc_test {
|
for doctest_info in &compilation.to_doc_test {
|
||||||
let Doctest {
|
let Doctest {
|
||||||
@ -215,6 +217,14 @@ fn run_doc_tests(
|
|||||||
for (var, value) in env {
|
for (var, value) in env {
|
||||||
p.env(var, value);
|
p.env(var, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let color_arg = match color {
|
||||||
|
ColorChoice::Always => "always",
|
||||||
|
ColorChoice::Never => "never",
|
||||||
|
ColorChoice::CargoAuto => "auto",
|
||||||
|
};
|
||||||
|
p.arg("--color").arg(color_arg);
|
||||||
|
|
||||||
p.arg("--crate-name").arg(&unit.target.crate_name());
|
p.arg("--crate-name").arg(&unit.target.crate_name());
|
||||||
p.arg("--test");
|
p.arg("--test");
|
||||||
|
|
||||||
|
@ -2871,7 +2871,7 @@ fn env_test() {
|
|||||||
[RUNNING] `[ROOT]/foo/target/debug/deps/foo-[HASH][EXE]`
|
[RUNNING] `[ROOT]/foo/target/debug/deps/foo-[HASH][EXE]`
|
||||||
[RUNNING] `[ROOT]/foo/target/debug/deps/test-[HASH][EXE]`
|
[RUNNING] `[ROOT]/foo/target/debug/deps/test-[HASH][EXE]`
|
||||||
[DOCTEST] foo
|
[DOCTEST] foo
|
||||||
[RUNNING] `rustdoc --edition=2015 --crate-type lib --crate-name foo[..]`
|
[RUNNING] `rustdoc --edition=2015 --crate-type lib --color auto --crate-name foo[..]`
|
||||||
|
|
||||||
"#]])
|
"#]])
|
||||||
.with_stdout_data(str![[r#"
|
.with_stdout_data(str![[r#"
|
||||||
|
@ -619,7 +619,7 @@ fn cdylib_and_rlib() {
|
|||||||
[RUNNING] `[ROOT]/foo/target/release/deps/bar-[HASH][EXE]`
|
[RUNNING] `[ROOT]/foo/target/release/deps/bar-[HASH][EXE]`
|
||||||
[RUNNING] `[ROOT]/foo/target/release/deps/b-[HASH][EXE]`
|
[RUNNING] `[ROOT]/foo/target/release/deps/b-[HASH][EXE]`
|
||||||
[DOCTEST] bar
|
[DOCTEST] bar
|
||||||
[RUNNING] `rustdoc --edition=2015 --crate-type cdylib --crate-type rlib --crate-name bar --test [..]-C lto [..]
|
[RUNNING] `rustdoc --edition=2015 --crate-type cdylib --crate-type rlib --color auto --crate-name bar --test [..]-C lto [..]
|
||||||
|
|
||||||
"#]].unordered())
|
"#]].unordered())
|
||||||
.run();
|
.run();
|
||||||
|
@ -5555,7 +5555,7 @@ fn cargo_test_print_env_verbose() {
|
|||||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
[RUNNING] `[..]CARGO_MANIFEST_DIR=[ROOT]/foo[..] [ROOT]/foo/target/debug/deps/foo-[HASH][EXE]`
|
[RUNNING] `[..]CARGO_MANIFEST_DIR=[ROOT]/foo[..] [ROOT]/foo/target/debug/deps/foo-[HASH][EXE]`
|
||||||
[DOCTEST] foo
|
[DOCTEST] foo
|
||||||
[RUNNING] `[..]CARGO_MANIFEST_DIR=[ROOT]/foo[..] rustdoc --edition=2015 --crate-type lib --crate-name foo[..]`
|
[RUNNING] `[..]CARGO_MANIFEST_DIR=[ROOT]/foo[..] rustdoc --edition=2015 --crate-type lib --color auto --crate-name foo[..]`
|
||||||
|
|
||||||
"#]]).run();
|
"#]]).run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user