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: improve error msg when bin is a directory #3231

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/launchers/process.js
Expand Up @@ -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()
}
Expand Down
20 changes: 20 additions & 0 deletions test/unit/launchers/process.spec.js
Expand Up @@ -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
Expand Down