mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-02 04:50:06 -05:00
@@ -4,6 +4,7 @@ const cp = require('child_process')
|
||||
const os = require('os')
|
||||
const tty = require('tty')
|
||||
const path = require('path')
|
||||
const EE = require('events')
|
||||
|
||||
const state = require(`${lib}/tasks/state`)
|
||||
const xvfb = require(`${lib}/exec/xvfb`)
|
||||
@@ -35,6 +36,7 @@ describe('lib/exec/spawn', function () {
|
||||
on: sinon.stub().returns(undefined),
|
||||
},
|
||||
}
|
||||
sinon.stub(process, 'stdin').value(new EE)
|
||||
sinon.stub(cp, 'spawn').returns(this.spawnedProcess)
|
||||
sinon.stub(xvfb, 'start').resolves()
|
||||
sinon.stub(xvfb, 'stop').resolves()
|
||||
@@ -313,5 +315,39 @@ describe('lib/exec/spawn', function () {
|
||||
expect(process.stderr.write).not.to.be.calledWith(buf1)
|
||||
})
|
||||
})
|
||||
|
||||
it('catches process.stdin errors and returns when code=EPIPE', function () {
|
||||
this.spawnedProcess.on.withArgs('close').yieldsAsync(0)
|
||||
|
||||
return spawn.start()
|
||||
.then(() => {
|
||||
let called = false
|
||||
|
||||
const fn = () => {
|
||||
called = true
|
||||
const err = new Error()
|
||||
err.code = 'EPIPE'
|
||||
return process.stdin.emit('error', err)
|
||||
}
|
||||
|
||||
expect(fn).not.to.throw()
|
||||
expect(called).to.be.true
|
||||
})
|
||||
})
|
||||
|
||||
it('throws process.stdin errors code!=EPIPE', function () {
|
||||
this.spawnedProcess.on.withArgs('close').yieldsAsync(0)
|
||||
|
||||
return spawn.start()
|
||||
.then(() => {
|
||||
const fn = () => {
|
||||
const err = new Error('wattttt')
|
||||
err.code = 'FAILWHALE'
|
||||
return process.stdin.emit('error', err)
|
||||
}
|
||||
|
||||
expect(fn).to.throw(/wattttt/)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user