Skip to content

Commit 4161d65

Browse files
committed
test(apple): pin the replacement bundle's mtime so the key must move
The in-place replacement case relied on the filesystem to make both halves of the memo key differ. On ext4 or tmpfs a freed inode is reused and two writes can land in one truncated millisecond, leaving the key untouched and the case red. Set the replacement's mtime explicitly. Also drop the claim that two probers read the selection link path; only the toolchain probe does.
1 parent d33b804 commit 4161d65

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎packages/platform-apple/src/runner/__tests__/runner-toolchain-probe.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,15 @@ describe('the developer dir a toolchain fingerprint answers for', () => {
317317

318318
// The installer writes a new bundle: same path, new inode for the version file.
319319
const versionFile = path.join(selected, '..', 'version.plist');
320+
const replacedAt = fs.statSync(versionFile).mtimeMs + 1_000;
320321
fs.unlinkSync(versionFile);
321322
fs.writeFileSync(versionFile, '<plist>build 2</plist>\n');
323+
// Not left to the filesystem to make the two halves of the identity differ. On ext4 or tmpfs a
324+
// freed inode comes straight back out, and the two writes can land in one truncated millisecond,
325+
// which would leave the key untouched and this case red for a reason the fix has nothing to do
326+
// with. A replacement bundle is written after the one it replaces, so one second later says that
327+
// wherever the temp dir lives.
328+
fs.utimesSync(versionFile, new Date(replacedAt), new Date(replacedAt));
322329

323330
runCmdSync.mockClear();
324331
expect(readFingerprint().xcodeBuildVersion).toBe(STUBBED_APPLE_TOOLCHAIN.xcodeBuildVersion);

‎packages/platform-apple/src/runner/apple-runner-platform.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export const COLD_TOOLCHAIN_PROBE_TIMEOUT_MS = 30_000;
2424
/**
2525
* The symlink `xcode-select -s` writes and `xcode-select -p` reads back. Resolving it answers which
2626
* developer dir the host selects, without a subprocess, so the toolchain memo can key on that answer
27-
* on a hit as well as on a miss. Beside the probe ceiling above so both Apple toolchain probers read
28-
* one value without either owning it.
27+
* on a hit as well as on a miss. Beside the probe ceiling above so the constant sits with the
28+
* toolchain constants this package shares rather than inside the one module that reads it.
2929
*/
3030
export const XCODE_SELECT_LINK_PATH = '/var/db/xcode_select_link';
3131

0 commit comments

Comments
 (0)