Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[test] Kill child process when exiting test runner
  • Loading branch information
mmalecki committed Oct 28, 2012
1 parent 3531fd6 commit 74ec175
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test/core/run-single
Expand Up @@ -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');
Expand All @@ -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.