From 1f41c35c6c081c2f673d713588220e78d8c7c1b0 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 28 Jan 2007 20:43:22 +0000 Subject: Fixing #454. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2105 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/provider/service/base.rb | 2 +- test/providers/service/base.rb | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb index 9099fc730..c615c30c0 100755 --- a/lib/puppet/provider/service/base.rb +++ b/lib/puppet/provider/service/base.rb @@ -116,7 +116,7 @@ Puppet::Type.type(:service).provide :base do begin output = execute(command, fof) rescue Puppet::ExecutionFailure => detail - warning "Could not %s %s: %s" % [type, @model.ref, detail] + @model.fail "Could not %s %s: %s" % [type, @model.ref, detail] end return output diff --git a/test/providers/service/base.rb b/test/providers/service/base.rb index 0de6c806b..38f2df5e6 100755 --- a/test/providers/service/base.rb +++ b/test/providers/service/base.rb @@ -47,6 +47,29 @@ class TestBaseServiceProvider < Test::Unit::TestCase assert_equal(:stopped, provider.status, "status was not returned correctly") end end + + # Testing #454 + def test_that_failures_propagate + nope = "/no/such/command" + service = Puppet::Type.type(:service).create( + :name => "yaytest", :provider => :base, + :start => nope, + :status => nope, + :stop => nope, + :restart => nope + ) + + provider = service.provider + assert(provider, "did not get base provider") + + # We can't fail well when status is messed up, because we depend on the return code + # of the command for data. + %w{start stop restart}.each do |command| + assert_raise(Puppet::Error, "did not throw error when %s failed" % command) do + provider.send(command) + end + end + end end # $Id$ \ No newline at end of file -- cgit