summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-22 11:53:30 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-22 15:39:06 -0700
commitf77304b703cbaaf5b46b974a0c80b73cece4a2aa (patch)
treedca46a71880832bbf91c6ad99c5264681546ae68 /spec/unit
parent435c826ead5c81c3eb7c47efe9c52e2e77c14666 (diff)
downloadpuppet-f77304b703cbaaf5b46b974a0c80b73cece4a2aa.tar.gz
puppet-f77304b703cbaaf5b46b974a0c80b73cece4a2aa.tar.xz
puppet-f77304b703cbaaf5b46b974a0c80b73cece4a2aa.zip
(#7157) Return a non-zero exit code on face failure.
When a face or action fails we should exit non-zero on the CLI to signal this to our caller. "Fails" is defined as "raises an exception"; we don't treat any return value as a significant failure. Reviewed-By: Jesse Wolf <jesse@puppetlabs.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/application/face_base_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/unit/application/face_base_spec.rb b/spec/unit/application/face_base_spec.rb
index e6e598430..7b3a69f61 100755
--- a/spec/unit/application/face_base_spec.rb
+++ b/spec/unit/application/face_base_spec.rb
@@ -201,6 +201,41 @@ describe Puppet::Application::FaceBase do
end
end
+ describe "error reporting" do
+ before :each do
+ app.stubs(:puts) # don't dump text to screen.
+
+ app.face = Puppet::Face[:basetest, '0.0.1']
+ app.arguments = []
+ end
+
+ it "should exit 0 when the action returns true" do
+ app.action = app.face.get_action :return_true
+ expect { app.main }.to exit_with 0
+ end
+
+ it "should exit 0 when the action returns false" do
+ app.action = app.face.get_action :return_false
+ expect { app.main }.to exit_with 0
+ end
+
+ it "should exit 0 when the action returns nil" do
+ app.action = app.face.get_action :return_nil
+ expect { app.main }.to exit_with 0
+ end
+
+ it "should exit non-0 when the action raises" do
+ app.action = app.face.get_action :return_raise
+ expect { app.main }.not_to exit_with 0
+ end
+
+ it "should exit non-0 when the action does not exist" do
+ app.action = nil
+ app.arguments = ["foo"]
+ expect { app.main }.to exit_with 1
+ end
+ end
+
describe "#render" do
before :each do
app.face = Puppet::Face[:basetest, '0.0.1']