diff options
author | Ho-Sheng Hsiao <hosheng.hsiao@gmail.com> | 2012-03-30 15:46:28 -0400 |
---|---|---|
committer | Ho-Sheng Hsiao <hosh@opscode.com> | 2012-05-10 14:43:54 -0400 |
commit | 0f734cef401fd93cd8409e9c834d9300f8026ac0 (patch) | |
tree | 9fc9623c4a784b14f359343626fb7692337f7c00 | |
parent | b0a12cfd37f162eec8c33e63c72e0454629481bf (diff) | |
download | chef-0f734cef401fd93cd8409e9c834d9300f8026ac0.tar.gz |
[CHEF-2994][WINDOWS] Fixed remaining failing tests on windows
-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 417def3aac..16b1946f27 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 7f55da53a9..b320c6ab80 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 00701a6797..74b96eae78 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 |