@@ -4,30 +4,41 @@ var helpers = require('../helpers');
44var runMocha = helpers . runMocha ;
55
66describe ( '--posix-exit-codes' , function ( ) {
7- var mocha ;
8-
9- function killSubprocess ( ) {
10- mocha . kill ( 'SIGKILL' ) ;
11- }
7+ describe ( 'when enabled with node options' , function ( ) {
8+ var args = [ '--no-warnings' , '--posix-exit-codes' ] ;
129
13- // these two handlers deal with a ctrl-c on command-line
14- before ( function ( ) {
15- process . on ( 'SIGINT' , killSubprocess ) ;
16- } ) ;
10+ it ( 'should exit with code 134 on SIGABRT' , function ( done ) {
11+ var fixture = 'signals-sigabrt.fixture.js' ;
12+ runMocha ( fixture , args , function postmortem ( err , res ) {
13+ if ( err ) {
14+ return done ( err ) ;
15+ }
16+ expect ( res . code , 'to be' , 134 ) ;
17+ done ( ) ;
18+ } ) ;
19+ } ) ;
1720
18- after ( function ( ) {
19- process . removeListener ( 'SIGINT' , killSubprocess ) ;
21+ it ( 'should exit with code 143 on SIGTERM' , function ( done ) {
22+ var fixture = 'signals-sigterm.fixture.js' ;
23+ runMocha ( fixture , args , function postmortem ( err , res ) {
24+ if ( err ) {
25+ return done ( err ) ;
26+ }
27+ expect ( res . code , 'to be' , 143 ) ;
28+ done ( ) ;
29+ } ) ;
30+ } ) ;
2031 } ) ;
2132
22- describe ( 'when enabled with node options' , function ( ) {
23- it ( 'should exit with code 134 on SIGABRT' , function ( done ) {
24- var fixture = 'posix-exit-codes .fixture.js' ;
25- var args = [ '--no-warnings' , '--posix-exit-codes' ] ;
26- mocha = runMocha ( fixture , args , function postmortem ( err , res ) {
33+ describe ( 'when not enabled with node options' , function ( ) {
34+ it ( 'should exit with code null on SIGABRT' , function ( done ) {
35+ var fixture = 'signals-sigabrt .fixture.js' ;
36+ var args = [ '--no-warnings' ] ;
37+ runMocha ( fixture , args , function postmortem ( err , res ) {
2738 if ( err ) {
2839 return done ( err ) ;
2940 }
30- expect ( res . code , 'to be' , 134 ) ;
41+ expect ( res . code , 'to be' , null ) ;
3142 done ( ) ;
3243 } ) ;
3344 } ) ;
0 commit comments