Sha256: 4e4afff715e68a1eda27a460ff0361e84b23732bf406ecdebe1b91e1969bf94f

Contents?: true

Size: 1.31 KB

Versions: 129

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

def command(cmd)
  Specinfra::Runner.run_command(cmd)
end

shared_examples "IO checks" do
    let (:generator) { "seq 1 #{max}" }
    let (:expected) { (1..max).map { |x| x.to_s }.join("\n") << "\n" }

    it "stdout only" do
        out = command(generator).stdout
        expect(out).to eq expected
    end

    it "stderr only" do
        out = command("#{generator} >&2" ).stderr
        expect(out).to eq expected
    end

    it "stdout then stderr" do
        cmd = command("#{generator}; #{generator} >&2" )
        expect(cmd.stdout).to eq expected
        expect(cmd.stderr).to eq expected
    end

    it "stderr then stdout" do
        cmd = command("#{generator} >&2; #{generator}" )
        expect(cmd.stdout).to eq expected
        expect(cmd.stderr).to eq expected
    end

    it "stdout and stderr" do
        cmd = command("(#{generator} &); #{generator} >&2; sleep 2" )
        expect(cmd.stdout).to eq expected
        expect(cmd.stderr).to eq expected
    end
end

describe "buffer overflow problem" do
    before :all do
        set :backend, :exec
    end

    context "with small output amount" do
        let (:max) { 10 }
        include_examples "IO checks"
    end

    context "with huge output amount" do
        let (:max) { 999999 }
        include_examples "IO checks"
    end
end

Version data entries

129 entries across 129 versions & 1 rubygems

Version Path
specinfra-2.91.0 spec/backend/exec/read_noblock_spec.rb
specinfra-2.90.1 spec/backend/exec/read_noblock_spec.rb
specinfra-2.90.0 spec/backend/exec/read_noblock_spec.rb
specinfra-2.89.0 spec/backend/exec/read_noblock_spec.rb
specinfra-2.88.2 spec/backend/exec/read_noblock_spec.rb
specinfra-2.88.1 spec/backend/exec/read_noblock_spec.rb
specinfra-2.88.0 spec/backend/exec/read_noblock_spec.rb
specinfra-2.87.2 spec/backend/exec/read_noblock_spec.rb
specinfra-2.87.1 spec/backend/exec/read_noblock_spec.rb
specinfra-2.87.0 spec/backend/exec/read_noblock_spec.rb
specinfra-2.86.0 spec/backend/exec/read_noblock_spec.rb
specinfra-2.85.1 spec/backend/exec/read_noblock_spec.rb
specinfra-2.85.0 spec/backend/exec/read_noblock_spec.rb
specinfra-2.84.1 spec/backend/exec/read_noblock_spec.rb
specinfra-2.84.0 spec/backend/exec/read_noblock_spec.rb
specinfra-2.83.4 spec/backend/exec/read_noblock_spec.rb
specinfra-2.83.3 spec/backend/exec/read_noblock_spec.rb
specinfra-2.83.2 spec/backend/exec/read_noblock_spec.rb
specinfra-2.83.1 spec/backend/exec/read_noblock_spec.rb
specinfra-2.83.0 spec/backend/exec/read_noblock_spec.rb