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.
This commit is contained in:
can1357
2026-07-27 04:34:14 +02:00
parent 4aa5d0b6b2
commit 03d9b7f048
@@ -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");
}