mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Fix multi-environment unified exec test
Use a command-backed remote environment so the test covers remote selection without depending on an unreachable websocket during session startup. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -206,6 +206,7 @@ pub struct TestCodexBuilder {
|
||||
home: Option<Arc<TempDir>>,
|
||||
user_shell_override: Option<Shell>,
|
||||
exec_server_url: Option<String>,
|
||||
environment_manager_config: Option<codex_exec_server::ConfiguredEnvironmentManagerArgs>,
|
||||
}
|
||||
|
||||
impl TestCodexBuilder {
|
||||
@@ -262,6 +263,14 @@ impl TestCodexBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_environment_manager_config(
|
||||
mut self,
|
||||
config: codex_exec_server::ConfiguredEnvironmentManagerArgs,
|
||||
) -> Self {
|
||||
self.environment_manager_config = Some(config);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_windows_cmd_shell(self) -> Self {
|
||||
if cfg!(windows) {
|
||||
self.with_user_shell(get_shell_by_model_provided_path(&PathBuf::from("cmd.exe")))
|
||||
@@ -357,16 +366,21 @@ impl TestCodexBuilder {
|
||||
let (config, fallback_cwd) = self
|
||||
.prepare_config(base_url, &home, test_env.cwd().clone())
|
||||
.await?;
|
||||
let exec_server_url = self
|
||||
.exec_server_url
|
||||
.clone()
|
||||
.or_else(|| test_env.exec_server_url().map(str::to_owned));
|
||||
let environment_manager = Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
codex_exec_server::EnvironmentManagerArgs {
|
||||
exec_server_url,
|
||||
local_runtime_paths: None,
|
||||
},
|
||||
));
|
||||
let environment_manager = match self.environment_manager_config.clone() {
|
||||
Some(config) => Arc::new(codex_exec_server::EnvironmentManager::try_new(config)?),
|
||||
None => {
|
||||
let exec_server_url = self
|
||||
.exec_server_url
|
||||
.clone()
|
||||
.or_else(|| test_env.exec_server_url().map(str::to_owned));
|
||||
Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
codex_exec_server::EnvironmentManagerArgs {
|
||||
exec_server_url,
|
||||
local_runtime_paths: None,
|
||||
},
|
||||
))
|
||||
}
|
||||
};
|
||||
let file_system = test_env.environment().get_filesystem();
|
||||
let mut workspace_setups = vec![];
|
||||
swap(&mut self.workspace_setups, &mut workspace_setups);
|
||||
@@ -919,6 +933,7 @@ pub fn test_codex() -> TestCodexBuilder {
|
||||
home: None,
|
||||
user_shell_override: None,
|
||||
exec_server_url: None,
|
||||
environment_manager_config: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@ use std::sync::OnceLock;
|
||||
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use codex_exec_server::ConfiguredEnvironmentManagerArgs;
|
||||
use codex_exec_server::ConfiguredEnvironmentSpec;
|
||||
use codex_exec_server::CreateDirectoryOptions;
|
||||
use codex_exec_server::RemoteExecServerTransport;
|
||||
use codex_features::Feature;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
@@ -347,8 +350,19 @@ async fn unified_exec_environment_id_targets_non_primary_environment() -> Result
|
||||
skip_if_windows!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let codex_exe = codex_utils_cargo_bin::cargo_bin("codex")
|
||||
.or_else(|_| codex_utils_cargo_bin::cargo_bin("codex-exec"))?;
|
||||
let mut builder = test_codex()
|
||||
.with_exec_server_url("ws://127.0.0.1:9")
|
||||
.with_environment_manager_config(ConfiguredEnvironmentManagerArgs {
|
||||
default_environment: Some("local".to_string()),
|
||||
environments: vec![ConfiguredEnvironmentSpec {
|
||||
id: "remote".to_string(),
|
||||
transport: RemoteExecServerTransport::Command {
|
||||
command: format!("{codex_exe:?} exec-server --listen stdio://"),
|
||||
},
|
||||
}],
|
||||
local_runtime_paths: None,
|
||||
})
|
||||
.with_config(|config| {
|
||||
config
|
||||
.features
|
||||
@@ -362,6 +376,7 @@ async fn unified_exec_environment_id_targets_non_primary_environment() -> Result
|
||||
let test = builder.build(&server).await?;
|
||||
let selected_local_cwd = create_workspace_directory(&test, "selected-local").await?;
|
||||
let primary_remote_cwd = test.config.cwd.join("primary-remote");
|
||||
tokio::fs::create_dir_all(&primary_remote_cwd).await?;
|
||||
|
||||
let call_id = "uexec-env-local";
|
||||
let args = json!({
|
||||
|
||||
Reference in New Issue
Block a user