Skip to content

Commit 86db7e8

Browse files
authored
fix: align iOS runner cache target metadata (#682)
* fix: align iOS runner cache target metadata * test: surface iOS cache metadata script stderr
1 parent 4eeec60 commit 86db7e8

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

scripts/write-xcuitest-cache-metadata.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function resolveDeviceKind() {
113113
function resolveTarget() {
114114
if (platform === 'macos') return 'desktop';
115115
if (platform === 'tvos') return 'tv';
116-
return 'phone';
116+
return 'mobile';
117117
}
118118

119119
function resolveMacRunnerArch() {

src/platforms/ios/__tests__/runner-xctestrun.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test, vi } from 'vitest';
22
import assert from 'node:assert/strict';
3+
import { execFileSync } from 'node:child_process';
34
import fs from 'node:fs';
45
import os from 'node:os';
56
import path from 'node:path';
@@ -10,6 +11,7 @@ import {
1011
acquireXcodebuildSimulatorSetRedirect,
1112
findXctestrun,
1213
prepareXctestrunWithEnv,
14+
resolveExpectedRunnerCacheMetadata,
1315
resolveXcodebuildSimulatorDeviceSetPath,
1416
scoreXctestrunCandidate,
1517
} from '../runner-xctestrun.ts';
@@ -19,6 +21,7 @@ const iosSimulator: DeviceInfo = {
1921
id: 'sim-1',
2022
name: 'iPhone Simulator',
2123
kind: 'simulator',
24+
target: 'mobile',
2225
booted: true,
2326
};
2427

@@ -193,6 +196,25 @@ test('scoreXctestrunCandidate penalizes macos and env xctestrun files for simula
193196
assert.ok(simulatorScore > macosEnvScore);
194197
});
195198

199+
test('setup metadata script matches expected iOS simulator cache metadata', async () => {
200+
await withTempDir('runner-cache-metadata-', async (root) => {
201+
execFileSync(
202+
process.execPath,
203+
['scripts/write-xcuitest-cache-metadata.mjs', 'ios', root, 'generic/platform=iOS Simulator'],
204+
{ cwd: process.cwd(), stdio: ['ignore', 'ignore', 'inherit'] },
205+
);
206+
207+
const actual = JSON.parse(
208+
fs.readFileSync(path.join(root, '.agent-device-runner-cache.json'), 'utf8'),
209+
);
210+
const { artifacts: _actualArtifacts, ...actualComparable } = actual;
211+
const { artifacts: _expectedArtifacts, ...expectedComparable } =
212+
resolveExpectedRunnerCacheMetadata(iosSimulator);
213+
214+
assert.deepEqual(actualComparable, expectedComparable);
215+
});
216+
});
217+
196218
test('prepareXctestrunWithEnv avoids XCTest screen recordings for nested and legacy targets', async () => {
197219
await withTempDir('runner-xctestrun-policy-', async (root) => {
198220
const xctestrunPath = path.join(root, 'AgentDeviceRunner.xctestrun');

src/platforms/ios/runner-xctestrun.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export type RunnerXctestrunCacheMetadata = {
8989
runnerSourceFingerprint: string;
9090
platformName: string;
9191
deviceKind: DeviceInfo['kind'];
92-
target: DeviceInfo['target'] | 'phone';
92+
target: NonNullable<DeviceInfo['target']>;
9393
buildDestinationFamily: string;
9494
runnerBundleBuildSettings: string[];
9595
runnerSigningBuildSettings: string[];
@@ -684,7 +684,7 @@ export function resolveExpectedRunnerCacheMetadata(
684684
runnerSourceFingerprint: computeRunnerSourceFingerprint(projectRoot),
685685
platformName: resolveRunnerPlatformName(device),
686686
deviceKind: device.kind,
687-
target: device.target ?? 'phone',
687+
target: device.target ?? 'mobile',
688688
buildDestinationFamily: resolveRunnerBuildDestinationFamily(device),
689689
runnerBundleBuildSettings: resolveRunnerBundleBuildSettings(process.env),
690690
runnerSigningBuildSettings: resolveRunnerSigningBuildSettings(

0 commit comments

Comments
 (0)