Skip to content

Commit

Permalink
Remove preload options in TestWorker
Browse files Browse the repository at this point in the history
This doesn’t serve any purpose. We call `runTest` in workers right after we were calling these preload methods which implicitly called the the preload methods themselves.
  • Loading branch information
cpojer committed Nov 7, 2015
1 parent 39b7264 commit 93287f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 53 deletions.
30 changes: 0 additions & 30 deletions src/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,36 +206,6 @@ class TestRunner {
});
}

/**
* For use by external users of TestRunner as a means of optimization.
*
* Imagine the following scenario executing in a child worker process:
*
* var runner = new TestRunner(config, {
* moduleLoaderResourceMap: serializedResourceMap
* });
* someOtherAyncProcess.then(function() {
* runner.runTestsParallel();
* });
*
* Here we wouldn't start deserializing the resource map (passed to us from
* the parent) until runner.runTestsParallel() is called. At the time of this
* writing, resource map deserialization is slow and a bottleneck on running
* the first test in a child.
*
* So this API gives scenarios such as the one above an optimization path to
* potentially start deserializing the resource map while we wait on the
* someOtherAsyncProcess to resolve (rather that doing it after it's
* resolved).
*/
preloadResourceMap() {
this._getModuleLoaderResourceMap().then(null, promiseDone);
}

preloadConfigDependencies() {
this._loadConfigDependencies();
}

/**
* Run the given single test file path.
* This just contains logic for running a single test given it's file path.
Expand Down
25 changes: 2 additions & 23 deletions src/TestWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
'use strict';

// Make sure uncaught errors are logged before we exit.
// Could be transient errors to do with loading and serializing the resouce
// map.
process.on('uncaughtException', (err) => {
process.on('uncaughtException', err => {
console.error(err.stack);
process.exit(1);
});
Expand All @@ -19,30 +17,11 @@ const TestRunner = require('./TestRunner');

let testRunner;

module.exports = function testWorker(data, callback) {
module.exports = (data, callback) => {
if (!testRunner) {
testRunner = new TestRunner(data.config, {
useCachedModuleLoaderResourceMap: true,
});

// Start require()ing config dependencies now.
//
// Config dependencies are entries in the config that are require()d (in
// order to be pluggable) such as 'moduleLoader' or
// 'testEnvironment'.
testRunner.preloadConfigDependencies();

// Start deserializing the resource map to get a potential head-start on
// that work before the first "run-test" message comes in.
//
// This is just a perf optimization -- and it is only an optimization
// some of the time (when the there is any significant idle time between
// this first initialization message and the first "run-rest" message).
//
// It is also only an optimization so long as deserialization of the
// resource map is a bottleneck (which is the case at the time of this
// writing).
testRunner.preloadResourceMap();
}

try {
Expand Down

0 comments on commit 93287f2

Please sign in to comment.