Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runner): Do not persist grep option across runs #3121

Merged
merged 1 commit into from
Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) => {
johnjbarton marked this conversation as resolved.
Show resolved Hide resolved
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