Skip to content

Commit 34ab803

Browse files
committed
refactor(ios): fake xcrun --find through the tool-provider seam, not a production option
xcrunShimPaths on XcrunShimProbeOptions let tests answer `xcrun --find` without going through the tool-provider, the seam testing.md already requires (no production exports or test-only dependency injection). Production call sites never passed it. withFakeXcrunHost already fakes `xcrun --find` through the real tool-provider seam, so every caller that passed xcrunShimPaths was already running inside that fake and can rely on it instead.
1 parent dee0555 commit 34ab803

5 files changed

Lines changed: 6 additions & 24 deletions

File tree

‎packages/platform-apple/src/core/__tests__/xcrun-shim-first-launch.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ test('equal versions disarm a hooked shim', async () => {
7979
devicectl: { expectedVersion: '629.3', installedVersion: '629.3' },
8080
});
8181

82-
const shims = await withFakeXcrunHost(host, () =>
83-
probeXcrunShimFirstLaunchHooks({ xcrunShimPaths: host.xcrunShimPaths }),
84-
);
82+
const shims = await withFakeXcrunHost(host, () => probeXcrunShimFirstLaunchHooks());
8583

8684
assert.deepEqual(
8785
shims.map((shim) => [shim.tool, shim.hook]),

‎packages/platform-apple/src/core/xcrun-shim-first-launch.ts‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ export type ArmedXcrunShimFirstLaunchHook = XcrunShimEvidence & {
6565
export type XctestDeviceSetCleanupArming = readonly XcrunShimFirstLaunchHook[];
6666

6767
export type XcrunShimProbeOptions = {
68-
/** Replaces `xcrun --find`: a tool absent from the map reads as not found. */
69-
xcrunShimPaths?: Readonly<Partial<Record<XcrunShimToolName, string>>>;
7068
/** The owning request's cancellation; an unanswered shim then reads as `probe_canceled`. */
7169
signal?: AbortSignal;
7270
};
@@ -80,15 +78,12 @@ export async function probeXcrunShimFirstLaunchHooks(
8078
const stoppedBy = (): XcrunShimArmedBy =>
8179
options.signal?.aborted ? 'probe_canceled' : 'probe_out_of_budget';
8280
return await Promise.all(
83-
XCRUN_SHIM_TOOL_NAMES.map(
84-
async (tool) => await probeWithinBudget(tool, options, signal, stoppedBy),
85-
),
81+
XCRUN_SHIM_TOOL_NAMES.map(async (tool) => await probeWithinBudget(tool, signal, stoppedBy)),
8682
);
8783
}
8884

8985
async function probeWithinBudget(
9086
tool: XcrunShimToolName,
91-
options: XcrunShimProbeOptions,
9287
signal: AbortSignal,
9388
stoppedBy: () => XcrunShimArmedBy,
9489
): Promise<XcrunShimFirstLaunchHook> {
@@ -106,7 +101,7 @@ async function probeWithinBudget(
106101
});
107102
signal.addEventListener('abort', onAbort, { once: true });
108103
try {
109-
return await Promise.race([readShimHook(evidence, options, signal), stopped]);
104+
return await Promise.race([readShimHook(evidence, signal), stopped]);
110105
} finally {
111106
signal.removeEventListener('abort', onAbort);
112107
}
@@ -121,11 +116,10 @@ function armed(
121116

122117
async function readShimHook(
123118
evidence: XcrunShimEvidence,
124-
options: XcrunShimProbeOptions,
125119
signal: AbortSignal,
126120
): Promise<XcrunShimFirstLaunchHook> {
127121
const { tool } = evidence;
128-
const shimPath = await locateShim(tool, options, signal);
122+
const shimPath = await locateShim(tool, signal);
129123
if (shimPath === null) return armed(evidence, 'shim_not_located');
130124
evidence.shimPath = shimPath;
131125
const text = await readShimText(shimPath, signal);
@@ -165,12 +159,7 @@ function settleShimHook(evidence: XcrunShimEvidence, shimPath: string): XcrunShi
165159
};
166160
}
167161

168-
async function locateShim(
169-
tool: XcrunShimToolName,
170-
options: XcrunShimProbeOptions,
171-
signal: AbortSignal,
172-
): Promise<string | null> {
173-
if (options.xcrunShimPaths) return options.xcrunShimPaths[tool] ?? null;
162+
async function locateShim(tool: XcrunShimToolName, signal: AbortSignal): Promise<string | null> {
174163
try {
175164
const result = await runAppleToolCommand('xcrun', ['--find', tool], {
176165
allowFailure: true,

‎packages/platform-apple/src/runner/__tests__/runner-device-set-cleanup-arming.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ async function acquire(layout: Layout, host: FakeXcrunHost, signal?: AbortSignal
7171
xctestDeviceSetPath: layout.xctestDeviceSetPath,
7272
backupPath: layout.backupPath,
7373
lockDirPath: layout.lockDirPath,
74-
xcrunShimPaths: host.xcrunShimPaths,
7574
signal,
7675
}),
7776
);

‎packages/platform-apple/src/runner/__tests__/runner-session-lifecycle.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ test('an armed xcrun shim refuses a scoped-set session before the runner launche
408408
await acquireRealSimulatorSetRedirect(device, {
409409
xctestDeviceSetPath,
410410
lockDirPath: path.join(root, 'xctest-device-set.lock'),
411-
xcrunShimPaths: host.xcrunShimPaths,
412411
}),
413412
);
414413
mockEnsureXctestrunArtifact.mockResolvedValue({

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ export async function acquireXcodebuildSimulatorSetRedirect(
171171
async function xctestDeviceSetCleanupArmedRefusal(
172172
options: XcrunShimProbeOptions,
173173
): Promise<AppError | null> {
174-
const xcrunShims = await probeXcrunShimFirstLaunchHooks({
175-
xcrunShimPaths: options.xcrunShimPaths,
176-
signal: options.signal,
177-
});
174+
const xcrunShims = await probeXcrunShimFirstLaunchHooks({ signal: options.signal });
178175
if (options.signal?.aborted) {
179176
return createRequestCanceledError({ phase: 'xctest_device_set_shim_probe' });
180177
}

0 commit comments

Comments
 (0)