From ba68feab3b19834c124e7e8eb8b037011c8ca128 Mon Sep 17 00:00:00 2001 From: DudaGod Date: Fri, 16 Mar 2018 14:29:01 +0300 Subject: [PATCH 1/2] fix: sync config in worker before running tests --- lib/worker/hermione-facade.js | 13 +++++++--- test/lib/worker/hermione-facade.js | 39 +++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/lib/worker/hermione-facade.js b/lib/worker/hermione-facade.js index 5ccae5ac6..d2d8bb90c 100644 --- a/lib/worker/hermione-facade.js +++ b/lib/worker/hermione-facade.js @@ -21,14 +21,22 @@ module.exports = class HermioneFacade { this.promise = this._init() .then((hermione) => this._hermione = hermione) - .then(() => this._syncConfig()) .then(() => this._hermione.init()); return this.promise; } + syncConfig() { + this.syncConfig = () => this.promise; + + this.promise = this.init() + .then(() => this._syncConfig()); + + return this.promise; + } + runTest(...args) { - return this.init() + return this.syncConfig() .then(() => this._hermione.runTest(...args)); } @@ -59,7 +67,6 @@ module.exports = class HermioneFacade { ipc.on('master.syncConfig', ({config} = {}) => { delete config.system.mochaOpts.grep; // grep affects only master - this._hermione.config.mergeWith(config); debug('config synced'); diff --git a/test/lib/worker/hermione-facade.js b/test/lib/worker/hermione-facade.js index a4fde186b..5b1f8c3df 100644 --- a/test/lib/worker/hermione-facade.js +++ b/test/lib/worker/hermione-facade.js @@ -18,6 +18,7 @@ describe('worker/hermione-facade', () => { // TODO: think about how to make it easier '../utils/ipc': {on: ipc.on.bind(ipc), emit: ipc.emit.bind(ipc)} }); + sandbox.spy(HermioneFacade.prototype, 'syncConfig'); config = makeConfigStub(); @@ -37,19 +38,39 @@ describe('worker/hermione-facade', () => { afterEach(() => sandbox.restore()); - it('should init hermione', () => { - const hermioneFacade = HermioneFacade.create(); + describe('init', () => { + it('should init hermione', () => { + const hermioneFacade = HermioneFacade.create(); - return hermioneFacade.init() - .then(() => assert.calledOnce(hermione.init)); + return hermioneFacade.init() + .then(() => assert.calledOnce(hermione.init)); + }); + + it('should not sync config', () => { + const hermioneFacade = HermioneFacade.create(); + + return hermioneFacade.init() + .then(() => assert.notCalled(HermioneFacade.prototype.syncConfig)); + }); }); - it('should init hermione before running tests', () => { - hermione.runTest = sandbox.spy().named('hermioneRunTest'); + describe('runTest', () => { + beforeEach(() => { + hermione.runTest = sandbox.spy().named('hermioneRunTest'); + }); - const hermioneFacade = HermioneFacade.create(); + it('should init hermione before running test', () => { + const hermioneFacade = HermioneFacade.create(); - return hermioneFacade.runTest() - .then(() => assert.callOrder(hermione.init, hermione.runTest)); + return hermioneFacade.runTest() + .then(() => assert.callOrder(hermione.init, hermione.runTest)); + }); + + it('should sync config before running test', () => { + const hermioneFacade = HermioneFacade.create(); + + return hermioneFacade.runTest() + .then(() => assert.callOrder(HermioneFacade.prototype.syncConfig, hermione.runTest)); + }); }); }); From 43c33cef43b0b3576542b75ffd27356e700203a6 Mon Sep 17 00:00:00 2001 From: DudaGod Date: Fri, 16 Mar 2018 14:33:08 +0300 Subject: [PATCH 2/2] chore: update package-lock --- package-lock.json | 93 ++++++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8a3feaf19..d3e454f3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,18 @@ { "name": "hermione", - "version": "0.63.0", + "version": "0.65.0", "lockfileVersion": 1, "requires": true, "dependencies": { + "@sinonjs/formatio": { + "version": "2.0.0", + "resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz", + "integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==", + "dev": true, + "requires": { + "samsam": "1.3.0" + } + }, "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", @@ -447,7 +456,7 @@ "JSONStream": "1.3.2", "safe-buffer": "5.1.1", "through2": "2.0.3", - "umd": "3.0.2" + "umd": "3.0.3" } }, "browser-resolve": { @@ -2290,7 +2299,7 @@ }, "onetime": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, @@ -2599,15 +2608,6 @@ "mime-types": "2.1.18" } }, - "formatio": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.2.0.tgz", - "integrity": "sha1-87IWfZBoxGmKjVH092CjmlTYGOs=", - "dev": true, - "requires": { - "samsam": "1.3.0" - } - }, "franc": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/franc/-/franc-2.0.0.tgz", @@ -3824,6 +3824,12 @@ "verror": "1.10.0" } }, + "just-extend": { + "version": "1.1.27", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", + "dev": true + }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -3924,6 +3930,12 @@ "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, "lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", @@ -3949,9 +3961,9 @@ } }, "lolex": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.6.0.tgz", - "integrity": "sha1-OpoCg0UqR9dDnnJzG54H1zhuSfY=", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -4291,18 +4303,25 @@ "resolved": "https://registry.npmjs.org/nan/-/nan-2.9.2.tgz", "integrity": "sha512-ltW65co7f3PQWBDbqVvaU1WtFJUsNW7sWWm4HINhbMQIyVyzIeyZ8toX5TC5eeooE6piZoaEh4cZkueSKG3KYw==" }, - "native-promise-only": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", - "integrity": "sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE=", - "dev": true - }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "nise": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.3.1.tgz", + "integrity": "sha512-kIH3X5YCj1vvj/32zDa9KNgzvfZd51ItGbiaCbtYhpnsCedLo0tIkb9zl169a41ATzF4z7kwMLz35XXDypma3g==", + "dev": true, + "requires": { + "@sinonjs/formatio": "2.0.0", + "just-extend": "1.1.27", + "lolex": "2.3.2", + "path-to-regexp": "1.7.0", + "text-encoding": "0.6.4" + } + }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -5282,18 +5301,17 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, "sinon": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-2.4.1.tgz", - "integrity": "sha512-vFTrO9Wt0ECffDYIPSP/E5bBugt0UjcBQOfQUMh66xzkyPEnhl/vM2LRZi2ajuTdkH07sA6DzrM6KvdvGIH8xw==", + "version": "4.4.6", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.4.6.tgz", + "integrity": "sha512-bzQag30yErCC4lJPv+C2HcmD1+3ula4JQNePZldKcagi0Exq6XDfcC2yqXVfEwtfTIq1rYGujrUIZbwHPpKjog==", "dev": true, "requires": { + "@sinonjs/formatio": "2.0.0", "diff": "3.5.0", - "formatio": "1.2.0", - "lolex": "1.6.0", - "native-promise-only": "0.8.1", - "path-to-regexp": "1.7.0", - "samsam": "1.3.0", - "text-encoding": "0.6.4", + "lodash.get": "4.4.2", + "lolex": "2.3.2", + "nise": "1.3.1", + "supports-color": "5.3.0", "type-detect": "4.0.8" }, "dependencies": { @@ -5302,6 +5320,15 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true + }, + "supports-color": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", + "dev": true, + "requires": { + "has-flag": "3.0.0" + } } } }, @@ -5910,9 +5937,9 @@ } }, "umd": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.2.tgz", - "integrity": "sha512-pmfBilQAzgIWo6aRuTx771b2MaCDkWzd1Z7qdByIk85Rq6bnzr0nKsQjkYshdTwOeGbSg8E3qORIZsmICwr/OA==" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", + "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==" }, "underscore": { "version": "1.8.3",