summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2009-05-27 22:49:16 +1000
committerJames Turnbull <james@lovedthanlost.net>2009-05-27 22:49:16 +1000
commit3ec3f915306dac13370f64795c399df97fc2d992 (patch)
treec8c409137c5cdccccd1b68c6d14b3ec2602dd1b9
parentf98d49f2d20ed52cd33504c5d0ef97d0edf9107f (diff)
downloadpuppet-3ec3f915306dac13370f64795c399df97fc2d992.tar.gz
puppet-3ec3f915306dac13370f64795c399df97fc2d992.tar.xz
puppet-3ec3f915306dac13370f64795c399df97fc2d992.zip
Fixed #2280 - Detailed exit codes fix
-rw-r--r--CHANGELOG2
-rw-r--r--lib/puppet/application/puppet.rb2
-rw-r--r--spec/unit/application/puppet.rb36
3 files changed, 38 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 99a69c676..9b7406600 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
0.25.0
+ Fixed #2280 - Detailed exit codes fix
+
Fixed #198 - Puppet man pages added
Moved puppetd, puppetmasterd, puppetrun, puppetca from bin to sbin
diff --git a/lib/puppet/application/puppet.rb b/lib/puppet/application/puppet.rb
index ce88a6868..ee848a503 100644
--- a/lib/puppet/application/puppet.rb
+++ b/lib/puppet/application/puppet.rb
@@ -81,7 +81,7 @@ Puppet::Application.new(:puppet) do
transaction = catalog.apply
status = 0
- if not Puppet[:noop] and options[:detailed_exits] then
+ if not Puppet[:noop] and options[:detailed_exitcodes] then
transaction.generate_report
status |= 2 if transaction.report.metrics["changes"][:total] > 0
status |= 4 if transaction.report.metrics["resources"][:failed] > 0
diff --git a/spec/unit/application/puppet.rb b/spec/unit/application/puppet.rb
index 0fbfbe591..9256b00dc 100644
--- a/spec/unit/application/puppet.rb
+++ b/spec/unit/application/puppet.rb
@@ -274,7 +274,7 @@ describe "Puppet" do
it "should generate a report if not noop" do
Puppet.stubs(:[]).with(:noop).returns(false)
- @puppet.options.stubs(:[]).with(:detailed_exits).returns(true)
+ @puppet.options.stubs(:[]).with(:detailed_exitcodes).returns(true)
metrics = stub 'metrics', :[] => { :total => 10, :failed => 0}
report = stub 'report', :metrics => metrics
@transaction.stubs(:report).returns(report)
@@ -284,6 +284,40 @@ describe "Puppet" do
@puppet.main
end
+ describe "with detailed_exitcodes" do
+ before :each do
+ Puppet.stubs(:[]).with(:noop).returns(false)
+ @puppet.options.stubs(:[]).with(:detailed_exitcodes).returns(true)
+ end
+
+ it "should exit with exit code of 2 if changes" do
+ report = stub 'report', :metrics => { "changes" => {:total => 1}, "resources" => {:failed => 0} }
+ @transaction.stubs(:generate_report).returns(report)
+ @transaction.stubs(:report).returns(report)
+ @puppet.expects(:exit).with(2)
+
+ @puppet.main
+ end
+
+ it "should exit with exit code of 4 if failures" do
+ report = stub 'report', :metrics => { "changes" => {:total => 0}, "resources" => {:failed => 1} }
+ @transaction.stubs(:generate_report).returns(report)
+ @transaction.stubs(:report).returns(report)
+ @puppet.expects(:exit).with(4)
+
+ @puppet.main
+ end
+
+ it "should exit with exit code of 6 if changes and failures" do
+ report = stub 'report', :metrics => { "changes" => {:total => 1}, "resources" => {:failed => 1} }
+ @transaction.stubs(:generate_report).returns(report)
+ @transaction.stubs(:report).returns(report)
+ @puppet.expects(:exit).with(6)
+
+ @puppet.main
+ end
+ end
+
end
end