Skip to content

Commit

Permalink
fix: improve error msg when bin is a directory (#3231)
Browse files Browse the repository at this point in the history
rogeriopvl authored and johnjbarton committed Dec 8, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent bb022a7 commit 584dddc
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/launchers/process.js
Original file line number Diff line number Diff line change
@@ -87,6 +87,9 @@ function ProcessLauncher (spawn, tempDir, timer, processKillTimeout) {
if (err.code === 'ENOENT') {
self._retryLimit = -1
errorOutput = `Can not find the binary ${cmd}\n\tPlease set env variable ${self.ENV_CMD}`
} else if (err.code === 'EACCES') {
self._retryLimit = -1
errorOutput = `Permission denied accessing the binary ${cmd}\n\tMaybe it's a directory?`
} else {
errorOutput += err.toString()
}
20 changes: 20 additions & 0 deletions test/unit/launchers/process.spec.js
Original file line number Diff line number Diff line change
@@ -93,6 +93,26 @@ describe('launchers/process.js', () => {
done()
})
})

it('should handle spawn EACCES error and not even retry', (done) => {
ProcessLauncher.call(launcher, mockSpawn, mockTempDir)
RetryLauncher.call(launcher, 2)
launcher._getCommand = () => BROWSER_PATH

const failureSpy = sinon.spy()
emitter.on('browser_process_failure', failureSpy)

launcher.start('http://host:9876/')
mockSpawn._processes[0].emit('error', {code: 'EACCES'})
mockSpawn._processes[0].emit('exit', 1)
mockTempDir.remove.callArg(1)

_.defer(() => {
expect(launcher.state).to.equal(launcher.STATE_FINISHED)
expect(failureSpy).to.have.been.called
done()
})
})
})

// higher level tests with Retry and CaptureTimeout launchers

0 comments on commit 584dddc

Please sign in to comment.