Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/write-xcuitest-cache-metadata.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function resolveDeviceKind() {
function resolveTarget() {
if (platform === 'macos') return 'desktop';
if (platform === 'tvos') return 'tv';
return 'phone';
return 'mobile';
}

function resolveMacRunnerArch() {
Expand Down
22 changes: 22 additions & 0 deletions src/platforms/ios/__tests__/runner-xctestrun.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, vi } from 'vitest';
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
Expand All @@ -10,6 +11,7 @@ import {
acquireXcodebuildSimulatorSetRedirect,
findXctestrun,
prepareXctestrunWithEnv,
resolveExpectedRunnerCacheMetadata,
resolveXcodebuildSimulatorDeviceSetPath,
scoreXctestrunCandidate,
} from '../runner-xctestrun.ts';
Expand All @@ -19,6 +21,7 @@ const iosSimulator: DeviceInfo = {
id: 'sim-1',
name: 'iPhone Simulator',
kind: 'simulator',
target: 'mobile',
booted: true,
};

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

test('setup metadata script matches expected iOS simulator cache metadata', async () => {
await withTempDir('runner-cache-metadata-', async (root) => {
execFileSync(
process.execPath,
['scripts/write-xcuitest-cache-metadata.mjs', 'ios', root, 'generic/platform=iOS Simulator'],
{ cwd: process.cwd(), stdio: ['ignore', 'ignore', 'inherit'] },
);

const actual = JSON.parse(
fs.readFileSync(path.join(root, '.agent-device-runner-cache.json'), 'utf8'),
);
const { artifacts: _actualArtifacts, ...actualComparable } = actual;
const { artifacts: _expectedArtifacts, ...expectedComparable } =
resolveExpectedRunnerCacheMetadata(iosSimulator);

assert.deepEqual(actualComparable, expectedComparable);
});
});

test('prepareXctestrunWithEnv avoids XCTest screen recordings for nested and legacy targets', async () => {
await withTempDir('runner-xctestrun-policy-', async (root) => {
const xctestrunPath = path.join(root, 'AgentDeviceRunner.xctestrun');
Expand Down
4 changes: 2 additions & 2 deletions src/platforms/ios/runner-xctestrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export type RunnerXctestrunCacheMetadata = {
runnerSourceFingerprint: string;
platformName: string;
deviceKind: DeviceInfo['kind'];
target: DeviceInfo['target'] | 'phone';
target: NonNullable<DeviceInfo['target']>;
buildDestinationFamily: string;
runnerBundleBuildSettings: string[];
runnerSigningBuildSettings: string[];
Expand Down Expand Up @@ -684,7 +684,7 @@ export function resolveExpectedRunnerCacheMetadata(
runnerSourceFingerprint: computeRunnerSourceFingerprint(projectRoot),
platformName: resolveRunnerPlatformName(device),
deviceKind: device.kind,
target: device.target ?? 'phone',
target: device.target ?? 'mobile',
buildDestinationFamily: resolveRunnerBuildDestinationFamily(device),
runnerBundleBuildSettings: resolveRunnerBundleBuildSettings(process.env),
runnerSigningBuildSettings: resolveRunnerSigningBuildSettings(
Expand Down
Loading