Skip to content

Commit 3e61534

Browse files
fix(apple): say what a runner failure report guarantees about its entry
The recorded selection outlives the entry it names: the memo's TTL is measured from the read that stored the entry, so a report can look it up after that entry is gone. Say that, and pin the case with a test that a report then names no Xcode rather than another selection's. Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
1 parent d2e5aad commit 3e61534

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,20 @@ describe('the lifetime of a memoized toolchain fingerprint', () => {
351351
expect(runCmdSync.mock.calls.map(([command]) => command)).toEqual(['xcode-select']);
352352
});
353353

354+
test('a report names no Xcode once the entry its selection recorded has expired', () => {
355+
scriptSelectableXcodes();
356+
readFingerprint();
357+
expect(memoizedRunnerXcodeVersion(IOS_SIMULATOR)).toBe(STUBBED_APPLE_TOOLCHAIN.xcodeVersion);
358+
359+
// The selection stays recorded past expiry; what goes away is the entry behind it, and a report
360+
// answers with nothing rather than probing or naming another selection's Xcode.
361+
advance(FINGERPRINT_TTL_MS);
362+
runCmdSync.mockClear();
363+
364+
expect(memoizedRunnerXcodeVersion(IOS_SIMULATOR)).toBeUndefined();
365+
expect(runCmdSync.mock.calls).toEqual([]);
366+
});
367+
354368
test('a fingerprint expired under one selection is read again under the current one', () => {
355369
scriptSelectableXcodes();
356370
readFingerprint();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function toolchainFingerprintCache(): TtlMemo<string, RunnerToolchainFingerprint
128128
/**
129129
* The selection the last default-selection read resolved, which is the entry a failure report
130130
* without a client-chosen `DEVELOPER_DIR` names. A read that threw or could not resolve its
131-
* selection leaves it alone, so it always names a dir with an entry behind it.
131+
* selection leaves it alone. The entry it names can expire, and a report then names no Xcode.
132132
*/
133133
let recordedDefaultSelection: string | undefined;
134134

0 commit comments

Comments
 (0)