Skip to content

Commit

Permalink
remove SIGINT handler for single runs; see #3570
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Dec 14, 2018
1 parent 4351697 commit e886ac1
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions lib/cli/run-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,12 @@ exports.handleFiles = ({
* @param {Options} [opts] - Options
* @param {string[]} [opts.files] - List of test files
* @param {boolean} [opts.exit] - Whether or not to force-exit after tests are complete
* @returns {Runner}
* @private
*/
exports.singleRun = (mocha, {files = [], exit = false} = {}) => {
mocha.files = files;
const runner = mocha.run(exit ? exitMocha : exitMochaLater);

process.once('SIGINT', () => {
debug('aborting runner');
runner.abort();

// This is a hack:
// Instead of `process.exit(130)`, set runner.failures to 130 (exit code for SIGINT)
// The amount of failures will be emitted as error code later
runner.failures = 130;
setImmediate(() => process.kill(process.pid, 'SIGINT'));
});
return mocha.run(exit ? exitMocha : exitMochaLater);
};

/**
Expand Down

0 comments on commit e886ac1

Please sign in to comment.