Skip to content

Commit

Permalink
fix(runner): Do not persist grep option across runs (#3121)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvalkeejarvi authored and johnjbarton committed Sep 5, 2018
1 parent 301b2d6 commit c91cb81
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 235 deletions.
12 changes: 12 additions & 0 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,15 @@ exports.defer = () => {
promise: promise
}
}

exports.saveOriginalArgs = (config) => {
if (config && config.client && config.client.args) {
config.client.originalArgs = _.cloneDeep(config.client.args)
}
}

exports.restoreOriginalArgs = (config) => {
if (config && config.client && config.client.originalArgs) {
config.client.args = _.cloneDeep(config.client.originalArgs)
}
}
2 changes: 2 additions & 0 deletions lib/middleware/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var json = require('body-parser').json()
function createRunnerMiddleware (emitter, fileList, capturedBrowsers, reporter, executor,
/* config.protocol */ protocol, /* config.hostname */ hostname, /* config.port */
port, /* config.urlRoot */ urlRoot, config) {
helper.saveOriginalArgs(config)
return function (request, response, next) {
if (request.url !== '/__run__' && request.url !== urlRoot + 'run') {
return next()
Expand Down Expand Up @@ -48,6 +49,7 @@ function createRunnerMiddleware (emitter, fileList, capturedBrowsers, reporter,
})
})

helper.restoreOriginalArgs(config)
if (_.isEmpty(data.args)) {
log.debug('Ignoring empty client.args from run command')
} else if ((_.isArray(data.args) && _.isArray(config.client.args)) ||
Expand Down
28 changes: 28 additions & 0 deletions test/unit/helper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,32 @@ describe('helper', () => {
helper.mmPatternWeight('{**,*}').should.be.deep.equal([2, 1, 0, 0, 0, 0])
})
})

describe('saveOriginalArgs', () => {
it('should clone config.client.args', () => {
var config = {
client: {
args: ['--somearg']
}
}
expect(config.client.originalArgs).to.not.exist
helper.saveOriginalArgs(config)
config.client.args.should.be.deep.equal(['--somearg'])
config.client.originalArgs.should.be.deep.equal(['--somearg'])
})
})

describe('restoreOriginalArgs', () => {
it('should restore config.client.originalArgs', () => {
var config = {
client: {
args: ['--somearg'],
originalArgs: []
}
}
helper.restoreOriginalArgs(config)
config.client.args.should.be.deep.equal([])
config.client.originalArgs.should.be.deep.equal([])
})
})
})
Loading

0 comments on commit c91cb81

Please sign in to comment.