From 584dddce0d43c7de33a68e161933167f5a4ca209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Vicente?= Date: Sat, 8 Dec 2018 16:15:12 +0000 Subject: [PATCH] fix: improve error msg when bin is a directory (#3231) --- lib/launchers/process.js | 3 +++ test/unit/launchers/process.spec.js | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/launchers/process.js b/lib/launchers/process.js index 079fb089c..3734bed5c 100644 --- a/lib/launchers/process.js +++ b/lib/launchers/process.js @@ -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() } diff --git a/test/unit/launchers/process.spec.js b/test/unit/launchers/process.spec.js index 1cd9f0791..f8a4e58ef 100644 --- a/test/unit/launchers/process.spec.js +++ b/test/unit/launchers/process.spec.js @@ -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