Skip to content

Commit 74ec175

Browse files
committed
[test] Kill child process when exiting test runner
1 parent 3531fd6 commit 74ec175

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Diff for: test/core/run-single

+15-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ var path = require('path'),
3939
httpProxy = require('../../'),
4040
common = require('./common');
4141

42-
var test = process.argv[2];
42+
var test = process.argv[2],
43+
done = false,
44+
testProcess;
4345

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

5355
proxy.on('listening', function () {
5456
console.log('Proxy server listening on ' + common.PROXY_PORT);
55-
var testProcess = spawn(process.argv[0], [ process.argv[2] ]);
57+
testProcess = spawn(process.argv[0], [ process.argv[2] ]);
5658
testProcess.stdout.pipe(process.stdout);
5759
testProcess.stderr.pipe(process.stderr);
58-
testProcess.on('exit', process.exit);
60+
61+
testProcess.on('exit', function () {
62+
done = true;
63+
process.exit();
64+
});
5965
});
6066

61-
// vim:filetype=javascript
67+
process.on('exit', function () {
68+
if (!done) {
69+
textProcess.kill();
70+
}
71+
});
6272

73+
// vim:filetype=javascript

0 commit comments

Comments
 (0)