Skip to content

Commit

Permalink
Fix mixed use of both XVFB and Xvfb to all be Xvfb (#4262)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-shehane authored and flotwig committed May 21, 2019
1 parent 031ae70 commit cacd122
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 26 deletions.
6 changes: 3 additions & 3 deletions cli/__snapshots__/errors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions cli/__snapshots__/verify_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions cli/lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions cli/lib/exec/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}

Expand All @@ -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())
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions cli/lib/exec/xvfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
_xvfb: xvfb, // expose for testing

start () {
debug('Starting XVFB')
debug('Starting Xvfb')

return xvfb.startAsync()
.return(null)
Expand All @@ -37,7 +37,7 @@ module.exports = {
},

stop () {
debug('Stopping XVFB')
debug('Stopping Xvfb')

return xvfb.stopAsync()
.return(null)
Expand All @@ -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}
Expand All @@ -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
},
Expand Down
4 changes: 2 additions & 2 deletions cli/lib/tasks/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion cli/test/lib/exec/spawn_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
Expand Down
5 changes: 4 additions & 1 deletion cli/test/lib/exec/xvfb_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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.')
})
})
})
Expand Down
8 changes: 4 additions & 4 deletions cli/test/lib/tasks/verify_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit cacd122

Please sign in to comment.