11import { test , vi } from 'vitest' ;
22import assert from 'node:assert/strict' ;
3+ import { execFileSync } from 'node:child_process' ;
34import fs from 'node:fs' ;
45import os from 'node:os' ;
56import 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+
196218test ( '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' ) ;
0 commit comments