From 586ec02b517c857d0b3bdce12e43a9560b375ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Mon, 7 Oct 2024 10:40:02 +0200 Subject: [PATCH] Set HOME env var in test runner --- test/Cargo.lock | 1 + test/scripts/ssh-setup.sh | 5 +++-- test/test-runner/Cargo.toml | 1 + test/test-runner/src/main.rs | 18 +++++++++++++++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/test/Cargo.lock b/test/Cargo.lock index ab73938b6b7b..1467eb05fa2d 100644 --- a/test/Cargo.lock +++ b/test/Cargo.lock @@ -3508,6 +3508,7 @@ version = "0.0.0" dependencies = [ "bytes", "chrono", + "dirs", "futures", "libc", "log", diff --git a/test/scripts/ssh-setup.sh b/test/scripts/ssh-setup.sh index 08887d4aba6d..66809407d8ea 100644 --- a/test/scripts/ssh-setup.sh +++ b/test/scripts/ssh-setup.sh @@ -22,8 +22,9 @@ for file in test-runner connection-checker $APP_PACKAGE $PREVIOUS_APP $UI_RUNNER cp -f "$SCRIPT_DIR/$file" "$RUNNER_DIR" done -# Unprivileged users need execute rights for connection checker -chmod 551 "${RUNNER_DIR}/connection-checker" +# Unprivileged users need execute rights for some executables +chmod 775 "${RUNNER_DIR}/connection-checker" +chmod 775 "${RUNNER_DIR}/$UI_RUNNER" chown -R root "$RUNNER_DIR/" diff --git a/test/test-runner/Cargo.toml b/test/test-runner/Cargo.toml index 7206cb394a8d..8df61e7164f8 100644 --- a/test/test-runner/Cargo.toml +++ b/test/test-runner/Cargo.toml @@ -11,6 +11,7 @@ rust-version.workspace = true workspace = true [dependencies] +dirs = "5.0.1" futures = { workspace = true } tarpc = { workspace = true } tokio = { workspace = true } diff --git a/test/test-runner/src/main.rs b/test/test-runner/src/main.rs index 79bc17b4ef50..735e61360ec1 100644 --- a/test/test-runner/src/main.rs +++ b/test/test-runner/src/main.rs @@ -92,12 +92,24 @@ impl Service for TestServer { log::debug!("Exec {} (args: {args:?})", path); let mut cmd = Command::new(&path); + cmd.stdout(Stdio::piped()); + cmd.stderr(Stdio::piped()); + cmd.stdin(Stdio::piped()); cmd.args(args); - // Make sure that PATH is updated - // TODO: We currently do not need this on non-Windows #[cfg(target_os = "windows")] - cmd.env("PATH", sys::get_system_path_var()?); + { + // Make sure that PATH is updated + cmd.env("PATH", sys::get_system_path_var()?); + if let Some(home_dir) = dirs::home_dir() { + cmd.env("USERPROFILE", home_dir); + } + } + + #[cfg(unix)] + if let Some(home_dir) = dirs::home_dir() { + cmd.env("HOME", home_dir); + } cmd.envs(env);