Created
March 13, 2012 15:23
-
-
Save eladb/2029393 to your computer and use it in GitHub Desktop.
node.js test fails when pipes are not closed on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('child_process').spawn(process.execPath, ['grandchild']); | |
// exit after 500ms | |
setTimeout(function() { process.exit(1); }, 500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// exit after 2s | |
setTimeout(function() { process.exit(0); }, 2000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spawn = require('child_process').spawn; | |
var assert = require('assert'); | |
process.chdir(__dirname); | |
var start = Date.now(); | |
var child = spawn(process.execPath, ['child']); | |
child.on('exit', function() { | |
var elapsed = Date.now() - start; | |
console.log('elapsed time to exit: %dms', elapsed); | |
assert.ok(elapsed < 2000, 'expecting exit event to be emitted after less than 2s since child exits after 500ms'); | |
process.exit(0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment