test/simple/test-child-process-cwd.js
/*
  Spawns 'pwd' with given options, then test
  - whether the exit code equals forCode,
  - optionally whether the stdout result matches forData
    (after removing traling whitespace)
*/
Spawns 'pwd' with given options, then test
whether the exit code equals forCode,
optionally whether the stdout result matches forData
(after removing traling whitespace)
Spawns ' pwd ' with given options then test whether the exit code equals forCode optionally whether the stdout result matches forData ( after removing traling whitespace )
function testCwd(options, forCode, forData) {
  var data = '';
  var child = spawn('pwd', [], options);
  child.stdout.setEncoding('utf8');
  child.stdout.addListener('data', function(chunk) {
    data += chunk;
  });
  child.addListener('exit', function(code, signal) {
    forData && assert.strictEqual(forData, data.replace(/[\s\r\n]+$/, ''));
    assert.strictEqual(forCode, code);
    returns--;
  });
  returns++;
}
function testCwd ( options , forCode , forData ) { var data = '' ; var child = spawn ( 'pwd' , [ ] , options ) ; child . stdout . setEncoding ( 'utf8' ) ; child . stdout . addListener ( 'data' , function ( chunk ) { data += chunk ; } ) ; child . addListener ( 'exit' , function ( code , signal ) { forData && assert . strictEqual ( forData , data . replace ( / [\s\r\n]+$ / , '' ) ) ; assert . strictEqual ( forCode , code ) ; returns -- ; } ) ; returns ++ ; }
Spawns 'pwd' with given options, then test
 whether the exit code equals forCode,
 optionally whether the stdout result matches forData
(after removing traling whitespace)
Spawns ' pwd ' with given options then test whether the exit code equals forCode optionally whether the stdout result matches forData ( after removing traling whitespace )