From 03d9b7f048b006a41b4d3d67bbf13a8f625327dd Mon Sep 17 00:00:00 2001 From: can1357 Date: Mon, 27 Jul 2026 04:34:14 +0200 Subject: [PATCH] fix(coding-agent): canonicalized config paths in failure-safety test injections The lock-race and EPERM regression tests compared injection predicates against the uncanonicalized temp config path, but the atomic writer resolves it via realpath; on macOS /var -> /private/var made the mocks never fire and both tests failed. Compared against the realpath instead. --- packages/coding-agent/test/settings-manager.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/coding-agent/test/settings-manager.test.ts b/packages/coding-agent/test/settings-manager.test.ts index fe8ef5e7c..5192465b7 100644 --- a/packages/coding-agent/test/settings-manager.test.ts +++ b/packages/coding-agent/test/settings-manager.test.ts @@ -186,10 +186,11 @@ describe("Settings", () => { const backupPath = `${configPath}.broken-other-process`; const original = 'modelRoles:\n default: "unterminated\n'; await Bun.write(configPath, original); + const canonicalConfigPath = await fs.promises.realpath(configPath); const withFileLock = fileLock.withFileLock; let movedAside = false; vi.spyOn(fileLock, "withFileLock").mockImplementation(async (filePath, fn, options) => { - if (!movedAside && filePath === configPath) { + if (!movedAside && filePath === canonicalConfigPath) { await fs.promises.rename(configPath, backupPath); movedAside = true; } @@ -295,10 +296,11 @@ describe("Settings", () => { it("falls back to move-aside replacement when Windows reports EPERM", async () => { await writeSettings({ setupVersion: 1 }); const settings = await Settings.init({ cwd: projectDir, agentDir }); + const canonicalConfigPath = await fs.promises.realpath(getConfigPath()); const rename = fs.promises.rename.bind(fs.promises); let injected = false; vi.spyOn(fs.promises, "rename").mockImplementation(async (source, target) => { - if (!injected && String(source).endsWith(".tmp") && String(target) === getConfigPath()) { + if (!injected && String(source).endsWith(".tmp") && String(target) === canonicalConfigPath) { injected = true; throw new FsCodeError("EPERM", "injected Windows replacement failure"); }