diff options
author | John Keiser <jkeiser@opscode.com> | 2014-05-17 22:03:31 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-05-17 22:03:31 -0700 |
commit | ede39a9532b56f24a77efe34086d0e8e13082cc2 (patch) | |
tree | 99cd2a07fc5e5d0ad4d220792de2d33b50eecfd2 /spec/unit/chef_fs | |
parent | b198db2ddf1664cd32389f13ad6284b66d80e9cb (diff) | |
download | chef-ede39a9532b56f24a77efe34086d0e8e13082cc2.tar.gz |
Add :stop_on_exception to stop consuming input on exception
Diffstat (limited to 'spec/unit/chef_fs')
-rw-r--r-- | spec/unit/chef_fs/parallelizer.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index 971949251c..7823c307f9 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -101,6 +101,20 @@ describe Chef::ChefFS::Parallelizer do elapsed_time.should < 0.4 processed.should == 3 end + + it "Exceptions with :stop_on_exception are raised after all processing is done" do + processed = 0 + parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x| + raise 'hi' if x == 'x' + sleep(x) + processed += 1 + x + end + expect { parallelized.to_a }.to raise_error 'hi' + processed.should <= 5 + processed.should >= 2 + end + end context "With :ordered => true (ordered output)" do @@ -154,6 +168,19 @@ describe Chef::ChefFS::Parallelizer do elapsed_time.should < 0.55 processed.should == 3 end + + it "Exceptions with :stop_on_exception are raised after all processing is done" do + processed = 0 + parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :stop_on_exception => true) do |x| + raise 'hi' if x == 'x' + sleep(x) + processed += 1 + x + end + expect { parallelized.to_a }.to raise_error 'hi' + processed.should <= 5 + processed.should >= 2 + end end end |