Skip to content

Commit 9267277

Browse files
committed
Print environment variables for cargo test in extra verbose mode
1 parent 5405cd3 commit 9267277

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
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/profile_targets.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fn profile_selection_test() {
328328
[RUNNING] `[..]/deps/foo-[..]`
329329
[RUNNING] `[..]/deps/test1-[..]`
330330
[DOCTEST] foo
331-
[RUNNING] `rustdoc [..]--test [..]
331+
[RUNNING] `[..] rustdoc [..]--test [..]
332332
").run();
333333
p.cargo("test -vv")
334334
.with_stderr_unordered(
@@ -341,7 +341,7 @@ fn profile_selection_test() {
341341
[RUNNING] `[..]/deps/foo-[..]`
342342
[RUNNING] `[..]/deps/test1-[..]`
343343
[DOCTEST] foo
344-
[RUNNING] `rustdoc [..]--test [..]
344+
[RUNNING] `[..] rustdoc [..]--test [..]
345345
",
346346
)
347347
.run();
@@ -395,7 +395,7 @@ fn profile_selection_test_release() {
395395
[RUNNING] `[..]/deps/foo-[..]`
396396
[RUNNING] `[..]/deps/test1-[..]`
397397
[DOCTEST] foo
398-
[RUNNING] `rustdoc [..]--test [..]`
398+
[RUNNING] `[..] rustdoc [..]--test [..]`
399399
").run();
400400
p.cargo("test --release -vv")
401401
.with_stderr_unordered(
@@ -408,7 +408,7 @@ fn profile_selection_test_release() {
408408
[RUNNING] `[..]/deps/foo-[..]`
409409
[RUNNING] `[..]/deps/test1-[..]`
410410
[DOCTEST] foo
411-
[RUNNING] `rustdoc [..]--test [..]
411+
[RUNNING] `[..] rustdoc [..]--test [..]
412412
",
413413
)
414414
.run();

tests/testsuite/test.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4861,3 +4861,24 @@ error: unexpected argument `--keep-going` found
48614861
.with_status(101)
48624862
.run();
48634863
}
4864+
4865+
#[cargo_test]
4866+
fn cargo_test_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+
"\
4875+
[COMPILING] foo v0.0.1 ([CWD])
4876+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc --crate-name foo[..]`
4877+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc --crate-name foo[..]`
4878+
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
4879+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] [CWD]/target/debug/deps/foo-[..][EXE]`
4880+
[DOCTEST] foo
4881+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustdoc --crate-type lib --crate-name foo[..]",
4882+
)
4883+
.run();
4884+
}

0 commit comments

Comments
 (0)