From 74ec1757153c503ce57eb552031648fe79731d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sun, 28 Oct 2012 14:31:15 +0100 Subject: [PATCH] [test] Kill child process when exiting test runner --- test/core/run-single | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/test/core/run-single b/test/core/run-single index ff1af48..bcfdb5b 100755 --- a/test/core/run-single +++ b/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(); + }); +}); + +process.on('exit', function () { + if (!done) { + textProcess.kill(); + } }); // vim:filetype=javascript -