[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Jesse Wolfe jes5199 at gmail.com
Thu Mar 17 10:47:56 UTC 2011


The following commit has been merged in the upstream branch:
commit 23eb77d999acb73021547c5ef86adf609e202605
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Fri Feb 25 11:45:38 2011 -0800

    (#6322) --noop should not suppress error codes
    
    The noop option has been suppressing exit statuses. This is
    counterintuitive, as per discussion at http://projects.puppetlabs.com/issues/6322
    
    This patch causes noop runs to return the same exit codes as real runs.
    
    Reviewed-By: Daniel Pittman <daniel at puppetlabs.com>

diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index 895156f..3749241 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 8f5aa86..cc733e1 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 9fc7879..8f498d4 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 ceba4a3..d4f39ab 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)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list