diff options
-rw-r--r-- | lib/mixlib/shellout/exceptions.rb | 1 | ||||
-rw-r--r-- | lib/mixlib/shellout/windows.rb | 2 | ||||
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 29 |
3 files changed, 19 insertions, 13 deletions
diff --git a/lib/mixlib/shellout/exceptions.rb b/lib/mixlib/shellout/exceptions.rb index 417def3..16b1946 100644 --- a/lib/mixlib/shellout/exceptions.rb +++ b/lib/mixlib/shellout/exceptions.rb @@ -5,4 +5,3 @@ module Mixlib class InvalidCommandOption < RuntimeError; end end end - diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb index 7f55da5..b320c6a 100644 --- a/lib/mixlib/shellout/windows.rb +++ b/lib/mixlib/shellout/windows.rb @@ -90,7 +90,7 @@ module Mixlib when WAIT_TIMEOUT # Kill the process if (Time.now - start_wait) > timeout - raise Mixlib::ShellOut::Exceptions::CommandTimeout, "command timed out:\n#{format_for_exception}" + raise Mixlib::ShellOut::CommandTimeout, "command timed out:\n#{format_for_exception}" end consume_output(open_streams, stdout_read, stderr_read) diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index 00701a6..74b96ea 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -759,12 +759,15 @@ describe Mixlib::ShellOut do # over again and generate lots of garbage, which will not be collected # since we have to turn GC off to avoid segv. context 'with subprocess that closes STDOUT before closing STDERR' do - subject { unclosed_pipes } let(:ruby_code) { %q{STDOUT.puts "F" * 4096; STDOUT.close; sleep 0.1; STDERR.puts "foo"; STDERR.close; sleep 0.1; exit} } let(:unclosed_pipes) { executed_cmd.send(:open_pipes) } it 'should not hang' do - should be_empty + stdout.should_not be_empty + end + + it 'should close all pipes', :unix_only => true do + unclosed_pipes.should be_empty end end @@ -828,7 +831,7 @@ describe Mixlib::ShellOut do end end - context 'when subprocess closes prematurely' do + context 'when subprocess closes prematurely', :unix_only => true do context 'with input data' do let(:ruby_code) { 'bad_ruby { [ } ]' } let(:options) { { :input => input } } @@ -874,18 +877,22 @@ describe Mixlib::ShellOut do context 'when execution fails' do let(:cmd) { "fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu" } - it "should recover the error message" do - lambda { executed_cmd }.should raise_error(Errno::ENOENT) - end - - context 'with input', :unix_only => true do - let(:options) { {:input => input } } - let(:input) { "Random input #{rand(1000000)}" } - + context 'when running under Unix', :unix_only => true do it "should recover the error message" do lambda { executed_cmd }.should raise_error(Errno::ENOENT) end + + context 'with input' do + let(:options) { {:input => input } } + let(:input) { "Random input #{rand(1000000)}" } + + it "should recover the error message" do + lambda { executed_cmd }.should raise_error(Errno::ENOENT) + end + end end + + pending 'when running under Windows', :windows_only => true end context 'without input data', :unix_only => true do |