Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mochajs/mocha
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: acf86876fdbf4144e9926992b83774a7920a78a7
Choose a base ref
..
head repository: mochajs/mocha
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3b59dd86bacb1b09ae04c3df66f4480d4dce9f81
Choose a head ref
4 changes: 2 additions & 2 deletions lib/cli/node-flags.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
* @module
*/

const nodeFlags = require('node-environment-flags');
const nodeFlags = process.allowedNodeEnvironmentFlags;
const unparse = require('yargs-unparser');

/**
@@ -48,7 +48,7 @@ exports.isNodeFlag = (flag, bareword = true) => {
// check actual node flags from `process.allowedNodeEnvironmentFlags`,
// then historical support for various V8 and non-`NODE_OPTIONS` flags
// and also any V8 flags with `--v8-` prefix
(nodeFlags.has(flag) ||
((nodeFlags && nodeFlags.has(flag)) ||
debugFlags.has(flag) ||
/(?:preserve-symlinks(?:-main)?|harmony(?:[_-]|$)|(?:trace[_-].+$)|gc(?:[_-]global)?$|es[_-]staging$|use[_-]strict$|v8[_-](?!options).+?$)/.test(
flag
19 changes: 9 additions & 10 deletions lib/runnable.js
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ function Runnable(title, fn) {
this._retries = -1;
this._currentRetry = 0;
this.pending = false;
this.skipped = false;
}

/**
@@ -304,6 +305,8 @@ Runnable.prototype.run = function(fn) {
var finished;
var emitted;

if (this.isPending() || this.isSkipped()) return fn();

// Sometimes the ctx exists, but it is not runnable
if (ctx && ctx.runnable) {
ctx.runnable(this);
@@ -369,11 +372,7 @@ Runnable.prototype.run = function(fn) {
};

try {
if (this.isPending() || this.isSkipped()) {
done();
} else {
callFnAsync(this.fn);
}
callFnAsync(this.fn);
} catch (err) {
// handles async runnables which actually run synchronously
emitted = true;
@@ -389,11 +388,7 @@ Runnable.prototype.run = function(fn) {

// sync or promise-returning
try {
if (this.isPending() || this.isSkipped()) {
done();
} else {
callFn(this.fn);
}
callFn(this.fn);
} catch (err) {
emitted = true;
if (err instanceof Pending) {
@@ -495,6 +490,10 @@ var constants = utils.defineConstants(
* Value of `state` prop when a `Runnable` has passed
*/
STATE_PASSED: 'passed',
/**
* Value of `state` prop when a `Runnable` has been skipped by user
*/
STATE_PENDING: 'pending',
/**
* Value of `state` prop when a `Runnable` has been skipped by failing hook
*/
13 changes: 8 additions & 5 deletions lib/runner.js
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ var HOOK_TYPE_BEFORE_ALL = Suite.constants.HOOK_TYPE_BEFORE_ALL;
var EVENT_ROOT_SUITE_RUN = Suite.constants.EVENT_ROOT_SUITE_RUN;
var STATE_FAILED = Runnable.constants.STATE_FAILED;
var STATE_PASSED = Runnable.constants.STATE_PASSED;
var STATE_PENDING = Runnable.constants.STATE_PENDING;
var STATE_SKIPPED = Runnable.constants.STATE_SKIPPED;
var dQuote = utils.dQuote;
var sQuote = utils.sQuote;
@@ -284,7 +285,7 @@ Runner.prototype.checkGlobals = function(test) {
* Fail the given `test`.
*
* @private
* @param {Test} test
* @param {Runnable} test
* @param {Error} err
* @param {boolean} [force=false] - Whether to fail a pending test.
*/
@@ -387,7 +388,7 @@ Runner.prototype.hook = function(name, fn) {
});
}

hook.run(function(err) {
hook.run(function cbHookRun(err) {
var testError = hook.error();
if (testError) {
self.fail(self.test, testError);
@@ -413,6 +414,7 @@ Runner.prototype.hook = function(name, fn) {
suite.suites.forEach(function(suite) {
suite.pending = true;
});
hooks = [];
} else {
hook.pending = false;
var errForbid = createUnsupportedError('`this.skip` forbidden');
@@ -545,9 +547,6 @@ Runner.prototype.runTest = function(fn) {
test.asyncOnly = true;
}
test.on('error', function(err) {
if (err instanceof Pending) {
return;
}
self.fail(test, err);
});
if (this.allowUncaught) {
@@ -647,6 +646,7 @@ Runner.prototype.runTests = function(suite, fn) {
if (test.isSkipped()) {
test.state = STATE_SKIPPED;
self.emit(constants.EVENT_TEST_SKIPPED, test);
self.emit(constants.EVENT_TEST_END, test);
return nextTest();
}

@@ -655,6 +655,7 @@ Runner.prototype.runTests = function(suite, fn) {
if (self.forbidPending) {
self.fail(test, new Error('Pending test forbidden'), true);
} else {
test.state = STATE_PENDING;
self.emit(constants.EVENT_TEST_PENDING, test);
}
self.emit(constants.EVENT_TEST_END, test);
@@ -669,6 +670,7 @@ Runner.prototype.runTests = function(suite, fn) {
if (self.forbidPending) {
self.fail(test, new Error('Pending test forbidden'), true);
} else {
test.state = STATE_PENDING;
self.emit(constants.EVENT_TEST_PENDING, test);
}
self.emit(constants.EVENT_TEST_END, test);
@@ -691,6 +693,7 @@ Runner.prototype.runTests = function(suite, fn) {
if (self.forbidPending) {
self.fail(test, new Error('Pending test forbidden'), true);
} else {
test.state = STATE_PENDING;
self.emit(constants.EVENT_TEST_PENDING, test);
}
self.emit(constants.EVENT_TEST_END, test);
6 changes: 3 additions & 3 deletions lib/stats-collector.js
Original file line number Diff line number Diff line change
@@ -24,8 +24,8 @@ var EVENT_RUN_END = constants.EVENT_RUN_END;
* @property {number} tests - integer count of tests run.
* @property {number} passes - integer count of passing tests.
* @property {number} pending - integer count of pending tests.
* @property {number} failures - integer count of failed tests.
* @property {number} skipped - integer count of skipped tests.
* @property {number} failures - integer count of failed tests.
* @property {Date} start - time when testing began.
* @property {Date} end - time when testing concluded.
* @property {number} duration - number of msecs that testing took.
@@ -49,8 +49,8 @@ function createStatsCollector(runner) {
tests: 0,
passes: 0,
pending: 0,
failures: 0,
skipped: 0
skipped: 0,
failures: 0
};

if (!runner) {
Loading