Skip to content

Commit 4c39ad3

Browse files
authored
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.
1 parent 24be9ac commit 4c39ad3

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

codex-rs/app-server/tests/common/mcp_process.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ impl McpProcess {
118118
Self::new_with_env(codex_home, &[(DISABLE_MANAGED_CONFIG_ENV_VAR, Some("1"))]).await
119119
}
120120

121+
pub async fn new_without_managed_config_with_env(
122+
codex_home: &Path,
123+
env_overrides: &[(&str, Option<&str>)],
124+
) -> anyhow::Result<Self> {
125+
let mut all_env_overrides = vec![(DISABLE_MANAGED_CONFIG_ENV_VAR, Some("1"))];
126+
all_env_overrides.extend_from_slice(env_overrides);
127+
Self::new_with_env(codex_home, &all_env_overrides).await
128+
}
129+
121130
pub async fn new_with_plugin_startup_tasks(codex_home: &Path) -> anyhow::Result<Self> {
122131
Self::new_with_env_and_args(codex_home, &[], &[]).await
123132
}

codex-rs/app-server/tests/suite/v2/plugin_list.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,15 @@ async fn plugin_list_returns_empty_when_workspace_codex_plugins_disabled() -> Re
307307
.mount(&server)
308308
.await;
309309

310-
let mut mcp = McpProcess::new_without_managed_config(codex_home.path()).await?;
310+
let home = codex_home.path().to_string_lossy().into_owned();
311+
let mut mcp = McpProcess::new_without_managed_config_with_env(
312+
codex_home.path(),
313+
&[
314+
("HOME", Some(home.as_str())),
315+
("USERPROFILE", Some(home.as_str())),
316+
],
317+
)
318+
.await?;
311319
timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??;
312320

313321
let request_id = mcp
@@ -388,7 +396,15 @@ async fn plugin_list_reuses_cached_workspace_codex_plugins_setting() -> Result<(
388396
.mount(&server)
389397
.await;
390398

391-
let mut mcp = McpProcess::new_without_managed_config(codex_home.path()).await?;
399+
let home = codex_home.path().to_string_lossy().into_owned();
400+
let mut mcp = McpProcess::new_without_managed_config_with_env(
401+
codex_home.path(),
402+
&[
403+
("HOME", Some(home.as_str())),
404+
("USERPROFILE", Some(home.as_str())),
405+
],
406+
)
407+
.await?;
392408
timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??;
393409

394410
for _ in 0..2 {

0 commit comments

Comments
 (0)