diff options
author | Ho-Sheng Hsiao <hosheng.hsiao@gmail.com> | 2012-03-26 18:38:20 -0400 |
---|---|---|
committer | Ho-Sheng Hsiao <hosheng.hsiao@gmail.com> | 2012-03-26 18:38:20 -0400 |
commit | 66f49acbc0eb92f9ece895f85b64020390926d95 (patch) | |
tree | e3d408c9d8297684c52fae37add539960f5f96e6 | |
parent | 310b1e3d5f99a5d1295718ef064e988984768bc1 (diff) | |
download | chef-66f49acbc0eb92f9ece895f85b64020390926d95.tar.gz |
[CHEF-2994][RSPEC] ShellOut#run_command when subprocess closes prematurely with input should raise broken pipe exception
-rw-r--r-- | spec/mixlib/shellout/shellout_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/mixlib/shellout/shellout_spec.rb b/spec/mixlib/shellout/shellout_spec.rb index 62ac3e5684..5a8e9c2de0 100644 --- a/spec/mixlib/shellout/shellout_spec.rb +++ b/spec/mixlib/shellout/shellout_spec.rb @@ -790,6 +790,19 @@ describe Mixlib::ShellOut do end end + context 'when subprocess closes prematurely' do + context 'with input data' do + let(:ruby_code) { 'bad_ruby { [ } ]' } + let(:options) { { :input => input } } + let(:input) { [ 'f' * 20_000, 'u' * 20_000, 'f' * 20_000, 'u' * 20_000 ].join(LINE_ENDING) } + + # Should the exception be handled? + it 'should raise error' do + lambda { executed_cmd }.should raise_error(Errno::EPIPE) + end + end + end + context 'when subprocess writes, pauses, then continues writing' do subject { stdout } let(:ruby_code) { %q{puts "before"; sleep 0.5; puts "after"} } |