Skip to content

Commit

Permalink
Merge branch 'master' into growl
Browse files Browse the repository at this point in the history
  • Loading branch information
plroebuck authored Dec 14, 2018
2 parents 372fab6 + 3d3e833 commit 1f06d4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/cli/run-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,15 @@ exports.singleRun = (mocha, {files = [], exit = false} = {}) => {
mocha.files = files;
const runner = mocha.run(exit ? exitMocha : exitMochaLater);

process.on('SIGINT', () => {
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;

This comment has been minimized.

Copy link
@plroebuck

plroebuck Dec 14, 2018

Author Contributor

Would set process.exitCode as well here JIC.

    process.exitCode = runner.failures = 130;
setImmediate(() => process.kill(process.pid, 'SIGINT'));

This comment has been minimized.

Copy link
@plroebuck

plroebuck Dec 14, 2018

Author Contributor

Don't think we need to reraise signal when running under Node (unlike C).
Let user press / again instead.

});
};

Expand Down
19 changes: 14 additions & 5 deletions lib/stats-collector.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
'use strict';

/**
* Provides a factory function for a {@link StatsCollector} object.
* @private
* @module
*/

/**
* Test statistics collector.
*
* @private
* @typedef {Object} StatsCollector
* @property {number} suites - integer count of suites run.
* @property {number} tests - integer count of tests run.
Expand All @@ -15,14 +22,16 @@
*/

/**
* Provides stats such as test duration,
* number of tests passed / failed etc.
* Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`.
*
* @public
* @memberof Mocha
* @param {Runner} runner
* @private
* @param {Runner} runner - Runner instance
* @throws {TypeError} If falsy `runner`
*/
function createStatsCollector(runner) {
/**
* @type StatsCollector
*/
var stats = {
suites: 0,
tests: 0,
Expand Down

0 comments on commit 1f06d4e

Please sign in to comment.