@@ -28,11 +28,14 @@ const assert = require('assert');
2828const { spawn } = require ( 'child_process' ) ;
2929
3030// Spawns 'pwd' with given options, then test
31+ // - whether the child pid is undefined or number,
3132// - whether the exit code equals expectCode,
3233// - optionally whether the trimmed stdout result matches expectData
33- function testCwd ( options , expectCode = 0 , expectData ) {
34+ function testCwd ( options , expectPidType , expectCode = 0 , expectData ) {
3435 const child = spawn ( ...common . pwdCommand , options ) ;
3536
37+ assert . strictEqual ( typeof child . pid , expectPidType ) ;
38+
3639 child . stdout . setEncoding ( 'utf8' ) ;
3740
3841 // No need to assert callback since `data` is asserted.
@@ -57,18 +60,18 @@ function testCwd(options, expectCode = 0, expectData) {
5760
5861// Assume does-not-exist doesn't exist, expect exitCode=-1 and errno=ENOENT
5962{
60- testCwd ( { cwd : 'does-not-exist' } , - 1 )
63+ testCwd ( { cwd : 'does-not-exist' } , 'undefined' , - 1 )
6164 . on ( 'error' , common . mustCall ( function ( e ) {
6265 assert . strictEqual ( e . code , 'ENOENT' ) ;
6366 } ) ) ;
6467}
6568
6669// Assume these exist, and 'pwd' gives us the right directory back
67- testCwd ( { cwd : tmpdir . path } , 0 , tmpdir . path ) ;
70+ testCwd ( { cwd : tmpdir . path } , 'number' , 0 , tmpdir . path ) ;
6871const shouldExistDir = common . isWindows ? process . env . windir : '/dev' ;
69- testCwd ( { cwd : shouldExistDir } , 0 , shouldExistDir ) ;
72+ testCwd ( { cwd : shouldExistDir } , 'number' , 0 , shouldExistDir ) ;
7073
7174// Spawn() shouldn't try to chdir() to invalid arg, so this should just work
72- testCwd ( { cwd : '' } ) ;
73- testCwd ( { cwd : undefined } ) ;
74- testCwd ( { cwd : null } ) ;
75+ testCwd ( { cwd : '' } , 'number' ) ;
76+ testCwd ( { cwd : undefined } , 'number' ) ;
77+ testCwd ( { cwd : null } , 'number' ) ;
0 commit comments