@@ -366,68 +366,70 @@ describe("DesktopLinuxUrlHandler", () => {
366366 } ) ;
367367 } ) ;
368368
369- it . effect . skipIf ( HostProcess . Platform . defaultValue ( ) !== "linux" ) (
370- "continues registration after a timed-out cache helper ignores SIGTERM" ,
371- ( ) =>
372- Effect . gen ( function * ( ) {
373- const realSpawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
374- const nodeExecutable = yield * HostProcess . ExecutablePath ;
375- const recorded = emptyRecording ( ) ;
376- const spawned = yield * Deferred . make < ChildProcessSpawner . ChildProcessHandle > ( ) ;
377- const ready = yield * Deferred . make < void > ( ) ;
378- const processSpawner = ChildProcessSpawner . make ( ( command ) =>
379- Effect . gen ( function * ( ) {
380- if ( ! ChildProcess . isStandardCommand ( command ) ) {
381- return yield * Effect . die ( "expected a single registration command" ) ;
382- }
383- recorded . commands . push ( { command : command . command , args : command . args } ) ;
384- if ( command . command !== "update-desktop-database" ) return mockProcess ( 0 ) ;
385- const child = yield * realSpawner . spawn (
386- ChildProcess . make (
387- nodeExecutable ,
388- [
389- "-e" ,
390- // The watchdog makes the unfixed case exit with a distinguishable code.
391- "process.on('SIGTERM', () => setTimeout(() => process.exit(99), 5000));" +
392- "process.stdout.write('ready\\n'); setInterval(() => {}, 2147483647);" ,
393- ] ,
394- { ...command . options , stdout : "pipe" } ,
369+ for ( const stalledHelper of [ "update-desktop-database" , "xdg-mime" ] as const ) {
370+ it . effect . skipIf ( HostProcess . Platform . defaultValue ( ) !== "linux" ) (
371+ `finishes registration after a timed-out ${ stalledHelper } ignores SIGTERM` ,
372+ ( ) =>
373+ Effect . gen ( function * ( ) {
374+ const realSpawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
375+ const nodeExecutable = yield * HostProcess . ExecutablePath ;
376+ const recorded = emptyRecording ( ) ;
377+ const spawned = yield * Deferred . make < ChildProcessSpawner . ChildProcessHandle > ( ) ;
378+ const ready = yield * Deferred . make < void > ( ) ;
379+ const processSpawner = ChildProcessSpawner . make ( ( command ) =>
380+ Effect . gen ( function * ( ) {
381+ if ( ! ChildProcess . isStandardCommand ( command ) ) {
382+ return yield * Effect . die ( "expected a single registration command" ) ;
383+ }
384+ recorded . commands . push ( { command : command . command , args : command . args } ) ;
385+ if ( command . command !== stalledHelper ) return mockProcess ( 0 ) ;
386+ const child = yield * realSpawner . spawn (
387+ ChildProcess . make (
388+ nodeExecutable ,
389+ [
390+ "-e" ,
391+ // The watchdog makes the unfixed case exit with a distinguishable code.
392+ "process.on('SIGTERM', () => setTimeout(() => process.exit(99), 5000));" +
393+ "process.stdout.write('ready\\n'); setInterval(() => {}, 2147483647);" ,
394+ ] ,
395+ { ...command . options , stdout : "pipe" } ,
396+ ) ,
397+ ) ;
398+ yield * Deferred . succeed ( spawned , child ) ;
399+ yield * Stream . runHead ( child . stdout ) ;
400+ yield * Deferred . succeed ( ready , undefined ) ;
401+ return child ;
402+ } ) ,
403+ ) ;
404+ const registration = yield * runRegister ( recorded , { processSpawner } ) . pipe (
405+ Effect . forkScoped ,
406+ ) ;
407+ const child = yield * Deferred . await ( spawned ) ;
408+ yield * Effect . addFinalizer ( ( ) =>
409+ child . isRunning . pipe (
410+ Effect . flatMap ( ( running ) =>
411+ running ? child . kill ( { killSignal : "SIGKILL" } ) : Effect . void ,
395412 ) ,
396- ) ;
397- yield * Deferred . succeed ( spawned , child ) ;
398- yield * Stream . runHead ( child . stdout ) ;
399- yield * Deferred . succeed ( ready , undefined ) ;
400- return child ;
401- } ) ,
402- ) ;
403- const registration = yield * runRegister ( recorded , { processSpawner } ) . pipe (
404- Effect . forkScoped ,
405- ) ;
406- const child = yield * Deferred . await ( spawned ) ;
407- yield * Effect . addFinalizer ( ( ) =>
408- child . isRunning . pipe (
409- Effect . flatMap ( ( running ) =>
410- running ? child . kill ( { killSignal : "SIGKILL" } ) : Effect . void ,
413+ Effect . ignore ,
411414 ) ,
412- Effect . ignore ,
413- ) ,
414- ) ;
415- yield * Deferred . await ( ready ) ;
416- yield * TestClock . adjust ( "5 seconds" ) ;
417- yield * Fiber . join ( registration ) ;
418-
419- const exit = yield * Effect . exit ( child . exitCode ) ;
420- if ( Exit . isFailure ( exit ) ) {
421- assert . include ( Cause . pretty ( exit . cause ) , "SIGKILL" ) ;
422- } else {
423- assert . fail ( `cache helper exited with ${ exit . value } instead of being force-killed` ) ;
424- }
425- assert . deepEqual (
426- recorded . commands . map ( ( { command } ) => command ) ,
427- [ "update-desktop-database" , "xdg-mime" ] ,
428- ) ;
429- } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
430- ) ;
415+ ) ;
416+ yield * Deferred . await ( ready ) ;
417+ yield * TestClock . adjust ( "5 seconds" ) ;
418+ yield * Fiber . join ( registration ) ;
419+
420+ const exit = yield * Effect . exit ( child . exitCode ) ;
421+ if ( Exit . isFailure ( exit ) ) {
422+ assert . include ( Cause . pretty ( exit . cause ) , "SIGKILL" ) ;
423+ } else {
424+ assert . fail ( `${ stalledHelper } exited with ${ exit . value } instead of being force-killed` ) ;
425+ }
426+ assert . deepEqual (
427+ recorded . commands . map ( ( { command } ) => command ) ,
428+ [ "update-desktop-database" , "xdg-mime" ] ,
429+ ) ;
430+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
431+ ) ;
432+ }
431433} ) ;
432434
433435interface ThemeIconRun {
0 commit comments