Browse Source

test: fix test-child-process-stdin and test-child-process-kill on windows

v0.7.4-release
Igor Zinkovsky 13 years ago
committed by Ben Noordhuis
parent
commit
5ca3dcd127
  1. 4
      test/simple/test-child-process-kill.js
  2. 11
      test/simple/test-child-process-stdin.js

4
test/simple/test-child-process-kill.js

@ -27,12 +27,14 @@ var assert = require('assert');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var is_windows = process.platform === 'win32';
var exitCode; var exitCode;
var termSignal; var termSignal;
var gotStdoutEOF = false; var gotStdoutEOF = false;
var gotStderrEOF = false; var gotStderrEOF = false;
var cat = spawn('cat'); var cat = spawn(is_windows ? 'cmd' : 'cat');
cat.stdout.on('data', function(chunk) { cat.stdout.on('data', function(chunk) {

11
test/simple/test-child-process-stdin.js

@ -23,8 +23,9 @@ var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var is_windows = process.platform === 'win32';
var cat = spawn('cat'); var cat = spawn(is_windows ? 'more' : 'cat');
cat.stdin.write('hello'); cat.stdin.write('hello');
cat.stdin.write(' '); cat.stdin.write(' ');
cat.stdin.write('world'); cat.stdin.write('world');
@ -65,10 +66,18 @@ cat.stderr.on('end', function(chunk) {
cat.on('exit', function(status) { cat.on('exit', function(status) {
console.log('exit event'); console.log('exit event');
exitStatus = status; exitStatus = status;
if (is_windows) {
assert.equal('hello world\r\n', response);
} else {
assert.equal('hello world', response); assert.equal('hello world', response);
}
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(0, exitStatus); assert.equal(0, exitStatus);
if (is_windows) {
assert.equal('hello world\r\n', response);
} else {
assert.equal('hello world', response); assert.equal('hello world', response);
}
}); });

Loading…
Cancel
Save