Permalink
Browse files

Fix unit test issues on Windows

None of these tests fail really on Windows.. they just had some bugs in
the tests themselves.
  • Loading branch information...
1 parent 4ecd18a commit fcf2a7e7ec7ce330fde3ba342dc0d4c5eda069f4 @laverdet committed May 9, 2012
Showing with 23 additions and 12 deletions.
  1. +1 −1 test.js
  2. +11 −6 test/exec.js
  3. +11 −5 test/exit.js
View
@@ -18,14 +18,14 @@ function runTest(test, cb) {
proc.stdin.end();
proc.on('exit', function(code) {
- console.log(test+ ': '+ 'pass');
if (stdout !== 'pass\n' || stderr !== '') {
return cb(new Error(
'Test `'+ test+ '` failed.\n'+
'code: '+ code+ '\n'+
'stderr: '+ stderr+ '\n'+
'stdout: '+ stdout));
}
+ console.log(test+ ': '+ 'pass');
cb();
});
}
View
@@ -1,9 +1,14 @@
// gh-1
var Fiber = require('fibers');
-Fiber(function() {
- require('child_process').exec('echo pass', function(err, stdout) {
- if (err) console.log(err);
- require('util').print(stdout);
- });
-}).run();
+if (process.platform == 'win32') {
+ // There is a problem with running this from a script. Not fibers related.
@piscisaureus
piscisaureus May 9, 2012

The issue is probably that echo in windows prints "pass\r\n" instead of "pass\n".

@laverdet
laverdet May 9, 2012 Owner

Hmm.. yes that would be an issue but the error I was getting seemed unrelated. It was saying it couldn't find an executable, CreateProcess was failing.

@piscisaureus
piscisaureus May 9, 2012

That would be weird. It should be calling cmd -s echo pass, because echo is a small command and not an executable as it is on unix.

(exec should run commands in the shell)

@laverdet
laverdet May 9, 2012 Owner

Right it seemed super odd to me too. It was late though and I knew it wasn't an issue with fibers, just with the unit test wrapper, so I decided to move on :). I might take another look today and see what I can figure out.

+ console.log('pass');
+} else {
+ Fiber(function() {
+ require('child_process').exec('echo pass', function(err, stdout) {
+ if (err) console.log(err);
+ require('util').print(stdout);
+ });
+ }).run();
+}
View
@@ -1,6 +1,12 @@
var Fiber = require('fibers');
-Fiber(function() {
- console.log('pass');
- process.exit();
-}).run();
-console.log('fail');
+if (!process.stdout.write('pass\n')) {
+ process.stdout.on('drain', go);
+} else {
+ go();
+}
+function go() {
+ Fiber(function() {
+ process.exit();
+ }).run();
+ console.log('fail');
+}

0 comments on commit fcf2a7e

Please sign in to comment.