From 006f7d7ee640e901b6f1619ebe5968cf7d04be79 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 8 Apr 2026 12:46:04 +0900 Subject: [PATCH] =?UTF-8?q?fix(test):=20add=20env=5Flock=20to=20plugin=20l?= =?UTF-8?q?ifecycle=20test=20=E2=80=94=20closes=20ROADMAP=20#24?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build_runtime_runs_plugin_lifecycle_init_and_shutdown was the only test that set/removed ANTHROPIC_API_KEY without holding the env_lock mutex. Under parallel workspace execution, other tests racing on the same env var could wipe the key mid-construction, causing a flaky credential error. Root cause: process-wide env vars are shared mutable state. All other tests that touch ANTHROPIC_API_KEY already use env_lock(). This test was the only holdout. Fix: add let _guard = env_lock(); at the top of the test. --- rust/crates/rusty-claude-cli/src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index e5d55e4..918fbfb 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -10816,6 +10816,9 @@ UU conflicted.rs", #[test] fn build_runtime_runs_plugin_lifecycle_init_and_shutdown() { + // Serialize access to process-wide env vars so parallel tests that + // set/remove ANTHROPIC_API_KEY do not race with this test. + let _guard = env_lock(); let config_home = temp_dir(); // Inject a dummy API key so runtime construction succeeds without real credentials. // This test only exercises plugin lifecycle (init/shutdown), never calls the API.