Skip to content

Commit

Permalink
rename some stuff
Browse files Browse the repository at this point in the history
- `Buffered` reporter becomes `ParallelBuffered`
- `BufferedRunner` becomes `ParallelBufferedRunner`

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
  • Loading branch information
boneskull committed May 28, 2020
1 parent f854f51 commit afc00ce
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions karma.conf.js
Expand Up @@ -40,8 +40,8 @@ module.exports = config => {
.ignore('./lib/nodejs/serializer.js')
.ignore('./lib/nodejs/worker.js')
.ignore('./lib/nodejs/buffered-worker-pool.js')
.ignore('./lib/nodejs/buffered-runner.js')
.ignore('./lib/nodejs/reporters/buffered.js')
.ignore('./lib/nodejs/parallel-buffered-runner.js')
.ignore('./lib/nodejs/reporters/parallel-buffered.js')
.on('bundled', (err, content) => {
if (err) {
throw err;
Expand Down
2 changes: 1 addition & 1 deletion lib/mocha.js
Expand Up @@ -1063,7 +1063,7 @@ Mocha.prototype.parallelMode = function parallelMode(enable) {

// swap Runner class
this._runnerClass = parallel
? require('./nodejs/buffered-runner')
? require('./nodejs/parallel-buffered-runner')
: exports.Runner;

// lazyLoadFiles may have been set `true` otherwise (for ESM loading),
Expand Down
@@ -1,6 +1,6 @@
/**
* A test Runner that uses a {@link module:buffered-worker-pool}.
* @module buffered-runner
* @module parallel-buffered-runner
* @private
*/

Expand All @@ -9,7 +9,7 @@
const allSettled = require('promise.allsettled');
const Runner = require('../runner');
const {EVENT_RUN_BEGIN, EVENT_RUN_END} = Runner.constants;
const debug = require('debug')('mocha:parallel:buffered-runner');
const debug = require('debug')('mocha:parallel:parallel-buffered-runner');
const {BufferedWorkerPool} = require('./buffered-worker-pool');
const {setInterval, clearInterval} = global;
const {createMap} = require('../utils');
Expand Down Expand Up @@ -58,7 +58,7 @@ const states = createMap({
* {@link Runnable}s by itself!
* @private
*/
class BufferedRunner extends Runner {
class ParallelBufferedRunner extends Runner {
constructor(...args) {
super(...args);

Expand Down Expand Up @@ -277,7 +277,7 @@ class BufferedRunner extends Runner {
}
}

module.exports = BufferedRunner;
module.exports = ParallelBufferedRunner;

/**
* Listener function intended to be bound to `Process.SIGINT` event
Expand Down
@@ -1,6 +1,6 @@
/**
* "Buffered" reporter used internally by a worker process when running in parallel mode.
* @module reporters/buffered
* @module reporters/parallel-buffered
* @private
*/

Expand Down Expand Up @@ -31,7 +31,7 @@ const Base = require('../../reporters/base');

/**
* List of events to listen to; these will be buffered and sent
* when `Mocha#run` is complete (via {@link Buffered#done}).
* when `Mocha#run` is complete (via {@link ParallelBuffered#done}).
*/
const EVENT_NAMES = [
EVENT_SUITE_BEGIN,
Expand All @@ -53,13 +53,13 @@ const EVENT_NAMES = [
const ONCE_EVENT_NAMES = [EVENT_DELAY_BEGIN, EVENT_DELAY_END];

/**
* The `Buffered` reporter is for use by concurrent runs. Instead of outputting
* The `ParallelBuffered` reporter is for use by concurrent runs. Instead of outputting
* to `STDOUT`, etc., it retains a list of events it receives and hands these
* off to the callback passed into {@link Mocha#run}. That callback will then
* return the data to the main process.
* @private
*/
class Buffered extends Base {
class ParallelBuffered extends Base {
/**
* Listens for {@link Runner} events and retains them in an `events` instance prop.
* @param {Runner} runner
Expand Down Expand Up @@ -130,4 +130,4 @@ class Buffered extends Base {
* @property {object} data - Event parameters
*/

module.exports = Buffered;
module.exports = ParallelBuffered;
4 changes: 3 additions & 1 deletion lib/nodejs/serializer.js
Expand Up @@ -8,6 +8,8 @@

const {type} = require('../utils');
const {createInvalidArgumentTypeError} = require('../errors');
// this is not named `mocha:parallel:serializer` because it's noisy and it's
// helpful to be able to write `DEBUG=mocha:parallel*` and get everything else.
const debug = require('debug')('mocha:serializer');

const SERIALIZABLE_RESULT_NAME = 'SerializableWorkerResult';
Expand Down Expand Up @@ -322,7 +324,7 @@ class SerializableEvent {
/**
* Deserialize value returned from a worker into something more useful.
* Does not return the same object.
* @todo - do this in a loop instead of with recursion (if necessary)
* @todo do this in a loop instead of with recursion (if necessary)
* @param {SerializedEvent} obj - Object returned from worker
* @returns {SerializedEvent} Deserialized result
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/nodejs/worker.js
@@ -1,5 +1,5 @@
/**
* A worker process. Consumes {@link module:reporters/buffered} reporter.
* A worker process. Consumes {@link module:reporters/parallel-buffered} reporter.
* @module worker
* @private
*/
Expand All @@ -23,7 +23,7 @@ const isDebugEnabled = d.enabled(`mocha:parallel:worker:${process.pid}`);
const {serialize} = require('./serializer');
const {setInterval, clearInterval} = global;

const BUFFERED_REPORTER_PATH = require.resolve('./reporters/buffered');
const BUFFERED_REPORTER_PATH = require.resolve('./reporters/parallel-buffered');

let rootHooks;

Expand Down
4 changes: 2 additions & 2 deletions package-scripts.js
Expand Up @@ -44,8 +44,8 @@ module.exports = {
--ignore './lib/cli/*.js' \
--ignore './lib/esm-utils.js' \
--ignore './lib/nodejs/serializer.js' \
--ignore './lib/nodejs/buffered-runner.js' \
--ignore './lib/nodejs/reporters/buffered.js' \
--ignore './lib/nodejs/parallel-buffered-runner.js' \
--ignore './lib/nodejs/reporters/parallel-buffered.js' \
--ignore './lib/nodejs/worker.js' \
--ignore './lib/nodejs/buffered-worker-pool.js' \
-o mocha.js`,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -166,8 +166,8 @@
"./lib/nodejs/serializer.js": false,
"./lib/nodejs/worker.js": false,
"./lib/nodejs/buffered-worker-pool.js": false,
"./lib/nodejs/buffered-runner.js": false,
"./lib/nodejs/reporters/buffered.js": false
"./lib/nodejs/parallel-buffered-runner.js": false,
"./lib/nodejs/reporters/parallel-buffered.js": false
},
"prettier": {
"singleQuote": true,
Expand Down
2 changes: 1 addition & 1 deletion test/node-unit/buffered-runner.spec.js
Expand Up @@ -9,7 +9,7 @@ const {
} = require('../../lib/runner').constants;
const rewiremock = require('rewiremock/node');
const BUFFERED_RUNNER_PATH = require.resolve(
'../../lib/nodejs/buffered-runner.js'
'../../lib/nodejs/parallel-buffered-runner.js'
);
const Suite = require('../../lib/suite');
const Runner = require('../../lib/runner');
Expand Down
2 changes: 1 addition & 1 deletion test/node-unit/mocha.spec.js
Expand Up @@ -57,7 +57,7 @@ describe('Mocha', function() {
Mocha = rewiremock.proxy(MODULE_PATH, r => ({
'../../lib/utils.js': r.with(stubs.utils).callThrough(),
'../../lib/suite.js': stubs.Suite,
'../../lib/nodejs/buffered-runner.js': stubs.BufferedRunner,
'../../lib/nodejs/parallel-buffered-runner.js': stubs.BufferedRunner,
'../../lib/runner.js': stubs.Runner
}));
delete require.cache[DUMB_FIXTURE_PATH];
Expand Down
2 changes: 1 addition & 1 deletion test/node-unit/reporters/buffered.spec.js
Expand Up @@ -31,7 +31,7 @@ describe('Buffered', function() {
sandbox = createSandbox();
runner = new EventEmitter();
Buffered = rewiremock.proxy(
require.resolve('../../../lib/nodejs/reporters/buffered'),
require.resolve('../../../lib/nodejs/reporters/parallel-buffered'),
{
'../../../lib/nodejs/serializer': {
SerializableEvent: {
Expand Down

0 comments on commit afc00ce

Please sign in to comment.