Skip to content

Commit fcd9500

Browse files
test(utils): state where a write through an alias lands
The misc lane at a4e8363 went from 51 failing tests to 2 on the hosted ubuntu arm. The two that remain describe the publish target for a write made through an alias, and both spellings predate the commit rename following the resolution taken under the lock: - safeWriteJson.lockKey.spec.ts read the caller's spelling and expected this writer's content there; on a case-sensitive filesystem the rename replaces the name the filesystem reported, so the peer keeps that entry under the spelling the caller was given. - safeWriteJson.test.ts expected the link node to be replaced in place and the referent to keep its seed; publishing on the resolved target leaves the alias a link that reads through to the payload, while the referent, the entry every writer to that file locks, carries the new content. guardedWrite.ts already binds its own publish to the resolved target, so the rows now describe the boundary the guard documents. No executable line changed: 16 lines added, 12 removed, all inside __tests__.
1 parent a4e8363 commit fcd9500

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎src/utils/__tests__/safeWriteJson.lockKey.spec.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,15 @@ describe("safeWriteJson lock key under a peer commit", () => {
326326
"the writer's spelling never appeared during acquisition, so the under-lock resolution had nothing to restate",
327327
).toEqual([true])
328328
expect(String(error && error.name)).toBe("undefined")
329-
expect(JSON.parse(await fs.readFile(upper, "utf8"))).toEqual({ mcpServers: { mine: true } })
329+
// The commit rename lands on the target the under-lock resolution named, which is the name
330+
// the filesystem reported during acquisition. On the case-folding filesystem the two
331+
// spellings are one entry, so reading either reports this writer's content. On the
332+
// case-sensitive one the rename replaces only that reported name: the other entry keeps the
333+
// peer's content under the spelling the caller was given, exactly as the hard-link pair was
334+
// laid out.
335+
expect(JSON.parse(await fs.readFile(lower, "utf8"))).toEqual({ mcpServers: { mine: true } })
330336
if (!foldsCase) {
331-
// The commit rename lands on the path the caller was given (safeWriteJson.ts:483), and on
332-
// a case-sensitive filesystem that names the other entry: the referent keeps the peer's
333-
// content and the writer's own spelling becomes a regular file. That is what the shipped
334-
// order does, so the row states it instead of asserting a result the platform never gives.
335-
expect(JSON.parse(await fs.readFile(lower, "utf8"))).toEqual({ mcpServers: { peer: true } })
337+
expect(JSON.parse(await fs.readFile(upper, "utf8"))).toEqual({ mcpServers: { peer: true } })
336338
}
337339
const entries = await fs.readdir(dir)
338340
// A case-folding filesystem holds one file and one artefact under the two spellings, so it

‎src/utils/__tests__/safeWriteJson.test.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,10 +1291,10 @@ describe("safeWriteJson", () => {
12911291
const alias = path.join(projectDir, "mcp.json")
12921292
await fs.symlink(referent, alias)
12931293

1294-
// Confining is about the scope, not about forbidding links: the write lands at
1295-
// the path the caller named. Main's body renames to that path and replaces the
1296-
// link node in place -- the alias becomes a regular file holding the payload and
1297-
// the old referent keeps the seed, matching the lock-referent test's contract.
1294+
// Confining is about the scope, not about forbidding links: the write lands on the
1295+
// target the under-lock resolution named -- the referent -- and not on the link node.
1296+
// The alias therefore stays a link and reads through to the payload, while the referent
1297+
// that holds the shared lock carries this writer's content in place of its seed.
12981298
await safeWriteJson(
12991299
alias,
13001300
{ mcpServers: { local: { url: "http://localhost" } } },
@@ -1304,8 +1304,10 @@ describe("safeWriteJson", () => {
13041304
expect(JSON.parse(await fsSyncActual.promises.readFile(alias, "utf8"))).toEqual({
13051305
mcpServers: { local: { url: "http://localhost" } },
13061306
})
1307-
expect(JSON.parse(await fsSyncActual.promises.readFile(referent, "utf8"))).toEqual({ mcpServers: {} })
1308-
expect(fsSyncActual.lstatSync(alias).isFile()).toBe(true)
1307+
expect(JSON.parse(await fsSyncActual.promises.readFile(referent, "utf8"))).toEqual({
1308+
mcpServers: { local: { url: "http://localhost" } },
1309+
})
1310+
expect(fsSyncActual.lstatSync(alias).isSymbolicLink()).toBe(true)
13091311
},
13101312
)
13111313

0 commit comments

Comments
 (0)