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.
This commit is contained in:
YeonGyu-Kim 2026-04-21 16:34:58 +09:00
parent 0cf8241978
commit 27ffd75f03

View File

@ -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(),