From 5ca3dcd127bfc2f577bcde50d04c0d4fa34a0c8c Mon Sep 17 00:00:00 2001 From: Igor Zinkovsky Date: Sat, 15 Oct 2011 12:21:15 -0700 Subject: [PATCH] test: fix test-child-process-stdin and test-child-process-kill on windows --- test/simple/test-child-process-kill.js | 4 +++- test/simple/test-child-process-stdin.js | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/simple/test-child-process-kill.js b/test/simple/test-child-process-kill.js index 30b99e20fe..05599f48d2 100644 --- a/test/simple/test-child-process-kill.js +++ b/test/simple/test-child-process-kill.js @@ -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) { diff --git a/test/simple/test-child-process-stdin.js b/test/simple/test-child-process-stdin.js index 8e1d18ca48..a58b062926 100644 --- a/test/simple/test-child-process-stdin.js +++ b/test/simple/test-child-process-stdin.js @@ -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); + } });