@@ -194,6 +194,7 @@ const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
194194 fixtures : Map < string , ( call : number ) => ProcessRunner . ProcessRunOutput > ;
195195 callCounts : Map < string , number > ;
196196 signals : Map < string , Deferred . Deferred < void > > ;
197+ delays : Map < string , Duration . Input > ;
197198 stateAfterStop ?: string ;
198199 linger : string ;
199200 enabled : boolean ;
@@ -203,6 +204,7 @@ const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
203204 fixtures : new Map ( ) ,
204205 callCounts : new Map ( ) ,
205206 signals : new Map ( ) ,
207+ delays : new Map ( ) ,
206208 linger : "yes" ,
207209 enabled : true ,
208210 active : true ,
@@ -218,6 +220,8 @@ const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
218220 control . callCounts . set ( command , call ) ;
219221 const signal = control . signals . get ( command ) ;
220222 if ( signal !== undefined ) yield * Deferred . succeed ( signal , undefined ) ;
223+ const delay = control . delays . get ( command ) ;
224+ if ( delay !== undefined ) yield * Effect . sleep ( delay ) ;
221225 const fixture = control . fixtures . get ( command ) ;
222226 if ( fixture !== undefined ) return fixture ( call ) ;
223227 const failed = command === control . failCommand ;
@@ -946,6 +950,36 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
946950 } ) . pipe ( Effect . provide ( TestClock . layer ( ) ) ) ,
947951 ) ;
948952
953+ it . effect ( "shares one stop timeout across bootout and absence verification" , ( ) =>
954+ Effect . gen ( function * ( ) {
955+ const { service, commands, control } = yield * makeHarness ( "darwin" ) ;
956+ yield * service . install ( ) ;
957+ commands . length = 0 ;
958+ control . callCounts . clear ( ) ;
959+ const bootoutStarted = yield * Deferred . make < void > ( ) ;
960+ const firstPrint = yield * Deferred . make < void > ( ) ;
961+ control . signals . set ( `launchctl bootout ${ launchdServiceTarget } ` , bootoutStarted ) ;
962+ control . signals . set ( `launchctl print ${ launchdServiceTarget } ` , firstPrint ) ;
963+ control . delays . set ( `launchctl bootout ${ launchdServiceTarget } ` , Duration . seconds ( 60 ) ) ;
964+ control . fixtures . set ( `launchctl print ${ launchdServiceTarget } ` , ( ) => processResult ( ) ) ;
965+
966+ const installFiber = yield * service . install ( ) . pipe ( Effect . forkChild ) ;
967+ yield * Deferred . await ( bootoutStarted ) ;
968+ yield * TestClock . adjust ( Duration . seconds ( 60 ) ) ;
969+ yield * Deferred . await ( firstPrint ) ;
970+ yield * Effect . yieldNow ;
971+ yield * TestClock . adjust ( Duration . seconds ( 60 ) ) ;
972+ const error = yield * Fiber . join ( installFiber ) . pipe ( Effect . flip ) ;
973+
974+ expect ( error ) . toMatchObject ( {
975+ _tag : "BootServiceCommandError" ,
976+ step : "waiting for the launch agent to stop" ,
977+ timedOut : true ,
978+ } ) ;
979+ expect ( commands ) . not . toContain ( `launchctl enable ${ launchdServiceTarget } ` ) ;
980+ } ) . pipe ( Effect . provide ( TestClock . layer ( ) ) ) ,
981+ ) ;
982+
949983 it . effect ( "uninstalls when launchd confirms the GUI domain is absent" , ( ) =>
950984 Effect . gen ( function * ( ) {
951985 const { service, fs, control } = yield * makeHarness ( "darwin" ) ;
0 commit comments