Skip to content

Commit 5405cd3

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

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/cargo/ops/cargo_run.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ pub fn run(
100100
// by `compile.target_process` (the package's root directory)
101101
process.args(args).cwd(config.cwd());
102102

103+
if config.extra_verbose() {
104+
process.display_env_vars();
105+
}
106+
103107
config.shell().status("Running", process.to_string())?;
104108

105109
process.exec_replace()

tests/testsuite/run.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Tests for the `cargo run` command.
22
3-
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, project, Project};
3+
use cargo_test_support::{
4+
basic_bin_manifest, basic_lib_manifest, basic_manifest, project, Project,
5+
};
46
use cargo_util::paths::dylib_path_envvar;
57

68
#[cargo_test]
@@ -1416,6 +1418,24 @@ fn default_run_workspace() {
14161418
p.cargo("run").with_stdout("run-a").run();
14171419
}
14181420

1421+
#[cargo_test]
1422+
fn print_env_verbose() {
1423+
let p = project()
1424+
.file("Cargo.toml", &basic_manifest("a", "0.0.1"))
1425+
.file("src/main.rs", r#"fn main() {println!("run-a");}"#)
1426+
.build();
1427+
1428+
p.cargo("run -vv")
1429+
.with_stderr(
1430+
"\
1431+
[COMPILING] a v0.0.1 ([CWD])
1432+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc --crate-name a[..]`
1433+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1434+
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] target/debug/a[EXE]`",
1435+
)
1436+
.run();
1437+
}
1438+
14191439
#[cargo_test]
14201440
#[cfg(target_os = "macos")]
14211441
fn run_link_system_path_macos() {

0 commit comments

Comments
 (0)