mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[test] Kill child process when exiting test runner
This commit is contained in:
parent
3531fd609a
commit
74ec175715
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
process.on('exit', function () {
|
||||
if (!done) {
|
||||
textProcess.kill();
|
||||
}
|
||||
});
|
||||
|
||||
// vim:filetype=javascript
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user