diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 1166ea6832cb..91a2b6bbe043 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -126,7 +126,7 @@ fn run_unit_tests( script_meta, } in compilation.tests.iter() { - let (exe_display, cmd) = cmd_builds( + let (exe_display, mut cmd) = cmd_builds( config, cwd, unit, @@ -136,6 +136,11 @@ fn run_unit_tests( compilation, "unittests", )?; + + if config.extra_verbose() { + cmd.display_env_vars(); + } + config .shell() .concise(|shell| shell.status("Running", &exe_display))?; @@ -266,9 +271,14 @@ fn run_doc_tests( p.arg("-Zunstable-options"); } + if config.extra_verbose() { + p.display_env_vars(); + } + config .shell() .verbose(|shell| shell.status("Running", p.to_string()))?; + if let Err(e) = p.exec() { let code = fail_fast_code(&e); let unit_err = UnitTestError { diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 4820c7dcd788..a796a56c9ef4 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -4861,3 +4861,23 @@ error: unexpected argument `--keep-going` found .with_status(101) .run(); } + +#[cargo_test] +fn print_env_verbose() { + let p = project() + .file("Cargo.toml", &basic_manifest("foo", "0.0.1")) + .file("src/lib.rs", "") + .build(); + + p.cargo("test -vv") + .with_stderr("\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc --crate-name foo[..]` +[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc --crate-name foo[..]` +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] [CWD]/target/debug/deps/foo-[..][EXE]` + Doc-tests foo +[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustdoc --crate-type lib --crate-name foo[..]" + ) + .run(); +}