Skip to content

Commit f507281

Browse files
committed
Print environment variables for cargo test in extra verbose mode
1 parent 81ba1a3 commit f507281

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/cargo/ops/cargo_test.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn run_unit_tests(
126126
script_meta,
127127
} in compilation.tests.iter()
128128
{
129-
let (exe_display, cmd) = cmd_builds(
129+
let (exe_display, mut cmd) = cmd_builds(
130130
config,
131131
cwd,
132132
unit,
@@ -136,6 +136,11 @@ fn run_unit_tests(
136136
compilation,
137137
"unittests",
138138
)?;
139+
140+
if config.extra_verbose() {
141+
cmd.display_env_vars();
142+
}
143+
139144
config
140145
.shell()
141146
.concise(|shell| shell.status("Running", &exe_display))?;
@@ -266,9 +271,14 @@ fn run_doc_tests(
266271
p.arg("-Zunstable-options");
267272
}
268273

274+
if config.extra_verbose() {
275+
p.display_env_vars();
276+
}
277+
269278
config
270279
.shell()
271280
.verbose(|shell| shell.status("Running", p.to_string()))?;
281+
272282
if let Err(e) = p.exec() {
273283
let code = fail_fast_code(&e);
274284
let unit_err = UnitTestError {

tests/testsuite/test.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4861,3 +4861,23 @@ error: unexpected argument `--keep-going` found
48614861
.with_status(101)
48624862
.run();
48634863
}
4864+
4865+
#[cargo_test]
4866+
fn print_env_verbose() {
4867+
let p = project()
4868+
.file("Cargo.toml", &basic_manifest("foo", "0.0.1"))
4869+
.file("src/lib.rs", "")
4870+
.build();
4871+
4872+
p.cargo("test -vv")
4873+
.with_stderr("\
4874+
[COMPILING] foo v0.0.1 ([CWD])
4875+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc --crate-name foo[..]`
4876+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc --crate-name foo[..]`
4877+
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
4878+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] [CWD]/target/debug/deps/foo-[..][EXE]`
4879+
Doc-tests foo
4880+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustdoc --crate-type lib --crate-name foo[..]"
4881+
)
4882+
.run();
4883+
}

0 commit comments

Comments
 (0)