Skip to content

Commit

Permalink
fix: Blow up if invalid parser is specified _before_ running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NickTomlin committed Aug 5, 2016
1 parent 914e887 commit 9d1ac98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ const DEFAULT_OPTIONS = {

export default function (options = {}, callback = function noop () {}) {
let parsedOptions = Object.assign(DEFAULT_OPTIONS, options)
let parser = getParser(parsedOptions.parser)
let testAttempt = 1

function handleTestEnd (status, output = '') {
if (status === 0) {
callback(status)
} else {
if (++testAttempt <= parsedOptions.maxAttempts) {
let parser = getParser(parsedOptions.parser)
log('info', `Using ${parser.name} to parse output\n`)
let failedSpecs = parser.parse(output)

Expand Down
14 changes: 14 additions & 0 deletions test/integration/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,18 @@ describe('Protractor Flake Executable', function () {
done()
})
})

it('integration: exits with error if invalid parser is specified', (done) => {
let output = ''
let proc = spawnFlake(['--max-attempts', '3', '--parser', 'foo', '--', configPath('sharded')])
proc.stderr.on('data', (buff) => {
output += buff.toString()
})

proc.on('close', (status) => {
expect(status).to.equal(1)
expect(output).to.contain('Error: Invalid Parser Specified: foo')
done()
})
})
})

0 comments on commit 9d1ac98

Please sign in to comment.