Skip to content

Commit 6aa85ad

Browse files
test(platform-apple): pin the final copy attempt and each path at its option
Review follow-up (#3434): distinct per-attempt stderr proves the copy failure reports the last container rather than the first, --source and --destination are asserted at their option positions so a swap fails, and the IPA fixture summary no longer claims ambiguous-name coverage. Co-authored-by: Apex <[email protected]>
1 parent a590340 commit 6aa85ad

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

‎packages/platform-apple/src/core/__tests__/install-artifact.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import { mkdtempForTest } from '../../__tests__/tmp-dir.ts';
1212
* An IPA whose `Payload` holds more than one `.app` is legal on disk and ambiguous for the
1313
* installer: `appIdentifierHint` is how the caller breaks the tie. The hint matches a bundle by
1414
* name first and by bundle id only when it is dotted, so these cases run the real extraction over
15-
* real multi-payload IPAs and pin each outcome: one name match, one id match, an ambiguous name,
16-
* and a hint that matches nothing.
15+
* real multi-payload IPAs and pin name/id resolution plus the unmatched-hint and no-hint errors.
16+
* (Two bundles whose names differ only by case, which would make the hint itself ambiguous, cannot
17+
* be built on a case-insensitive host filesystem and stay unpinned.)
1718
*/
1819
test('prepareIosInstallArtifact resolves a multi-payload IPA by a bundle-name hint', async () => {
1920
await withMultiPayloadIpa([{ name: 'Alpha' }, { name: 'Beta' }], async (ipaPath) => {

‎packages/platform-apple/src/core/__tests__/physical-device-files.test.ts‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ test('copyCoreDeviceRunnerFile copies with the app data container domain', async
1515
assert.equal(calls.length, 1);
1616
const args = calls[0]!;
1717
assert.deepEqual(args.slice(0, 4), ['devicectl', 'device', 'copy', 'from']);
18-
assert.ok(args.includes('--source') && args.includes('/tmp/shot.png'));
19-
assert.ok(args.includes('--destination') && args.includes('/out/shot.png'));
18+
assert.equal(args[args.indexOf('--source') + 1], '/tmp/shot.png');
19+
assert.equal(args[args.indexOf('--destination') + 1], '/out/shot.png');
2020
assert.equal(args[args.indexOf('--domain-type') + 1], 'appDataContainer');
2121
});
2222

@@ -33,9 +33,27 @@ test('copyCoreDeviceRunnerFile retries the next runner container and stops at th
3333
});
3434

3535
test('copyCoreDeviceRunnerFile reports the last container error', async () => {
36-
await assertCopyFailure(
37-
() => ({ exitCode: 1, stderr: 'Failed to find a matching device' }),
38-
/Failed to copy runner file from iOS device: Failed to find a matching device/,
36+
// Distinct per-attempt errors: reporting an earlier candidate's failure instead of the final
37+
// one is the regression this pins, so the message must carry the last attempt's text only.
38+
const calls: string[][] = [];
39+
await assert.rejects(
40+
async () =>
41+
await withFakeAppleTool(
42+
(args) => {
43+
calls.push(args);
44+
return { exitCode: 1, stderr: `container miss ${calls.length}` };
45+
},
46+
async () => await copyCoreDeviceRunnerFile(IOS_DEVICE, '/tmp/shot.png', '/out/shot.png'),
47+
{ device: IOS_DEVICE },
48+
),
49+
(error: unknown) => {
50+
const message = error instanceof Error ? error.message : '';
51+
// Every candidate container is tried, and the report names the last one alone.
52+
assert.ok(calls.length >= 2, 'every candidate container must be tried');
53+
assert.ok(domainIdentifier(calls[0]!) !== domainIdentifier(calls[1]!));
54+
assert.ok(message.endsWith(`container miss ${calls.length}`), message);
55+
return true;
56+
},
3957
);
4058
});
4159

0 commit comments

Comments
 (0)