From 27ffd75f035af17abe4fda53f8d2dcf40c8d9a73 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 21 Apr 2026 16:34:58 +0900 Subject: [PATCH] fix: #140 isolate test cwd + env in punctuation_bearing_single_token test Previously this test inherited the cargo test runner's CWD, which could contain a stale .claw/settings.json with "permissionMode": "acceptEdits" written by another test. The deprecated-field resolver then silently downgraded the default permission mode to WorkspaceWrite, breaking the test's assertion. Fix: wrap the assertion in with_current_dir() + env_lock() so the test runs in an isolated temp directory with no stale config. Full workspace test now passes except for pre-existing resume_latest flake (unrelated to #140, environment-dependent, tracked separately). Closes ROADMAP #140. --- rust/crates/rusty-claude-cli/src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index 5efdd32..f9b1105 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -10061,9 +10061,19 @@ mod tests { #[test] fn punctuation_bearing_single_token_still_dispatches_to_prompt() { - assert_eq!( + // #140: Guard against test pollution — isolate cwd + env so this test + // doesn't pick up a stale .claw/settings.json from other tests that + // may have set `permissionMode: acceptEdits` in a shared cwd. + let _guard = env_lock(); + let root = temp_dir(); + let cwd = root.join("project"); + std::fs::create_dir_all(&cwd).expect("project dir should exist"); + let result = with_current_dir(&cwd, || { parse_args(&["PARITY_SCENARIO:bash_permission_prompt_approved".to_string()]) - .expect("scenario token should still dispatch to prompt"), + .expect("scenario token should still dispatch to prompt") + }); + assert_eq!( + result, CliAction::Prompt { prompt: "PARITY_SCENARIO:bash_permission_prompt_approved".to_string(), model: DEFAULT_MODEL.to_string(),