From 1b06d9e9d9d78032568b3b0fbcb50b0e7d2a9a82 Mon Sep 17 00:00:00 2001 From: cpojer Date: Fri, 13 Nov 2015 11:34:20 -0800 Subject: [PATCH] =?UTF-8?q?Freeze=20the=20config=20object=20in=20the=20tes?= =?UTF-8?q?t=20runner=20and=20don=E2=80=99t=20mutate=20it=20any=20longer.?= =?UTF-8?q?=20Remove=20object-assign.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 - src/TestRunner.js | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 14956b07904a..2129622a74b0 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/TestRunner.js b/src/TestRunner.js index 3b278d0d1d8a..bc068981d920 100644 --- a/src/TestRunner.js +++ b/src/TestRunner.js @@ -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'); @@ -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; @@ -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) { @@ -183,10 +182,7 @@ class TestRunner { * @return {Promise} 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);