Skip to content

Commit fc359bf

Browse files
committed
inherit envs for child processes
1 parent 50bc39c commit fc359bf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

crates/fspy/tests/test_utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ macro_rules! track_child {
4646
#[allow(unused)]
4747
pub async fn spawn_std(std_cmd: std::process::Command) -> anyhow::Result<PathAccessIterable> {
4848
let mut command = fspy::Command::new(std_cmd.get_program());
49-
command.args(std_cmd.get_args());
49+
command
50+
.args(std_cmd.get_args())
51+
.envs(std_cmd.get_envs().filter_map(|(name, value)| Some((name, value?))));
5052

5153
let termination = command.spawn().await?.wait_handle.await?;
5254
assert!(termination.status.success());

crates/fspy_test_utils/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ pub fn create_command(id: &str, arg: impl Encode) -> Command {
5454
let arg_base64 = BASE64_STANDARD_NO_PAD.encode(&arg_bytes);
5555
command.arg(id).arg(arg_base64);
5656

57+
// Set inherit environment explicitly, in case it needs to be converted to fspy::Command later
58+
command.env_clear().envs(std::env::vars_os());
59+
5760
command
5861
}
5962

0 commit comments

Comments
 (0)