Skip to content

Commit

Permalink
Freeze the config object in the test runner and don’t mutate it any l…
Browse files Browse the repository at this point in the history
…onger. Remove object-assign.
  • Loading branch information
cpojer committed Nov 16, 2015
1 parent 422ab88 commit 1b06d9e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -13,7 +13,6 @@
"json-stable-stringify": "^1.0.0",
"lodash.template": "^3.6.2",
"node-haste": "https://github.com/facebook/node-haste.git#5e7a8768611c1912c2428833b25e0b6f61af2a35",
"object-assign": "^4.0.1",
"optimist": "^0.6.1",
"resolve": "^1.1.6",
"sane": "^1.2.0",
Expand Down
10 changes: 3 additions & 7 deletions src/TestRunner.js
Expand Up @@ -10,7 +10,6 @@
const fs = require('graceful-fs');
const os = require('os');
const path = require('path');
const assign = require('object-assign');
const utils = require('./lib/utils');
const workerFarm = require('worker-farm');
const Console = require('./Console');
Expand Down Expand Up @@ -70,7 +69,7 @@ function optionPathToRegex(p) {
class TestRunner {

constructor(config, options) {
this._config = config;
this._config = Object.freeze(config);
this._configDeps = null;
// Maximum memory usage if `logHeapUsage` is enabled.
this._maxMemoryUsage = 0;
Expand All @@ -93,7 +92,7 @@ class TestRunner {
// optimally schedule bigger test runs.
this._testPerformanceCache = null;

this._opts = assign({}, DEFAULT_OPTIONS, options);
this._opts = Object.assign({}, DEFAULT_OPTIONS, options);
}

_constructModuleLoader(environment, customCfg) {
Expand Down Expand Up @@ -183,10 +182,7 @@ class TestRunner {
* @return {Promise<Object>} Results of the test
*/
runTest(testFilePath) {
// Shallow copying lets us adjust the config object locally without
// worrying about the external consequences of changing the config object
// for needs that are local to this particular function call
const config = assign({}, this._config);
const config = this._config;
const configDeps = this._loadConfigDependencies();

const env = new configDeps.testEnvironment(config);
Expand Down

0 comments on commit 1b06d9e

Please sign in to comment.