@@ -4,37 +4,48 @@ import path from 'node:path';
44import { beforeAll , describe , test } from 'vitest' ;
55import { runCmd } from '@agent-device/host-kit/command' ;
66import { mkdtempForTest } from '../__tests__/tmp-dir.ts' ;
7+ import { BUILD_TIMEOUT_MS } from './cache.ts' ;
8+ import { createSnapshotSourceDeadline , remainingSnapshotSourceMs } from './deadline.ts' ;
9+
10+ // The host bridge compile is budgeted from a deadline sized to production's build ceiling, not a
11+ // stricter warm-host constant, so a cold runner's first `xcrun` (signature-scan stall plus clang)
12+ // is not tripped before the compile finishes (#2439). The hook budget leaves headroom beyond that.
13+ const COMPILE_HOOK_TIMEOUT_MS = BUILD_TIMEOUT_MS + 30_000 ;
14+
15+ async function compileSnapshotBridgeFixture ( clangArgs : readonly string [ ] ) : Promise < void > {
16+ const deadline = createSnapshotSourceDeadline ( BUILD_TIMEOUT_MS , undefined ) ;
17+ const compiled = await runCmd ( 'xcrun' , [ ...clangArgs ] , {
18+ allowFailure : true ,
19+ timeoutMs : remainingSnapshotSourceMs ( deadline , 'native-build-deadline' ) ,
20+ } ) ;
21+ assert . equal ( compiled . exitCode , 0 , compiled . stderr ) ;
22+ }
723
824describe . skipIf ( process . platform !== 'darwin' ) ( 'native snapshot capture' , ( ) => {
925 let binary : string ;
1026 beforeAll ( async ( ) => {
1127 binary = path . join ( await mkdtempForTest ( 'snapshot-foreground-' ) , 'foreground-owner' ) ;
1228 const nativeRoot = path . resolve ( import . meta. dirname , '../../../../apple/snapshot-bridge' ) ;
13- const compiled = await runCmd (
14- 'xcrun' ,
15- [
16- '--sdk' ,
17- 'macosx' ,
18- 'clang' ,
19- '-fobjc-arc' ,
20- '-Ddlopen=fixtureDlopen' ,
21- '-Ddlsym=fixtureDlsym' ,
22- '-framework' ,
23- 'Foundation' ,
24- '-framework' ,
25- 'CoreGraphics' ,
26- '-I' ,
27- nativeRoot ,
28- path . join ( nativeRoot , 'SnapshotBridgeRuntime.m' ) ,
29- path . join ( nativeRoot , 'SnapshotBridgeCapture.m' ) ,
30- path . join ( import . meta. dirname , 'fixtures/foreground-owner.m' ) ,
31- '-o' ,
32- binary ,
33- ] ,
34- { allowFailure : true , timeoutMs : 45_000 } ,
35- ) ;
36- assert . equal ( compiled . exitCode , 0 , compiled . stderr ) ;
37- } , 60_000 ) ;
29+ await compileSnapshotBridgeFixture ( [
30+ '--sdk' ,
31+ 'macosx' ,
32+ 'clang' ,
33+ '-fobjc-arc' ,
34+ '-Ddlopen=fixtureDlopen' ,
35+ '-Ddlsym=fixtureDlsym' ,
36+ '-framework' ,
37+ 'Foundation' ,
38+ '-framework' ,
39+ 'CoreGraphics' ,
40+ '-I' ,
41+ nativeRoot ,
42+ path . join ( nativeRoot , 'SnapshotBridgeRuntime.m' ) ,
43+ path . join ( nativeRoot , 'SnapshotBridgeCapture.m' ) ,
44+ path . join ( import . meta. dirname , 'fixtures/foreground-owner.m' ) ,
45+ '-o' ,
46+ binary ,
47+ ] ) ;
48+ } , COMPILE_HOOK_TIMEOUT_MS ) ;
3849
3950 test . each ( [
4051 'stable' ,
@@ -90,26 +101,21 @@ describe.skipIf(process.platform !== 'darwin')(
90101 beforeAll ( async ( ) => {
91102 binary = path . join ( await mkdtempForTest ( 'snapshot-recovery-' ) , 'recovery-conformance' ) ;
92103 const nativeRoot = path . resolve ( import . meta. dirname , '../../../../apple/snapshot-bridge' ) ;
93- const compiled = await runCmd (
94- 'xcrun' ,
95- [
96- '--sdk' ,
97- 'macosx' ,
98- 'clang' ,
99- '-fobjc-arc' ,
100- '-framework' ,
101- 'Foundation' ,
102- '-I' ,
103- nativeRoot ,
104- path . join ( nativeRoot , 'SnapshotBridgeCapture.m' ) ,
105- path . join ( import . meta. dirname , 'fixtures/recovery-conformance.m' ) ,
106- '-o' ,
107- binary ,
108- ] ,
109- { allowFailure : true , timeoutMs : 45_000 } ,
110- ) ;
111- assert . equal ( compiled . exitCode , 0 , compiled . stderr ) ;
112- } , 60_000 ) ;
104+ await compileSnapshotBridgeFixture ( [
105+ '--sdk' ,
106+ 'macosx' ,
107+ 'clang' ,
108+ '-fobjc-arc' ,
109+ '-framework' ,
110+ 'Foundation' ,
111+ '-I' ,
112+ nativeRoot ,
113+ path . join ( nativeRoot , 'SnapshotBridgeCapture.m' ) ,
114+ path . join ( import . meta. dirname , 'fixtures/recovery-conformance.m' ) ,
115+ '-o' ,
116+ binary ,
117+ ] ) ;
118+ } , COMPILE_HOOK_TIMEOUT_MS ) ;
113119
114120 assert . equal ( recoveryFixture . version , 1 ) ;
115121 test . each ( recoveryFixture . recoveryCases . map ( ( recoveryCase ) => recoveryCase . name ) ) (
0 commit comments