Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions spec/support/nonblocking_examples.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
shared_examples_for "a command that does not block" do
it "does not block if the command output a lot on stderr" do
cmd = Terrapin::CommandLine.new(
"ruby",
"-e '$stdout.puts %{hello}; $stderr.puts %{goodbye}*10_000'",
:swallow_stderr => false
)
Timeout.timeout(5) do
cmd.run
shared_examples_for "a command that does not block" do |opts = {}|
if opts[:supports_stderr]
it "does not block if the command output a lot on stderr" do
Timeout.timeout(5) do
output = subject.call("ruby -e '$stdout.puts %{hello}; $stderr.puts %{goodbye}*10_000'")

expect(output.output).to eq "hello\n"
expect(output.error_output).to eq "#{"goodbye" * 10_000}\n"
end
end
expect(cmd.command_output).to eq "hello\n"
expect(cmd.command_error_output).to eq "#{"goodbye" * 10_000}\n"
end

it 'does not block if the command outputs a lot of data' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe Terrapin::CommandLine::BackticksRunner do
if Terrapin::CommandLine::BackticksRunner.supported?
it_behaves_like 'a command that does not block'
it_behaves_like 'a command that does not block', { :supports_stderr => false }

it 'runs the command given and captures the output in an Output' do
output = subject.call("echo hello")
Expand Down
2 changes: 1 addition & 1 deletion spec/terrapin/command_line/runners/popen_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe Terrapin::CommandLine::PopenRunner do
if Terrapin::CommandLine::PopenRunner.supported?
it_behaves_like 'a command that does not block'
it_behaves_like 'a command that does not block', { :supports_stderr => false }

it 'runs the command given and captures the output in an Output' do
output = subject.call("echo hello")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe Terrapin::CommandLine::ProcessRunner do
if Terrapin::CommandLine::ProcessRunner.supported?
it_behaves_like "a command that does not block"
it_behaves_like "a command that does not block", { :supports_stderr => true }

it 'runs the command given and captures the output' do
output = subject.call("echo hello")
Expand Down