test: fix test-child-process-stdin and test-child-process-kill on windows
authorIgor Zinkovsky <igorzi@microsoft.com>
Sat, 15 Oct 2011 19:21:15 +0000 (12:21 -0700)
committerBen Noordhuis <info@bnoordhuis.nl>
Sat, 15 Oct 2011 20:55:24 +0000 (22:55 +0200)
test/simple/test-child-process-kill.js
test/simple/test-child-process-stdin.js

index 30b99e20fe60945d3e8c83eecdb3384a8cf0e425..05599f48d2febfe0beaee3a4099b001fab27c8d9 100644 (file)
@@ -27,12 +27,14 @@ var assert = require('assert');
 
 var spawn = require('child_process').spawn;
 
+var is_windows = process.platform === 'win32';
+
 var exitCode;
 var termSignal;
 var gotStdoutEOF = false;
 var gotStderrEOF = false;
 
-var cat = spawn('cat');
+var cat = spawn(is_windows ? 'cmd' : 'cat');
 
 
 cat.stdout.on('data', function(chunk) {
index 8e1d18ca4817082d0cfcd9f6c58b9c230a7d763f..a58b062926439c434f2704a99ab04f7304a7bc9e 100644 (file)
@@ -23,8 +23,9 @@ var common = require('../common');
 var assert = require('assert');
 
 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(' ');
 cat.stdin.write('world');
@@ -65,10 +66,18 @@ cat.stderr.on('end', function(chunk) {
 cat.on('exit', function(status) {
   console.log('exit event');
   exitStatus = status;
-  assert.equal('hello world', response);
+  if (is_windows) {
+    assert.equal('hello world\r\n', response);
+  } else {
+    assert.equal('hello world', response);
+  }
 });
 
 process.on('exit', function() {
   assert.equal(0, exitStatus);
-  assert.equal('hello world', response);
+  if (is_windows) {
+    assert.equal('hello world\r\n', response);
+  } else {
+    assert.equal('hello world', response);
+  }
 });