File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -477,3 +477,33 @@ describe("handles env vars", () => {
477477
478478 // Close the main "handles env vars" describe block
479479} ) ;
480+
481+ describe ( "kill" , ( ) => {
482+ it ( "can explicitly kill a running process" , function * ( ) {
483+ let proc : Process = yield * exec ( "deno run -A './fixtures/echo-server.ts'" , {
484+ env : {
485+ PORT : "29001" ,
486+ PATH : process . env . PATH as string ,
487+ ...( SystemRoot ? { SystemRoot } : { } ) ,
488+ } ,
489+ cwd : import . meta. dirname ,
490+ } ) ;
491+
492+ // Wait for the server to start
493+ yield * expectMatch ( / l i s t e n i n g / , lines ( ) ( proc . stdout ) ) ;
494+
495+ // Kill the process
496+ yield * proc . kill ( ) ;
497+
498+ // Join should complete after kill
499+ let status = yield * proc . join ( ) ;
500+
501+ // On POSIX systems, a killed process should have a signal set
502+ if ( process . platform !== "win32" ) {
503+ expect ( status . signal ) . toBeDefined ( ) ;
504+ } else {
505+ // On Windows, it might be an exit code instead
506+ expect ( status . code !== 0 || status . signal ) . toBeTruthy ( ) ;
507+ }
508+ } ) ;
509+ } ) ;
You can’t perform that action at this time.
0 commit comments