diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2011-02-25 13:19:19 -0800 |
|---|---|---|
| committer | Jesse Wolfe <jes5199@gmail.com> | 2011-02-25 13:19:19 -0800 |
| commit | 1172a4ee50040843e0e4b5eef73183aaf50be855 (patch) | |
| tree | 7afc83986e6ea068dc6fee4ac5c171b63c47019b | |
| parent | 063a55eda926ab77aad856a0948da1cb85d4aa7a (diff) | |
| parent | 23eb77d999acb73021547c5ef86adf609e202605 (diff) | |
| download | puppet-1172a4ee50040843e0e4b5eef73183aaf50be855.tar.gz puppet-1172a4ee50040843e0e4b5eef73183aaf50be855.tar.xz puppet-1172a4ee50040843e0e4b5eef73183aaf50be855.zip | |
Merge branch 'ticket/2.6.next/6322' into 2.6.next
| -rw-r--r-- | lib/puppet/application/agent.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/application/apply.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/application/agent_spec.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/application/apply_spec.rb | 16 |
4 files changed, 20 insertions, 4 deletions
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index 895156f11..3749241f8 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -119,7 +119,7 @@ class Puppet::Application::Agent < Puppet::Application if not report exit(1) - elsif not Puppet[:noop] and options[:detailed_exitcodes] then + elsif options[:detailed_exitcodes] then exit(report.exit_status) else exit(0) diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 8f5aa86d0..cc733e1f5 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -125,7 +125,7 @@ class Puppet::Application::Apply < Puppet::Application configurer = Puppet::Configurer.new report = configurer.run(:skip_plugin_download => true, :catalog => catalog) - exit( Puppet[:noop] ? 0 : options[:detailed_exitcodes] ? report.exit_status : 0 ) + exit( options[:detailed_exitcodes] ? report.exit_status : 0 ) rescue => detail puts detail.backtrace if Puppet[:trace] $stderr.puts detail.message diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb index 9fc7879c9..8f498d4ba 100755 --- a/spec/unit/application/agent_spec.rb +++ b/spec/unit/application/agent_spec.rb @@ -526,11 +526,11 @@ describe Puppet::Application::Agent do @puppetd.onetime end - it "should always exit with 0 if --noop" do + it "should exit with the report's computer exit status, even if --noop is set." do Puppet.stubs(:[]).with(:noop).returns(true) report = stub 'report', :exit_status => 666 @agent.stubs(:run).returns(report) - @puppetd.expects(:exit).with(0) + @puppetd.expects(:exit).with(666) @puppetd.onetime end diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index ceba4a333..d4f39abe0 100755 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -166,6 +166,13 @@ describe Puppet::Application::Apply do @apply.expects(:exit).with(1) @apply.parseonly end + + it "should exit with exit code 1 if error, even if --noop is set" do + Puppet[:noop] = true + @collection.stubs(:perform_initial_import).raises(Puppet::ParseError) + @apply.expects(:exit).with(1) + @apply.parseonly + end end describe "the main command" do @@ -327,6 +334,15 @@ describe Puppet::Application::Apply do @apply.main end + it "should exit with report's computed exit status, even if --noop is set" do + Puppet.stubs(:[]).with(:noop).returns(true) + @apply.options.stubs(:[]).with(:detailed_exitcodes).returns(true) + Puppet::Transaction::Report.any_instance.stubs(:exit_status).returns(666) + @apply.expects(:exit).with(666) + + @apply.main + end + it "should always exit with 0 if option is disabled" do Puppet.stubs(:[]).with(:noop).returns(false) @apply.options.stubs(:[]).with(:detailed_exitcodes).returns(false) |
