Partial fix for test-child-process.cwd on windows
authorBert Belder <bertbelder@gmail.com>
Tue, 2 Aug 2011 01:19:57 +0000 (03:19 +0200)
committerBert Belder <bertbelder@gmail.com>
Tue, 2 Aug 2011 01:27:19 +0000 (03:27 +0200)
test/simple/test-child-process-cwd.js

index eeca22e7aff77a4494415514cbd25792e104b322..5fc5c07d59d2fbf060bb21b7e195dffdf3c68f42 100644 (file)
@@ -33,9 +33,13 @@ var returns = 0;
     (after removing traling whitespace)
 */
 function testCwd(options, forCode, forData) {
-  var data = '';
+  var child, data = '';
 
-  var child = spawn('pwd', [], 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) {
@@ -52,8 +56,13 @@ function testCwd(options, forCode, forData) {
 }
 
 // Assume these exist, and 'pwd' gives us the right directory back
-testCwd({cwd: '/dev'}, 0, '/dev');
-testCwd({cwd: '/'}, 0, '/');
+if (process.platform == "win32") {
+  testCwd({cwd: process.env.windir}, 0, process.env.windir);
+  testCwd({cwd: 'c:\\'}, 0, 'c:\\');
+} else {
+  testCwd({cwd: '/dev'}, 0, '/dev');
+  testCwd({cwd: '/'}, 0, '/');
+}
 
 // Assume this doesn't exist, we expect exitcode=127
 testCwd({cwd: 'does-not-exist'}, 127);