@@ -864,6 +864,32 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
864864 } ) ,
865865 ) ;
866866
867+ it . effect (
868+ "requires launchd shutdown confirmation for maintenance after a failed status probe" ,
869+ ( ) =>
870+ Effect . gen ( function * ( ) {
871+ const { service, control } = yield * makeHarness ( "darwin" ) ;
872+ yield * service . install ( ) ;
873+ control . failCommand = "launchctl print gui/501/com.t3tools.t3code.service" ;
874+ let ran = false ;
875+
876+ const error = yield * service
877+ . withStopped (
878+ Effect . sync ( ( ) => {
879+ ran = true ;
880+ } ) ,
881+ )
882+ . pipe ( Effect . flip ) ;
883+
884+ expect ( error ) . toMatchObject ( {
885+ _tag : "BootServiceCommandError" ,
886+ step : "waiting for the launch agent to stop" ,
887+ exitCode : 1 ,
888+ } ) ;
889+ expect ( ran ) . toBe ( false ) ;
890+ } ) ,
891+ ) ;
892+
867893 // regression: #11995 macOS 15 rejects `bootout --wait`, so the stop waits on `print`
868894 it . effect ( "starts a booted-out launch agent again only once launchd has removed it" , ( ) =>
869895 Effect . gen ( function * ( ) {
@@ -893,25 +919,36 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
893919 } ) ,
894920 ) ;
895921
896- it . effect ( "fails an install whose launch agent is still loaded after the stop timeout" , ( ) =>
897- Effect . gen ( function * ( ) {
898- const { service, commands, control } = yield * makeHarness ( "darwin" ) ;
899- const plan = yield * service . install ( ) ;
900- const polls = yield * Queue . unbounded < void > ( ) ;
901- control . drainPolls = Number . POSITIVE_INFINITY ;
902- control . onDrainPoll = Queue . offer ( polls , undefined ) . pipe ( Effect . asVoid ) ;
903- commands . length = 0 ;
904-
905- const reinstall = yield * service . install ( ) . pipe ( Effect . flip , Effect . forkChild ) ;
906- yield * Queue . take ( polls ) ;
907- yield * TestClock . adjust ( "120 seconds" ) ;
922+ it . effect . each ( [ "install" , "maintenance" ] as const ) (
923+ "fails %s while launchd is still draining after the stop timeout" ,
924+ ( operation ) =>
925+ Effect . gen ( function * ( ) {
926+ const { service, commands, control } = yield * makeHarness ( "darwin" ) ;
927+ const plan = yield * service . install ( ) ;
928+ const polls = yield * Queue . unbounded < void > ( ) ;
929+ control . drainPolls = Number . POSITIVE_INFINITY ;
930+ control . onDrainPoll = Queue . offer ( polls , undefined ) . pipe ( Effect . asVoid ) ;
931+ commands . length = 0 ;
908932
909- expect ( yield * Fiber . join ( reinstall ) ) . toMatchObject ( {
910- _tag : "BootServiceCommandError" ,
911- step : "waiting for the launch agent to stop" ,
912- } ) ;
913- expect ( commands ) . not . toContain ( `launchctl bootstrap gui/501 ${ plan . unitPath } ` ) ;
914- } ) ,
933+ const run =
934+ operation === "install"
935+ ? service . install ( ) . pipe ( Effect . asVoid )
936+ : service . withStopped (
937+ Effect . sync ( ( ) => {
938+ commands . push ( "repair" ) ;
939+ } ) ,
940+ ) ;
941+ const reinstall = yield * run . pipe ( Effect . flip , Effect . forkChild ) ;
942+ yield * Queue . take ( polls ) ;
943+ yield * TestClock . adjust ( "120 seconds" ) ;
944+
945+ expect ( yield * Fiber . join ( reinstall ) ) . toMatchObject ( {
946+ _tag : "BootServiceCommandError" ,
947+ step : "waiting for the launch agent to stop" ,
948+ } ) ;
949+ expect ( commands ) . not . toContain ( `launchctl bootstrap gui/501 ${ plan . unitPath } ` ) ;
950+ expect ( commands ) . not . toContain ( "repair" ) ;
951+ } ) ,
915952 ) ;
916953
917954 it . effect ( "fails an install when launchd cannot say whether the agent stopped" , ( ) =>
0 commit comments