Not clear why, but child processes are not killed
This commit is contained in:
parent
ddc64e81dc
commit
7d2c0d538b
@ -9,6 +9,7 @@ var debug = require('debug')('e2e:runner'),
|
||||
semver = require('semver'),
|
||||
mailer = require('./mailer.js'),
|
||||
superagent = require('superagent'),
|
||||
terminate = require('terminate'),
|
||||
util = require('util');
|
||||
|
||||
// override debug.log to print only as console.log
|
||||
@ -16,11 +17,21 @@ debug.log = console.log.bind(console);
|
||||
|
||||
var gLastModified = null; // do not use etag since it only hashes body. touching file to rerun tests is nice
|
||||
var gLatestBoxVersion = null; // for sending mail
|
||||
var gNpmTest = null;
|
||||
|
||||
function cleanExit() {
|
||||
if (gNpmTest) {
|
||||
debug('Terminating child test process %s', gNpmTest.pid);
|
||||
terminate(gNpmTest.pid, process.exit);
|
||||
gNpmTest = null;
|
||||
} else {
|
||||
debug('No child test process to terminate');
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
|
||||
function start() {
|
||||
runTestsIfNeeded(function () {
|
||||
setTimeout(start, 60 * 1000);
|
||||
});
|
||||
setTimeout(runTestsIfNeeded.bind(null, start), 60 * 1000);
|
||||
}
|
||||
|
||||
function runTestsIfNeeded(callback) {
|
||||
@ -73,7 +84,8 @@ function runTests(latestETag, latestBoxVersion, callback) {
|
||||
|
||||
debug('Running tests for %s', topic);
|
||||
|
||||
shell.system('e2etestrunner', 'npm test', function (error, stdout, stderr) {
|
||||
gNpmTest = shell.system('e2etestrunner', 'npm test', function (error, stdout, stderr) {
|
||||
gNpmTest = null;
|
||||
debug('Final test result', error);
|
||||
|
||||
mailer.sendEndToEndTestResult(topic, stdout ? stdout.toString('utf8') : '', stderr ? stderr.toString('utf8') : '', function () { });
|
||||
@ -82,4 +94,10 @@ function runTests(latestETag, latestBoxVersion, callback) {
|
||||
}
|
||||
|
||||
debug('e2etest started.');
|
||||
|
||||
process.on('exit', cleanExit);
|
||||
process.on('SIGINT', cleanExit); // catch ctrl-c
|
||||
process.on('SIGTERM', cleanExit); // catch kill
|
||||
process.on('uncaughtException', cleanExit);
|
||||
|
||||
start();
|
||||
|
@ -28,6 +28,7 @@
|
||||
"stripe": "^3.5.0",
|
||||
"superagent": "^1.2.0",
|
||||
"superagent-sync": "^0.1.0",
|
||||
"supererror": "^0.7.0"
|
||||
"supererror": "^0.7.0",
|
||||
"terminate": "^1.0.5"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user