Skip to content

Commit dcd0c9c

Browse files
committed
test: lift six Apple waivers; fix format and fallow findings from CI
- interactions, simulator, screenshot, physical-device-screenshot, devicectl, and screenshot-status-bar leave CONTENTION_RETRY_FILES: the first five stopped stubbing PATH binaries in earlier refactors (measured 3-64ms per file, no subprocess activity), and screenshot-status-bar now injects through the fake tool provider. apps.test.ts stays with its reason corrected to the unzip PATH stub (xcrun is in-process; install-artifact.ts:112 / install-source.ts:438 call runCmd('unzip') outside the Apple seam). Serialized lane 12 -> 6. - oxfmt: fake-apple-tool.ts and contention-retry.ts were pushed unformatted (local check piped through tail masked the failure). - fallow complexity: the three fake-script arrows in apps.test.ts drop under threshold via shared predicates (isSimctlMainScreenScale, isSimctlScreenshot, isDevicectlDevice), which also deduplicate the screenshot pair. Full unit suite green at the new membership: 638 files, 5,724 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019S5sZnmPn4A9Ct7sTJdfAf
1 parent 92e833f commit dcd0c9c

3 files changed

Lines changed: 30 additions & 94 deletions

File tree

scripts/lib/contention-retry.ts

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -70,49 +70,8 @@ export const CONTENTION_RETRY_FILES: readonly ContentionRetryEntry[] = [
7070
},
7171
{
7272
file: 'src/platforms/apple/core/__tests__/apps.test.ts',
73-
reason: 'Stubs xcrun/simctl on PATH and spawns them, waiting real app-state poll budgets.',
74-
trackingIssue: SUBPROCESS_STUB_ISSUE,
75-
reviewBy: REVIEW_BY,
76-
serializedStub: true,
77-
},
78-
{
79-
file: 'src/platforms/apple/core/__tests__/interactions.test.ts',
80-
reason: 'Stubs xcrun/simctl on PATH and spawns them, waiting real interaction settle budgets.',
81-
trackingIssue: SUBPROCESS_STUB_ISSUE,
82-
reviewBy: REVIEW_BY,
83-
serializedStub: true,
84-
},
85-
{
86-
file: 'src/platforms/apple/core/__tests__/simulator.test.ts',
87-
reason: 'Stubs xcrun/simctl on PATH and spawns them, waiting real boot-poll budgets.',
88-
trackingIssue: SUBPROCESS_STUB_ISSUE,
89-
reviewBy: REVIEW_BY,
90-
serializedStub: true,
91-
},
92-
{
93-
file: 'src/platforms/apple/core/__tests__/physical-device-screenshot.test.ts',
94-
reason: 'Stubs devicectl on PATH and spawns it, waiting real capture budgets.',
95-
trackingIssue: SUBPROCESS_STUB_ISSUE,
96-
reviewBy: REVIEW_BY,
97-
serializedStub: true,
98-
},
99-
{
100-
file: 'src/platforms/apple/core/__tests__/screenshot.test.ts',
101-
reason: 'Stubs xcrun/simctl on PATH and spawns them, waiting real capture budgets.',
102-
trackingIssue: SUBPROCESS_STUB_ISSUE,
103-
reviewBy: REVIEW_BY,
104-
serializedStub: true,
105-
},
106-
{
107-
file: 'src/platforms/apple/core/__tests__/screenshot-status-bar.test.ts',
108-
reason: 'Stubs xcrun/simctl on PATH and spawns them, waiting real status-bar override time.',
109-
trackingIssue: SUBPROCESS_STUB_ISSUE,
110-
reviewBy: REVIEW_BY,
111-
serializedStub: true,
112-
},
113-
{
114-
file: 'src/platforms/apple/core/__tests__/devicectl.test.ts',
115-
reason: 'Stubs devicectl on PATH and spawns it, waiting real device-poll budgets.',
73+
reason:
74+
'Stubs unzip on PATH for .ipa extraction (xcrun is in-process) and spawns it per install case.',
11675
trackingIssue: SUBPROCESS_STUB_ISSUE,
11776
reviewBy: REVIEW_BY,
11877
serializedStub: true,

src/__tests__/test-utils/fake-apple-tool.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ export async function withFakeAppleTool<T>(
108108
...options.provider,
109109
whichCommand: options.provider?.whichCommand ?? (async () => true),
110110
runCommand: async (cmd, args, execOptions) =>
111-
await respond(
112-
cmd === 'xcrun' ? [...args] : [cmd, ...args],
113-
cmd,
114-
execOptions?.allowFailure,
115-
),
111+
await respond(cmd === 'xcrun' ? [...args] : [cmd, ...args], cmd, execOptions?.allowFailure),
116112
simctl: {
117113
run: async (args, execOptions) =>
118114
await respond(['simctl', ...args], 'xcrun', execOptions?.allowFailure),

src/platforms/apple/core/__tests__/apps.test.ts

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ function unexpectedArgs(args: string[]): FakeAppleToolResponse {
8686
return { stderr: `unexpected xcrun args: ${args.join(' ')}`, exitCode: 1 };
8787
}
8888

89+
function isSimctlMainScreenScale(args: string[]): boolean {
90+
return args[0] === 'simctl' && args[1] === 'getenv' && args[3] === 'SIMULATOR_MAINSCREEN_SCALE';
91+
}
92+
93+
function isSimctlScreenshot(args: string[]): boolean {
94+
return (
95+
args[0] === 'simctl' && args[1] === 'io' && args[2] === 'sim-1' && args[3] === 'screenshot'
96+
);
97+
}
98+
99+
function isDevicectlDevice(args: string[], ...subcommand: string[]): boolean {
100+
return (
101+
args[0] === 'devicectl' &&
102+
args[1] === 'device' &&
103+
subcommand.every((word, index) => args[2 + index] === word)
104+
);
105+
}
106+
89107
/**
90108
* `unzip` is spawned through `runCmd` directly (install-artifact.ts /
91109
* install-source.ts), bypassing the Apple tool provider scope, so IPA
@@ -192,19 +210,8 @@ test('screenshotIos retries simulator capture timeouts and eventually succeeds',
192210
await withFakeAppleTool(
193211
(args) => {
194212
if (isSimctlListDevices(args)) return BOOTED_SIM_LIST_JSON;
195-
if (
196-
args[0] === 'simctl' &&
197-
args[1] === 'getenv' &&
198-
args[3] === 'SIMULATOR_MAINSCREEN_SCALE'
199-
) {
200-
return '3\n';
201-
}
202-
if (
203-
args[0] === 'simctl' &&
204-
args[1] === 'io' &&
205-
args[2] === 'sim-1' &&
206-
args[3] === 'screenshot'
207-
) {
213+
if (isSimctlMainScreenScale(args)) return '3\n';
214+
if (isSimctlScreenshot(args)) {
208215
screenshotAttempts += 1;
209216
if (screenshotAttempts < 3) {
210217
return {
@@ -252,19 +259,8 @@ test('screenshotIos keeps requested simulator pixel density', async () => {
252259
await withFakeAppleTool(
253260
(args) => {
254261
if (isSimctlListDevices(args)) return BOOTED_SIM_LIST_JSON;
255-
if (
256-
args[0] === 'simctl' &&
257-
args[1] === 'getenv' &&
258-
args[3] === 'SIMULATOR_MAINSCREEN_SCALE'
259-
) {
260-
return '3\n';
261-
}
262-
if (
263-
args[0] === 'simctl' &&
264-
args[1] === 'io' &&
265-
args[2] === 'sim-1' &&
266-
args[3] === 'screenshot'
267-
) {
262+
if (isSimctlMainScreenScale(args)) return '3\n';
263+
if (isSimctlScreenshot(args)) {
268264
writeFileSync(args[4] ?? '', sourcePng);
269265
return '';
270266
}
@@ -585,12 +581,7 @@ test('reinstallIosApp on iOS physical device uses devicectl uninstall + install'
585581

586582
await withFakeAppleTool(
587583
(args) => {
588-
if (
589-
args[0] === 'devicectl' &&
590-
args[1] === 'device' &&
591-
args[2] === 'info' &&
592-
args[3] === 'apps'
593-
) {
584+
if (isDevicectlDevice(args, 'info', 'apps')) {
594585
const jsonOut = args[args.indexOf('--json-output') + 1];
595586
writeFileSync(
596587
jsonOut ?? '',
@@ -624,23 +615,18 @@ test('reinstallIosApp on iOS physical device proceeds when uninstall reports app
624615

625616
await withFakeAppleTool(
626617
(args) => {
627-
if (
628-
args[0] === 'devicectl' &&
629-
args[1] === 'device' &&
630-
args[2] === 'info' &&
631-
args[3] === 'apps'
632-
) {
618+
if (isDevicectlDevice(args, 'info', 'apps')) {
633619
const jsonOut = args[args.indexOf('--json-output') + 1];
634620
writeFileSync(
635621
jsonOut ?? '',
636622
'{"result":{"apps":[{"bundleIdentifier":"com.example.demo","name":"Demo"}]}}\n',
637623
);
638624
return '';
639625
}
640-
if (args[0] === 'devicectl' && args[1] === 'device' && args[2] === 'uninstall') {
626+
if (isDevicectlDevice(args, 'uninstall')) {
641627
return { stderr: 'app not installed', exitCode: 1 };
642628
}
643-
if (args[0] === 'devicectl' && args[1] === 'device' && args[2] === 'install') return '';
629+
if (isDevicectlDevice(args, 'install')) return '';
644630
if (args[0] === 'plutil') return '';
645631
return unexpectedArgs(args);
646632
},
@@ -915,12 +901,7 @@ test('resolveIosApp resolves app display name on iOS physical devices', async ()
915901

916902
await withFakeAppleTool(
917903
(args) => {
918-
if (
919-
args[0] === 'devicectl' &&
920-
args[1] === 'device' &&
921-
args[2] === 'info' &&
922-
args[3] === 'apps'
923-
) {
904+
if (isDevicectlDevice(args, 'info', 'apps')) {
924905
const jsonOut = args[args.indexOf('--json-output') + 1];
925906
writeFileSync(
926907
jsonOut ?? '',

0 commit comments

Comments
 (0)