From cacd122c67706b9bcf1eca3b1a727ea953dceb64 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Tue, 21 May 2019 21:03:59 +0630 Subject: [PATCH] Fix mixed use of both XVFB and Xvfb to all be Xvfb (#4262) --- cli/__snapshots__/errors_spec.js | 6 +++--- cli/__snapshots__/verify_spec.js | 4 ++-- cli/lib/errors.js | 8 ++++---- cli/lib/exec/spawn.js | 6 +++--- cli/lib/exec/xvfb.js | 8 ++++---- cli/lib/tasks/verify.js | 4 ++-- cli/lib/util.js | 4 ++-- cli/test/lib/exec/spawn_spec.js | 2 +- cli/test/lib/exec/xvfb_spec.js | 5 ++++- cli/test/lib/tasks/verify_spec.js | 8 ++++---- 10 files changed, 29 insertions(+), 26 deletions(-) diff --git a/cli/__snapshots__/errors_spec.js b/cli/__snapshots__/errors_spec.js index c3891648fdb6..f8333d37acba 100644 --- a/cli/__snapshots__/errors_spec.js +++ b/cli/__snapshots__/errors_spec.js @@ -10,9 +10,9 @@ Cypress Version: 1.2.3 ` exports['errors .errors.formErrorText returns fully formed text message 1'] = ` -Your system is missing the dependency: XVFB +Your system is missing the dependency: Xvfb -Install XVFB and run Cypress again. +Install Xvfb and run Cypress again. Read our documentation on dependencies for more information: @@ -47,7 +47,7 @@ exports['errors individual has the following errors 1'] = [ exports['invalid display error'] = ` Cypress verification failed. -Cypress failed to start after spawning a new XVFB server. +Cypress failed to start after spawning a new Xvfb server. The error logs we received were: diff --git a/cli/__snapshots__/verify_spec.js b/cli/__snapshots__/verify_spec.js index ded2295d591c..9b7e43f9257a 100644 --- a/cli/__snapshots__/verify_spec.js +++ b/cli/__snapshots__/verify_spec.js @@ -364,7 +364,7 @@ It looks like this is your first time using Cypress: 1.2.3 ✖ Verifying Cypress can run /cache/Cypress/1.2.3/Cypress.app STRIPPED -Error: XVFB exited with a non zero exit code. +Error: Xvfb exited with a non zero exit code. There was a problem spawning Xvfb. @@ -384,7 +384,7 @@ Cypress Version: 1.2.3 exports['tried to verify twice, on the first try got the DISPLAY error'] = ` Cypress verification failed. -Cypress failed to start after spawning a new XVFB server. +Cypress failed to start after spawning a new Xvfb server. The error logs we received were: diff --git a/cli/lib/errors.js b/cli/lib/errors.js index 4e7e5a95ed69..3727c7014ef3 100644 --- a/cli/lib/errors.js +++ b/cli/lib/errors.js @@ -75,7 +75,7 @@ const notInstalledCI = (executable) => { } const nonZeroExitCodeXvfb = { - description: 'XVFB exited with a non zero exit code.', + description: 'Xvfb exited with a non zero exit code.', solution: stripIndent` There was a problem spawning Xvfb. @@ -84,9 +84,9 @@ const nonZeroExitCodeXvfb = { } const missingXvfb = { - description: 'Your system is missing the dependency: XVFB', + description: 'Your system is missing the dependency: Xvfb', solution: stripIndent` - Install XVFB and run Cypress again. + Install Xvfb and run Cypress again. Read our documentation on dependencies for more information: @@ -113,7 +113,7 @@ const invalidSmokeTestDisplayError = { description: 'Cypress verification failed.', solution (msg) { return stripIndent` - Cypress failed to start after spawning a new XVFB server. + Cypress failed to start after spawning a new Xvfb server. The error logs we received were: diff --git a/cli/lib/exec/spawn.js b/cli/lib/exec/spawn.js index 7451cf628507..2dea8d0edaf0 100644 --- a/cli/lib/exec/spawn.js +++ b/cli/lib/exec/spawn.js @@ -51,7 +51,7 @@ function getStdio (needsXvfb) { if (needsStderrPiped(needsXvfb)) { // returning pipe here so we can massage stderr // and remove garbage from Xlib and libuv - // due to starting the XVFB process on linux + // due to starting the Xvfb process on linux return ['inherit', 'inherit', 'pipe'] } @@ -67,7 +67,7 @@ module.exports = { executable = path.resolve(util.getEnv('CYPRESS_RUN_BINARY')) } - debug('needs to start own XVFB?', needsXvfb) + debug('needs to start own Xvfb?', needsXvfb) // always push cwd into the args args = [].concat(args, '--cwd', process.cwd()) @@ -227,7 +227,7 @@ module.exports = { // if we are on linux and there's already a DISPLAY // set, then we may need to rerun cypress after - // spawning our own XVFB server + // spawning our own Xvfb server const linuxWithDisplayEnv = util.isPossibleLinuxWithIncorrectDisplay() return userFriendlySpawn(linuxWithDisplayEnv) diff --git a/cli/lib/exec/xvfb.js b/cli/lib/exec/xvfb.js index 6e750bc27cba..c5e9ce4656f9 100644 --- a/cli/lib/exec/xvfb.js +++ b/cli/lib/exec/xvfb.js @@ -22,7 +22,7 @@ module.exports = { _xvfb: xvfb, // expose for testing start () { - debug('Starting XVFB') + debug('Starting Xvfb') return xvfb.startAsync() .return(null) @@ -37,7 +37,7 @@ module.exports = { }, stop () { - debug('Stopping XVFB') + debug('Stopping Xvfb') return xvfb.stopAsync() .return(null) @@ -57,7 +57,7 @@ module.exports = { const message = stripIndent` DISPLAY environment variable is set to ${process.env.DISPLAY} on Linux Assuming this DISPLAY points at working X11 server, - Cypress will not spawn own XVFB + Cypress will not spawn own Xvfb NOTE: if the X11 server is NOT working, Cypress will exit without explanation, see ${issueUrl} @@ -71,7 +71,7 @@ module.exports = { } debug('undefined DISPLAY environment variable') - debug('Cypress will spawn its own XVFB') + debug('Cypress will spawn its own Xvfb') return true }, diff --git a/cli/lib/tasks/verify.js b/cli/lib/tasks/verify.js index 4052c22fccdc..bf9590ccadaa 100644 --- a/cli/lib/tasks/verify.js +++ b/cli/lib/tasks/verify.js @@ -68,7 +68,7 @@ const runSmokeTest = (binaryDir, options) => { const needsXvfb = xvfb.isNeeded() - debug('needs XVFB?', needsXvfb) + debug('needs Xvfb?', needsXvfb) /** * Spawn Cypress running smoke test to check if all operating system @@ -138,7 +138,7 @@ const runSmokeTest = (binaryDir, options) => { // if we are on linux and there's already a DISPLAY // set, then we may need to rerun cypress after - // spawning our own XVFB server + // spawning our own Xvfb server const linuxWithDisplayEnv = util.isPossibleLinuxWithIncorrectDisplay() return userFriendlySpawn(linuxWithDisplayEnv) diff --git a/cli/lib/util.js b/cli/lib/util.js index 4296b39587c8..369f29c03175 100644 --- a/cli/lib/util.js +++ b/cli/lib/util.js @@ -36,7 +36,7 @@ function normalizeModuleOptions (options = {}) { /** * Returns true if the platform is Linux. We do a lot of different - * stuff on Linux (like XVFB) and it helps to has readable code + * stuff on Linux (like Xvfb) and it helps to has readable code */ const isLinux = () => { return os.platform() === 'linux' @@ -58,7 +58,7 @@ const isPossibleLinuxWithIncorrectDisplay = () => { } const logBrokenGtkDisplayWarning = () => { - debug('Cypress exited due to a broken gtk display because of a potential invalid DISPLAY env... retrying after starting XVFB') + debug('Cypress exited due to a broken gtk display because of a potential invalid DISPLAY env... retrying after starting Xvfb') // if we get this error, we are on Linux and DISPLAY is set logger.warn(stripIndent` diff --git a/cli/test/lib/exec/spawn_spec.js b/cli/test/lib/exec/spawn_spec.js index 9cfeb8068945..569c3a51614f 100644 --- a/cli/test/lib/exec/spawn_spec.js +++ b/cli/test/lib/exec/spawn_spec.js @@ -153,7 +153,7 @@ describe('lib/exec/spawn', function () { expect(xvfb.start).to.have.been.calledOnce expect(xvfb.stop).to.have.been.calledOnce expect(cp.spawn).to.have.been.calledTwice - // second code should be 0 after successfully running with XVFB + // second code should be 0 after successfully running with Xvfb expect(code).to.equal(0) }) }) diff --git a/cli/test/lib/exec/xvfb_spec.js b/cli/test/lib/exec/xvfb_spec.js index b25014ba95ca..55db48b0f5dd 100644 --- a/cli/test/lib/exec/xvfb_spec.js +++ b/cli/test/lib/exec/xvfb_spec.js @@ -33,11 +33,13 @@ describe('lib/exec/xvfb', function () { context('#start', function () { it('passes', function () { sinon.stub(xvfb._xvfb, 'startAsync').resolves() + return xvfb.start() }) it('fails with error message', function () { const message = 'nope' + sinon.stub(xvfb._xvfb, 'startAsync').rejects(new Error(message)) return xvfb.start() @@ -51,6 +53,7 @@ describe('lib/exec/xvfb', function () { it('fails when xvfb exited with non zero exit code', function () { const e = new Error('something bad happened') + e.nonZeroExitCode = true sinon.stub(xvfb._xvfb, 'startAsync').rejects(e) @@ -62,7 +65,7 @@ describe('lib/exec/xvfb', function () { .catch((err) => { expect(err.known).to.be.true expect(err.message).to.include('something bad happened') - expect(err.message).to.include('XVFB exited with a non zero exit code.') + expect(err.message).to.include('Xvfb exited with a non zero exit code.') }) }) }) diff --git a/cli/test/lib/tasks/verify_spec.js b/cli/test/lib/tasks/verify_spec.js index 8df629664f74..e8935d7bbf07 100644 --- a/cli/test/lib/tasks/verify_spec.js +++ b/cli/test/lib/tasks/verify_spec.js @@ -285,7 +285,7 @@ context('lib/tasks/verify', () => { }) }) - describe('smoke test retries on bad display with our XVFB', () => { + describe('smoke test retries on bad display with our Xvfb', () => { let restore beforeEach(() => { @@ -307,7 +307,7 @@ context('lib/tasks/verify', () => { restore() }) - it('successfully retries with our XVFB on Linux', () => { + it('successfully retries with our Xvfb on Linux', () => { // initially we think the user has everything set xvfb.isNeeded.returns(false) sinon.stub(util, 'isPossibleLinuxWithIncorrectDisplay').returns(true) @@ -340,7 +340,7 @@ context('lib/tasks/verify', () => { }) }) - it('fails on both retries with our XVFB on Linux', () => { + it('fails on both retries with our Xvfb on Linux', () => { // initially we think the user has everything set xvfb.isNeeded.returns(false) @@ -378,7 +378,7 @@ context('lib/tasks/verify', () => { }) .catch((e) => { expect(util.exec).to.have.been.calledTwice - // second time around we should have called XVFB + // second time around we should have called Xvfb expect(xvfb.start).to.have.been.calledOnce expect(xvfb.stop).to.have.been.calledOnce