summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/puppet/type/tidy.rb9
-rwxr-xr-xspec/unit/type/tidy.rb8
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb
index e37da5ef8..b4df4a9a2 100755
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -44,7 +44,14 @@ module Puppet
end
def insync?(is)
- if File.lstat(resource[:path]).ftype == "directory" and ! @resource[:rmdirs]
+ begin
+ stat = File.lstat(resource[:path])
+ rescue Errno::ENOENT
+ info "Tidy target does not exist; ignoring"
+ return true
+ end
+
+ if stat.ftype == "directory" and ! @resource[:rmdirs]
self.debug "Not tidying directories"
return true
end
diff --git a/spec/unit/type/tidy.rb b/spec/unit/type/tidy.rb
index ee820d4aa..9bcae86d7 100755
--- a/spec/unit/type/tidy.rb
+++ b/spec/unit/type/tidy.rb
@@ -6,6 +6,14 @@ tidy = Puppet::Type.type(:tidy)
describe tidy do
after { tidy.clear }
+
+ it "should be in sync if the targeted file does not exist" do
+ File.expects(:lstat).with("/tmp/foonesslaters").raises Errno::ENOENT
+ @tidy = tidy.create :path => "/tmp/foonesslaters", :age => "100d"
+
+ @tidy.property(:ensure).must be_insync({})
+ end
+
[:ensure, :age, :size].each do |property|
it "should have a %s property" % property do
tidy.attrclass(property).ancestors.should be_include(Puppet::Property)