File tree Expand file tree Collapse file tree 3 files changed +19
-30
lines changed
Expand file tree Collapse file tree 3 files changed +19
-30
lines changed Original file line number Diff line number Diff line change @@ -627,14 +627,8 @@ function _safely_install_sigint_listener() {
627627 // ignore
628628 }
629629 }
630- try {
631- // force the garbage collector even it is called again in the exit listener
632- _garbageCollector ( ) ;
633- } finally {
634- if ( ! ! doExit ) {
635- process . exit ( 0 ) ;
636- }
637- }
630+ // force the garbage collector even it is called again in the exit listener
631+ _garbageCollector ( ) ;
638632 } ) ;
639633}
640634
Original file line number Diff line number Diff line change 77 os = require ( 'os' ) ,
88 rimraf = require ( 'rimraf' ) ,
99 testCases = [
10- { signal : 'SIGINT' , expectExists : false } ,
11- { signal : 'SIGTERM' , expectExists : true }
10+ 'SIGINT' ,
11+ 'SIGTERM'
1212 ] ;
1313
1414// skip tests on win32
@@ -18,10 +18,10 @@ const tfunc = isWindows ? xit : it;
1818describe ( 'tmp' , function ( ) {
1919 describe ( 'issue121 - clean up on terminating signals' , function ( ) {
2020 for ( let tc of testCases ) {
21- tfunc ( 'for signal ' + tc . signal , function ( done ) {
22- // increase timeout so that the child process may fail
23- this . timeout ( 20000 ) ;
24- issue121Tests ( tc . signal , tc . expectExists ) ( done ) ;
21+ tfunc ( 'for signal ' + tc , function ( done ) {
22+ // increase timeout so that the child process may terminate in time
23+ this . timeout ( 5000 ) ;
24+ issue121Tests ( tc ) ( done ) ;
2525 } ) ;
2626 }
2727 } ) ;
@@ -33,22 +33,8 @@ function issue121Tests(signal, expectExists) {
3333 if ( err ) return done ( err ) ;
3434 else if ( stderr ) return done ( new Error ( stderr ) ) ;
3535
36- try {
37- if ( expectExists ) {
38- assertions . assertExists ( stdout ) ;
39- }
40- else {
41- assertions . assertDoesNotExist ( stdout ) ;
42- }
43- done ( ) ;
44- } catch ( err ) {
45- done ( err ) ;
46- } finally {
47- // cleanup
48- if ( expectExists ) {
49- rimraf . sync ( stdout ) ;
50- }
51- }
36+ assertions . assertDoesNotExist ( stdout ) ;
37+ done ( ) ;
5238 } , signal ) ;
5339 } ;
5440}
Original file line number Diff line number Diff line change 44const
55 tmp = require ( '../../lib/tmp' ) ;
66
7+ // install exit handler since tmp will no longer exit on its own
8+ process . on ( 'SIGINT' , function ( ) {
9+ process . exit ( 0 ) ;
10+ } ) ;
11+
12+ process . on ( 'SIGTERM' , function ( ) {
13+ process . exit ( 0 ) ;
14+ } ) ;
15+
716// https://github.com/raszi/node-tmp/issues/121
817module . exports = function ( ) {
918
You can’t perform that action at this time.
0 commit comments