Beispiel #1
0
    it('does not write to process.stderr when from xlib or libudev', function () {
      const buf1 = Buffer.from('Xlib: something foo')
      const buf2 = Buffer.from('libudev something bar')
      const buf3 = Buffer.from('asdf')

      this.spawnedProcess.stderr.on
      .withArgs('data')
      .onFirstCall()
      .yields(buf1)
      .onSecondCall()
      .yields(buf2)
      .onThirdCall()
      .yields(buf3)

      this.spawnedProcess.on.withArgs('close').yieldsAsync(0)

      sinon.stub(process.stderr, 'write').withArgs(buf3)
      os.platform.returns('linux')
      xvfb.isNeeded.returns(true)

      return spawn.start()
      .then(() => {
        expect(process.stderr.write).not.to.be.calledWith(buf1)
        expect(process.stderr.write).not.to.be.calledWith(buf2)
      })
    })
Beispiel #2
0
    it('starts xvfb when needed', function () {
      xvfb.isNeeded.returns(true)

      this.spawnedProcess.on.withArgs('close').yieldsAsync(0)

      return spawn.start('--foo')
      .then(() => {
        expect(xvfb.start).to.be.calledOnce
      })
    })
Beispiel #3
0
    it('inherits when on linux and xvfb isnt needed', function () {
      this.spawnedProcess.on.withArgs('close').yieldsAsync(0)
      os.platform.returns('linux')
      xvfb.isNeeded.returns(false)

      return spawn.start()
      .then(() => {
        expect(cp.spawn.firstCall.args[2].stdio).to.deep.eq('inherit')
      })
    })
Beispiel #4
0
    it('pipes when on win32', function () {
      this.spawnedProcess.on.withArgs('close').yieldsAsync(0)
      os.platform.returns('win32')
      xvfb.isNeeded.returns(false)

      return spawn.start()
      .then(() => {
        expect(cp.spawn.firstCall.args[2].stdio).to.deep.eq('pipe')
      })
    })
Beispiel #5
0
    it('uses [inherit, inherit, pipe] on darwin', function () {
      this.spawnedProcess.on.withArgs('close').yieldsAsync(0)

      xvfb.isNeeded.returns(false)
      os.platform.returns('darwin')

      return spawn.start()
      .then(() => {
        expect(cp.spawn.firstCall.args[2].stdio).to.deep.eq([
          'inherit', 'inherit', 'pipe',
        ])
      })
    })