@@ -405,13 +405,42 @@ describe("await", () => {
405
405
async_get : job_id ,
406
406
async_stats : true ,
407
407
} ) ;
408
- expect ( ( Date . now ( ) - t0 ) / 1000 ) . toBeGreaterThan ( .05 ) ;
408
+ expect ( ( Date . now ( ) - t0 ) / 1000 ) . toBeGreaterThan ( 0 .05) ;
409
409
expect ( s . type ) . toEqual ( "async" ) ;
410
410
if ( s . type !== "async" ) return ;
411
411
expect ( s . stderr ) . toEqual ( "baz\n" ) ;
412
412
expect ( s . exit_code ) . toEqual ( 3 ) ;
413
413
expect ( s . status ) . toEqual ( "completed" ) ;
414
414
} ) ;
415
+
416
+ it ( "react to a killed process" , async ( ) => {
417
+ const c = await executeCode ( {
418
+ command : "sh" ,
419
+ args : [ "-c" , `echo foo; sleep 1; echo bar;` ] ,
420
+ bash : false ,
421
+ err_on_exit : false ,
422
+ async_call : true ,
423
+ } ) ;
424
+ expect ( c . type ) . toEqual ( "async" ) ;
425
+ if ( c . type !== "async" ) return ;
426
+ const { job_id, pid } = c ;
427
+ await new Promise ( ( done ) => setTimeout ( done , 100 ) ) ;
428
+ await executeCode ( {
429
+ command : `kill -9 -${ pid } ` ,
430
+ bash : true ,
431
+ } ) ;
432
+ const s = await executeCode ( {
433
+ async_await : true ,
434
+ async_get : job_id ,
435
+ async_stats : true ,
436
+ } ) ;
437
+ expect ( s . type ) . toEqual ( "async" ) ;
438
+ if ( s . type !== "async" ) return ;
439
+ expect ( s . stderr ) . toEqual ( "" ) ;
440
+ expect ( s . stdout ) . toEqual ( "foo\n" ) ;
441
+ expect ( s . exit_code ) . toEqual ( 0 ) ;
442
+ expect ( s . status ) . toEqual ( "completed" ) ;
443
+ } ) ;
415
444
} ) ;
416
445
417
446
// we burn a bit of CPU to get the cpu_pct and cpu_secs up
0 commit comments