Skip to content

Commit

Permalink
Merge pull request #243 from gemini-testing/dd.fix_worker_sync_config
Browse files Browse the repository at this point in the history
fix sync config in worker
  • Loading branch information
DudaGod authored Mar 16, 2018
2 parents db4056e + 43c33ce commit 606b680
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 45 deletions.
13 changes: 10 additions & 3 deletions lib/worker/hermione-facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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');
Expand Down
93 changes: 60 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 30 additions & 9 deletions test/lib/worker/hermione-facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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));
});
});
});

0 comments on commit 606b680

Please sign in to comment.