From 4c39ad33cbe920f88122a8bd7c7e5eec88bbf328 Mon Sep 17 00:00:00 2001 From: canvrno-oai Date: Tue, 28 Apr 2026 18:34:38 -0700 Subject: [PATCH] Fix plugin list workspace settings test isolation (#20086) Fixes test that often fails locally when running `cargo test` - Add an app-server test helper that combines managed-config isolation with custom env overrides. - Isolate `HOME` / `USERPROFILE` in plugin-list workspace settings tests so host home marketplaces do not affect results. --- .../app-server/tests/common/mcp_process.rs | 9 +++++++++ .../app-server/tests/suite/v2/plugin_list.rs | 20 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/codex-rs/app-server/tests/common/mcp_process.rs b/codex-rs/app-server/tests/common/mcp_process.rs index bcd364c74..81be41f21 100644 --- a/codex-rs/app-server/tests/common/mcp_process.rs +++ b/codex-rs/app-server/tests/common/mcp_process.rs @@ -118,6 +118,15 @@ impl McpProcess { Self::new_with_env(codex_home, &[(DISABLE_MANAGED_CONFIG_ENV_VAR, Some("1"))]).await } + pub async fn new_without_managed_config_with_env( + codex_home: &Path, + env_overrides: &[(&str, Option<&str>)], + ) -> anyhow::Result { + let mut all_env_overrides = vec![(DISABLE_MANAGED_CONFIG_ENV_VAR, Some("1"))]; + all_env_overrides.extend_from_slice(env_overrides); + Self::new_with_env(codex_home, &all_env_overrides).await + } + pub async fn new_with_plugin_startup_tasks(codex_home: &Path) -> anyhow::Result { Self::new_with_env_and_args(codex_home, &[], &[]).await } diff --git a/codex-rs/app-server/tests/suite/v2/plugin_list.rs b/codex-rs/app-server/tests/suite/v2/plugin_list.rs index 23f6e5496..51e5d8dd8 100644 --- a/codex-rs/app-server/tests/suite/v2/plugin_list.rs +++ b/codex-rs/app-server/tests/suite/v2/plugin_list.rs @@ -307,7 +307,15 @@ async fn plugin_list_returns_empty_when_workspace_codex_plugins_disabled() -> Re .mount(&server) .await; - let mut mcp = McpProcess::new_without_managed_config(codex_home.path()).await?; + let home = codex_home.path().to_string_lossy().into_owned(); + let mut mcp = McpProcess::new_without_managed_config_with_env( + codex_home.path(), + &[ + ("HOME", Some(home.as_str())), + ("USERPROFILE", Some(home.as_str())), + ], + ) + .await?; timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??; let request_id = mcp @@ -388,7 +396,15 @@ async fn plugin_list_reuses_cached_workspace_codex_plugins_setting() -> Result<( .mount(&server) .await; - let mut mcp = McpProcess::new_without_managed_config(codex_home.path()).await?; + let home = codex_home.path().to_string_lossy().into_owned(); + let mut mcp = McpProcess::new_without_managed_config_with_env( + codex_home.path(), + &[ + ("HOME", Some(home.as_str())), + ("USERPROFILE", Some(home.as_str())), + ], + ) + .await?; timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??; for _ in 0..2 {