summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/metatype/evaluation.rb24
-rwxr-xr-xtest/ral/manager/type.rb22
2 files changed, 28 insertions, 18 deletions
diff --git a/lib/puppet/metatype/evaluation.rb b/lib/puppet/metatype/evaluation.rb
index 746375d49..58f316e2c 100644
--- a/lib/puppet/metatype/evaluation.rb
+++ b/lib/puppet/metatype/evaluation.rb
@@ -12,7 +12,9 @@ class Puppet::Type
end
@evalcount += 1
- changes = []
+ if p = self.provider and p.respond_to?(:prefetch)
+ p.prefetch
+ end
# this only operates on properties, not properties + children
# it's important that we call retrieve() on the type instance,
@@ -20,22 +22,7 @@ class Puppet::Type
# the method, like pfile does
self.retrieve
- # properties() is a private method, returning an ordered list
- unless self.class.depthfirst?
- changes += propertychanges()
- end
-
- changes << @children.collect { |child|
- ch = child.evaluate
- child.cache(:checked, Time.now)
- ch
- }
-
- if self.class.depthfirst?
- changes += propertychanges()
- end
-
- changes.flatten!
+ changes = propertychanges().flatten
# now record how many changes we've resulted in
if changes.length > 0
@@ -46,7 +33,8 @@ class Puppet::Type
return changes.flatten
end
- # By default, try flushing the provider.
+ # Flush the provider, if it supports it. This is called by the
+ # transaction.
def flush
if self.provider and self.provider.respond_to?(:flush)
self.provider.flush
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index c8d4104a8..139db76e2 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -3,6 +3,7 @@
$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppettest'
+require 'mocha'
class TestType < Test::Unit::TestCase
include PuppetTest
@@ -810,6 +811,27 @@ end
exec = mk.call(6, :parent => comp)
assert_equal("//Good[bad]/Exec[exec6]", exec.path)
end
+
+ def test_evaluate
+ faketype = Puppet::Type.newtype(:faketype) do
+ newparam(:name) {}
+ end
+ cleanup { Puppet::Type.rmtype(:faketype) }
+ faketype.provide(:fake) do
+ def prefetch
+ end
+ end
+
+ obj = faketype.create :name => "yayness", :provider => :fake
+ assert(obj, "did not create object")
+
+ obj.provider.expects(:prefetch)
+ obj.expects(:retrieve)
+ obj.expects(:propertychanges).returns([])
+ obj.expects(:cache)
+
+ obj.evaluate
+ end
end
# $Id$