From ac91c14443c11c4279a9305099354e443c6fa7d4 Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Tue, 3 Nov 2026 06:48:41 +0000 Subject: [PATCH] Make native startup libraries available to Windows voice-host tests (#59082) ## What changed Add a shared command builder for `codex-voice-host` integration tests. On Windows MSVC builds with Bazel runfiles available, locate the architecture-specific voice runtime and prepend its `bin` directory to the helper's `PATH`. Use the builder for lifecycle helper launches and build-identity queries in the lifecycle, installed-client, and packaged-runtime tests. GitOrigin-RevId: c9fbd0769842eb4ee20742e126a9c4173dd7e128 --- codex-rs/voice-host/tests/common/mod.rs | 31 +++++++++++++++++++ codex-rs/voice-host/tests/installed_client.rs | 6 ++-- codex-rs/voice-host/tests/lifecycle.rs | 9 +++--- codex-rs/voice-host/tests/packaged_runtime.rs | 6 ++-- 4 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 codex-rs/voice-host/tests/common/mod.rs diff --git a/codex-rs/voice-host/tests/common/mod.rs b/codex-rs/voice-host/tests/common/mod.rs new file mode 100644 index 0000000000..6ff3250159 --- /dev/null +++ b/codex-rs/voice-host/tests/common/mod.rs @@ -0,0 +1,31 @@ +//! Launches the helper with its Bazel-provided native startup libraries available. + +#[cfg(all(windows, target_env = "msvc"))] +use std::env; + +#[cfg(all(windows, target_env = "msvc"))] +use anyhow::Context; +use anyhow::Result; +use codex_utils_cargo_bin::cargo_bin; +use tokio::process::Command; + +pub(crate) fn voice_host_command() -> Result { + let command = Command::new(cargo_bin("codex-voice-host")?); + #[cfg(all(windows, target_env = "msvc"))] + let mut command = command; + #[cfg(all(windows, target_env = "msvc"))] + if codex_utils_cargo_bin::runfiles_available() { + let resource = format!( + "../../third_party/voice/native_link_windows_{}/runtime.json", + env::consts::ARCH + ); + let runtime = codex_utils_cargo_bin::find_resource!(resource)?; + let runtime_bin = runtime.parent().context("voice runtime root")?.join("bin"); + let path = env::join_paths( + std::iter::once(runtime_bin) + .chain(env::split_paths(&env::var_os("PATH").unwrap_or_default())), + )?; + command.env("PATH", path); + } + Ok(command) +} diff --git a/codex-rs/voice-host/tests/installed_client.rs b/codex-rs/voice-host/tests/installed_client.rs index d865255890..df6ba876fa 100644 --- a/codex-rs/voice-host/tests/installed_client.rs +++ b/codex-rs/voice-host/tests/installed_client.rs @@ -1,5 +1,7 @@ //! Exercise the production client against copied helper packages and startup libraries. +mod common; + use std::fs; use std::path::Path; use std::path::PathBuf; @@ -14,9 +16,9 @@ use codex_install_context::InstallContext; use codex_realtime_webrtc::SessionDescription; use codex_realtime_webrtc::VoiceHost; use codex_utils_cargo_bin::cargo_bin; +use common::voice_host_command; use futures::future::BoxFuture; use pretty_assertions::assert_eq; -use tokio::process::Command; use tokio::sync::Notify; use tokio::sync::mpsc; use tokio::time::timeout; @@ -36,7 +38,7 @@ const DEADLINE: Duration = Duration::from_secs(/*secs*/ 10); async fn build_commit() -> Result { let output = timeout( DEADLINE, - Command::new(cargo_bin("codex-voice-host")?) + voice_host_command()? .arg("--build-commit") .kill_on_drop(true) .output(), diff --git a/codex-rs/voice-host/tests/lifecycle.rs b/codex-rs/voice-host/tests/lifecycle.rs index a7c18fcdb9..157c5aebbb 100644 --- a/codex-rs/voice-host/tests/lifecycle.rs +++ b/codex-rs/voice-host/tests/lifecycle.rs @@ -1,5 +1,7 @@ //! Exercise the real helper protocol and bounded process I/O. +mod common; + use std::process::Stdio; use std::time::Duration; @@ -8,18 +10,17 @@ use anyhow::Result; use codex_realtime_webrtc::Message; use codex_realtime_webrtc::decode_frame; use codex_realtime_webrtc::encode_frame; -use codex_utils_cargo_bin::cargo_bin; +use common::voice_host_command; use pretty_assertions::assert_eq; use tokio::io::AsyncReadExt; use tokio::io::AsyncWriteExt; use tokio::process::Child; -use tokio::process::Command; use tokio::time::timeout; const DEADLINE: Duration = Duration::from_secs(/*secs*/ 10); fn spawn() -> Result { - Ok(Command::new(cargo_bin("codex-voice-host")?) + Ok(voice_host_command()? .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) @@ -30,7 +31,7 @@ fn spawn() -> Result { async fn build_commit() -> Result { let output = timeout( DEADLINE, - Command::new(cargo_bin("codex-voice-host")?) + voice_host_command()? .arg("--build-commit") .kill_on_drop(true) .output(), diff --git a/codex-rs/voice-host/tests/packaged_runtime.rs b/codex-rs/voice-host/tests/packaged_runtime.rs index 2a53063ba7..4041c04c7b 100644 --- a/codex-rs/voice-host/tests/packaged_runtime.rs +++ b/codex-rs/voice-host/tests/packaged_runtime.rs @@ -1,5 +1,7 @@ //! Exercise native initialization with real prepared libraries in a relocated package. +mod common; + use std::fs; use std::time::Duration; @@ -9,7 +11,7 @@ use anyhow::ensure; use codex_install_context::InstallContext; use codex_realtime_webrtc::VoiceHost; use codex_utils_cargo_bin::cargo_bin; -use tokio::process::Command; +use common::voice_host_command; use tokio::time::timeout; const DEADLINE: Duration = Duration::from_secs(/*secs*/ 10); @@ -64,7 +66,7 @@ async fn relocated_runtime_initializes_closes_and_rejects_duplicate_initializati .context("package layout")?; let output = timeout( DEADLINE, - Command::new(&helper_source) + voice_host_command()? .arg("--build-commit") .kill_on_drop(true) .output(),