Skip to content
Permalink
Browse files

[test] Kill child process when exiting test runner

  • Loading branch information...
mmalecki committed Oct 28, 2012
1 parent 3531fd6 commit 74ec1757153c503ce57eb552031648fe79731d48
Showing with 15 additions and 4 deletions.
  1. +15 −4 test/core/run-single
@@ -39,7 +39,9 @@ var path = require('path'),
httpProxy = require('../../'),
common = require('./common');

var test = process.argv[2];
var test = process.argv[2],
done = false,
testProcess;

if (!test) {
return console.error('Need test to run');
@@ -52,11 +54,20 @@ proxy.listen(common.PROXY_PORT);

proxy.on('listening', function () {
console.log('Proxy server listening on ' + common.PROXY_PORT);
var testProcess = spawn(process.argv[0], [ process.argv[2] ]);
testProcess = spawn(process.argv[0], [ process.argv[2] ]);
testProcess.stdout.pipe(process.stdout);
testProcess.stderr.pipe(process.stderr);
testProcess.on('exit', process.exit);

testProcess.on('exit', function () {
done = true;
process.exit();
});
});

// vim:filetype=javascript
process.on('exit', function () {
if (!done) {
textProcess.kill();
}
});

// vim:filetype=javascript

0 comments on commit 74ec175

Please sign in to comment.
You can’t perform that action at this time.