@@ -77,33 +77,35 @@ test('public HTTP rejects Limrun uploaded-app listing and allocation before prov
7777 limrunTestDependencies ,
7878 ) ;
7979 rootPorts . providerComposition . mockResolvedValue ( { runtimes : [ limrun ] , platformModules : [ ] } ) ;
80- const runtime = await startDaemonRuntime ( {
81- composeDeps : createDaemonRuntimeDeps ,
82- env : {
83- ...process . env ,
84- AGENT_DEVICE_STATE_DIR : stateDir ,
85- AGENT_DEVICE_DAEMON_IDLE_TIMEOUT_MS : '0' ,
86- AGENT_DEVICE_DAEMON_SERVER_MODE : 'http' ,
87- LIM_ANDROID_INSTANCE_URL : 'https://region.limrun.example/v1/android_test/api' ,
88- LIM_ANDROID_INSTANCE_TOKEN : 'lim-test-token' ,
89- LIM_ANDROID_INSTANCE_ADB_URL : 'https://region.limrun.example/v1/android_test/adb' ,
90- } ,
91- exit : ( ) => { } ,
92- registerProcessHandlers : false ,
93- stderr : { write : ( ) => { } } ,
94- stdout : { write : ( ) => { } } ,
95- } ) ;
80+ let runtime : Awaited < ReturnType < typeof startDaemonRuntime > > | undefined ;
9681
9782 try {
98- if ( ! runtime ?. httpPort ) throw new Error ( 'HTTP daemon runtime did not start' ) ;
83+ runtime = await startDaemonRuntime ( {
84+ composeDeps : createDaemonRuntimeDeps ,
85+ env : {
86+ ...process . env ,
87+ AGENT_DEVICE_STATE_DIR : stateDir ,
88+ AGENT_DEVICE_DAEMON_IDLE_TIMEOUT_MS : '0' ,
89+ AGENT_DEVICE_DAEMON_SERVER_MODE : 'http' ,
90+ LIM_ANDROID_INSTANCE_URL : 'https://region.limrun.example/v1/android_test/api' ,
91+ LIM_ANDROID_INSTANCE_TOKEN : 'lim-test-token' ,
92+ LIM_ANDROID_INSTANCE_ADB_URL : 'https://region.limrun.example/v1/android_test/adb' ,
93+ } ,
94+ exit : ( ) => { } ,
95+ registerProcessHandlers : false ,
96+ stderr : { write : ( ) => { } } ,
97+ stdout : { write : ( ) => { } } ,
98+ } ) ;
99+ const activeRuntime = runtime ;
100+ if ( ! activeRuntime ?. httpPort ) throw new Error ( 'HTTP daemon runtime did not start' ) ;
99101 limrunIo . listAssets . mockClear ( ) ;
100102 limrunIo . createAndroidInstance . mockClear ( ) ;
101103
102104 const callRpc = async ( payload : Record < string , unknown > ) => {
103- const response = await fetch ( `http://127.0.0.1:${ runtime . httpPort } /rpc` , {
105+ const response = await fetch ( `http://127.0.0.1:${ activeRuntime . httpPort } /rpc` , {
104106 method : 'POST' ,
105107 headers : {
106- authorization : `Bearer ${ runtime . token } ` ,
108+ authorization : `Bearer ${ activeRuntime . token } ` ,
107109 'content-type' : 'application/json' ,
108110 [ DAEMON_HTTP_NETWORK_ACCESS_HEADER ] : DAEMON_HTTP_PUBLIC_NETWORK_ACCESS ,
109111 } ,
@@ -147,7 +149,8 @@ test('public HTTP rejects Limrun uploaded-app listing and allocation before prov
147149 } finally {
148150 await runtime ?. shutdown ( ) ;
149151 await limrun . shutdown ( ) ;
150- assert . equal ( rootPorts . applicationLifecycle . finalizeDaemonShutdown . mock . calls . length , 1 ) ;
151152 fs . rmSync ( paths . baseDir , { recursive : true , force : true } ) ;
153+ if ( runtime )
154+ assert . equal ( rootPorts . applicationLifecycle . finalizeDaemonShutdown . mock . calls . length , 1 ) ;
152155 }
153156} ) ;
0 commit comments