From 4983bd348dfe50538990badc7c73c48ca1c68e0b Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 10 Aug 2011 11:22:58 -0700 Subject: [PATCH] x-platform func for spawning pwd in tests Fixes test-child-process-buffering --- test/common.js | 10 ++++++++++ test/simple/test-child-process-buffering.js | 2 +- test/simple/test-child-process-cwd.js | 9 +++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/test/common.js b/test/common.js index 2486724040..de89a3c20e 100644 --- a/test/common.js +++ b/test/common.js @@ -61,6 +61,16 @@ exports.ddCommand = function(filename, kilobytes) { }; +exports.spawnPwd = function(options) { + var spawn = require('child_process').spawn; + + if (process.platform == "win32") { + return spawn('cmd.exe', ['/c', 'cd'], options); + } else { + return spawn('pwd', [], options); + } +}; + // Turn this off if the test should not check for global leaks. exports.globalCheck = true; diff --git a/test/simple/test-child-process-buffering.js b/test/simple/test-child-process-buffering.js index f377273686..4e5655f684 100644 --- a/test/simple/test-child-process-buffering.js +++ b/test/simple/test-child-process-buffering.js @@ -28,7 +28,7 @@ var pwd_called = false; function pwd(callback) { var output = ''; - var child = spawn('pwd'); + var child = common.spawnPwd(); child.stdout.setEncoding('utf8'); child.stdout.addListener('data', function(s) { diff --git a/test/simple/test-child-process-cwd.js b/test/simple/test-child-process-cwd.js index 5fc5c07d59..4260b39716 100644 --- a/test/simple/test-child-process-cwd.js +++ b/test/simple/test-child-process-cwd.js @@ -33,13 +33,10 @@ var returns = 0; (after removing traling whitespace) */ function testCwd(options, forCode, forData) { - var child, data = ''; + var data = ''; + + var child = common.spawnPwd(options); - if (process.platform == "win32") { - child = spawn('cmd.exe', ['/c', 'cd'], options); - } else { - child = spawn('pwd', [], options); - } child.stdout.setEncoding('utf8'); child.stdout.addListener('data', function(chunk) {