summaryrefslogtreecommitdiffstats
path: root/test/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-10 22:13:10 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-10 22:13:10 +0000
commit201aa023dd279d2d968a97732db11a1933665562 (patch)
treed96aea85ef130b698025771ba3bedcae56f800b4 /test/puppet
parent0507486ad35189c557903d0c78bd1bbd7d43b967 (diff)
downloadpuppet-201aa023dd279d2d968a97732db11a1933665562.tar.gz
puppet-201aa023dd279d2d968a97732db11a1933665562.tar.xz
puppet-201aa023dd279d2d968a97732db11a1933665562.zip
Adding simple benchmarking, and using it in a few of the more obvious places. Also, fixed a bug in Scope#gennode.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1098 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/puppet')
-rwxr-xr-xtest/puppet/utiltest.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/puppet/utiltest.rb b/test/puppet/utiltest.rb
index 34278716f..e33d73c65 100755
--- a/test/puppet/utiltest.rb
+++ b/test/puppet/utiltest.rb
@@ -157,6 +157,30 @@ class TestPuppetUtil < Test::Unit::TestCase
assert_equal(oldmask, File.umask, "Umask was not reset")
end
+ def test_benchmark
+ path = tempfile()
+ str = "yayness"
+ File.open(path, "w") do |f| f.print "yayness" end
+
+ # First test it with the normal args
+ assert_nothing_raised do
+ val = Puppet::Util.benchmark(:notice, "Read file") do
+ File.read(path)
+ end
+
+ assert_equal(str, val)
+ end
+
+ # Now test it with a passed object
+ assert_nothing_raised do
+ val = Puppet::Util.benchmark(Puppet, :notice, "Read file") do
+ File.read(path)
+ end
+
+ assert_equal(str, val)
+ end
+ end
+
unless Process.uid == 0
$stderr.puts "Run as root to perform Utility tests"
def test_nothing