@@ -32,7 +32,7 @@ const { spawn } = require('child_process');
3232// - whether the child pid is undefined or number,
3333// - whether the exit code equals expectCode,
3434// - optionally whether the trimmed stdout result matches expectData
35- function testCwd ( options , expectPidType , expectCode = 0 , expectData ) {
35+ function testCwd ( options , expectPidType , expectCode = 0 , expectData , shouldCallExit = true ) {
3636 const child = spawn ( ...common . pwdCommand , options ) ;
3737
3838 assert . strictEqual ( typeof child . pid , expectPidType ) ;
@@ -47,9 +47,9 @@ function testCwd(options, expectPidType, expectCode = 0, expectData) {
4747
4848 // Can't assert callback, as stayed in to API:
4949 // _The 'exit' event may or may not fire after an error has occurred._
50- child . on ( 'exit' , function ( code , signal ) {
50+ child . on ( 'exit' , shouldCallExit ? common . mustCall ( ( code ) => {
5151 assert . strictEqual ( code , expectCode ) ;
52- } ) ;
52+ } ) : common . mustNotCall ( ) ) ;
5353
5454 child . on ( 'close' , common . mustCall ( function ( ) {
5555 if ( expectData ) {
@@ -68,7 +68,7 @@ function testCwd(options, expectPidType, expectCode = 0, expectData) {
6868
6969// Assume does-not-exist doesn't exist, expect exitCode=-1 and errno=ENOENT
7070{
71- testCwd ( { cwd : 'does-not-exist' } , 'undefined' , - 1 )
71+ testCwd ( { cwd : 'does-not-exist' } , 'undefined' , - 1 , undefined , false )
7272 . on ( 'error' , common . mustCall ( function ( e ) {
7373 assert . strictEqual ( e . code , 'ENOENT' ) ;
7474 } ) ) ;
0 commit comments