diff options
| author | The Miri Conjob Bot <miri@cron.bot> | 2023-09-23 05:17:05 +0000 |
|---|---|---|
| committer | The Miri Conjob Bot <miri@cron.bot> | 2023-09-23 05:17:05 +0000 |
| commit | 3ca49cfe9d0ab73f3ee33f6f216b1d001f7cd073 (patch) | |
| tree | 8981d23317d71c12ac7a3e1241f1fed1fee34d41 /library/std/src/process/tests.rs | |
| parent | 68706342323af86d58595d43a725637b42783675 (diff) | |
| parent | 79d685325c170f0aed483e4c50c1f2b7d5b2bdc1 (diff) | |
| download | rust-3ca49cfe9d0ab73f3ee33f6f216b1d001f7cd073.tar.gz rust-3ca49cfe9d0ab73f3ee33f6f216b1d001f7cd073.zip | |
Merge from rustc
Diffstat (limited to 'library/std/src/process/tests.rs')
| -rw-r--r-- | library/std/src/process/tests.rs | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index 00636237288..07d4de5c1a2 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -537,7 +537,7 @@ fn env_empty() { #[test] #[cfg(not(windows))] #[cfg_attr(any(target_os = "emscripten", target_env = "sgx"), ignore)] -fn main() { +fn debug_print() { const PIDFD: &'static str = if cfg!(target_os = "linux") { " create_pidfd: false,\n" } else { "" }; @@ -626,6 +626,51 @@ fn main() { {PIDFD}}}"# ) ); + + let mut command_with_removed_env = Command::new("boring-name"); + command_with_removed_env.env_remove("FOO").env_remove("BAR"); + assert_eq!(format!("{command_with_removed_env:?}"), r#"env -u BAR -u FOO "boring-name""#); + assert_eq!( + format!("{command_with_removed_env:#?}"), + format!( + r#"Command {{ + program: "boring-name", + args: [ + "boring-name", + ], + env: CommandEnv {{ + clear: false, + vars: {{ + "BAR": None, + "FOO": None, + }}, + }}, +{PIDFD}}}"# + ) + ); + + let mut command_with_cleared_env = Command::new("boring-name"); + command_with_cleared_env.env_clear().env("BAR", "val").env_remove("FOO"); + assert_eq!(format!("{command_with_cleared_env:?}"), r#"env -i BAR="val" "boring-name""#); + assert_eq!( + format!("{command_with_cleared_env:#?}"), + format!( + r#"Command {{ + program: "boring-name", + args: [ + "boring-name", + ], + env: CommandEnv {{ + clear: true, + vars: {{ + "BAR": Some( + "val", + ), + }}, + }}, +{PIDFD}}}"# + ) + ); } // See issue #91991 |
