Print environment variables for cargo run in extra verbose mode

This commit is contained in:
Jakub Beránek 2023-08-14 20:38:24 +02:00
parent f13759445f
commit 5405cd3a8b
No known key found for this signature in database
GPG Key ID: 909CD0D26483516B
2 changed files with 25 additions and 1 deletions

View File

@ -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()

View File

@ -1,6 +1,8 @@
//! Tests for the `cargo run` command.
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, project, Project};
use cargo_test_support::{
basic_bin_manifest, basic_lib_manifest, basic_manifest, project, Project,
};
use cargo_util::paths::dylib_path_envvar;
#[cargo_test]
@ -1416,6 +1418,24 @@ fn default_run_workspace() {
p.cargo("run").with_stdout("run-a").run();
}
#[cargo_test]
fn print_env_verbose() {
let p = project()
.file("Cargo.toml", &basic_manifest("a", "0.0.1"))
.file("src/main.rs", r#"fn main() {println!("run-a");}"#)
.build();
p.cargo("run -vv")
.with_stderr(
"\
[COMPILING] a v0.0.1 ([CWD])
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc --crate-name a[..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] target/debug/a[EXE]`",
)
.run();
}
#[cargo_test]
#[cfg(target_os = "macos")]
fn run_link_system_path_macos() {