Skip to content

Commit

Permalink
Print environment variables for cargo run in extra verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Aug 14, 2023
1 parent f137594 commit 4807d25
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cargo/ops/cargo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ pub fn run(
// by `compile.target_process` (the package's root directory)
process.args(args).cwd(config.cwd());

if config.extra_verbose() {
process.display_env_vars();
}

config.shell().status("Running", process.to_string())?;

process.exec_replace()
Expand Down
17 changes: 17 additions & 0 deletions tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,23 @@ fn default_run_workspace() {
p.cargo("run").with_stdout("run-a").run();
}

#[cargo_test]
fn print_env_verbose() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "a"
version = "0.0.1"
"#,
)
.file("src/main.rs", r#"fn main() {println!("run-a");}"#)
.build();

p.cargo("run -vv").with_stderr("LD_LIBRARY_PATH").run();
}

#[cargo_test]
#[cfg(target_os = "macos")]
fn run_link_system_path_macos() {
Expand Down

0 comments on commit 4807d25

Please sign in to comment.