diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-09-13 23:00:35 -0700 |
---|---|---|
committer | Jesse Wolfe <jes5199@gmail.com> | 2010-09-13 23:00:35 -0700 |
commit | 9e72ccd8ff087d0cf4a1396401e3843311b4e6d4 (patch) | |
tree | 19f55c6cb37bfd9bc39f0bf9060643ac61005415 /test | |
parent | 1d93c4dd86181eb2663dd8df2e84719c2e1ffcdf (diff) | |
parent | efa834aaec596b0d5e7b314a53e6b258ce44728c (diff) | |
download | puppet-9e72ccd8ff087d0cf4a1396401e3843311b4e6d4.tar.gz puppet-9e72ccd8ff087d0cf4a1396401e3843311b4e6d4.tar.xz puppet-9e72ccd8ff087d0cf4a1396401e3843311b4e6d4.zip |
Merge commit '2.6.1rc4' into next
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/mocha_standalone.rb | 2 | ||||
-rwxr-xr-x | test/lib/puppettest.rb | 22 | ||||
-rw-r--r-- | test/lib/puppettest/fakes.rb | 2 | ||||
-rw-r--r-- | test/lib/puppettest/support/assertions.rb | 2 | ||||
-rw-r--r-- | test/lib/puppettest/support/utils.rb | 45 |
5 files changed, 27 insertions, 46 deletions
diff --git a/test/lib/mocha_standalone.rb b/test/lib/mocha_standalone.rb deleted file mode 100644 index ce605811a..000000000 --- a/test/lib/mocha_standalone.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'mocha/standalone' -require 'mocha/object' diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 294d0ef8d..0b3a89a72 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -6,17 +6,6 @@ mainlib = File.expand_path(File.join(File.dirname(__FILE__), '../../lib')) $LOAD_PATH.unshift(mainlib) unless $LOAD_PATH.include?(mainlib) require 'puppet' - -# include any gems in vendor/gems -Dir["#{mainlib}/../vendor/gems/**"].each do |path| - libpath = File.join(path, "lib") - if File.directory?(libpath) - $LOAD_PATH.unshift(libpath) - else - $LOAD_PATH.unshift(path) - end -end - require 'mocha' # Only load the test/unit class if we're not in the spec directory. @@ -31,16 +20,7 @@ if ARGV.include?("-d") $console = true end -# Some monkey-patching to allow us to test private methods. -class Class - def publicize_methods(*methods) - saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods - - self.class_eval { public(*saved_private_instance_methods) } - yield - self.class_eval { private(*saved_private_instance_methods) } - end -end +require File.expand_path(File.join(File.dirname(__FILE__), '../../spec/monkey_patches/publicize_methods')) module PuppetTest # These need to be here for when rspec tests use these diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb index aaa711004..712332b74 100644 --- a/test/lib/puppettest/fakes.rb +++ b/test/lib/puppettest/fakes.rb @@ -1,4 +1,4 @@ -require 'puppettest' +require File.expand_path(File.join(File.dirname(__FILE__), '../../../lib/puppet/util')) module PuppetTest # A baseclass for the faketypes. diff --git a/test/lib/puppettest/support/assertions.rb b/test/lib/puppettest/support/assertions.rb index 7f326b119..31fa3f1da 100644 --- a/test/lib/puppettest/support/assertions.rb +++ b/test/lib/puppettest/support/assertions.rb @@ -1,8 +1,6 @@ -require 'puppettest' require 'puppettest/support/utils' require 'fileutils' - module PuppetTest include PuppetTest::Support::Utils def assert_logged(level, regex, msg = nil) diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb index edc81d3d6..e022f123c 100644 --- a/test/lib/puppettest/support/utils.rb +++ b/test/lib/puppettest/support/utils.rb @@ -1,5 +1,3 @@ -require 'puppettest' - module PuppetTest::Support end module PuppetTest::Support::Utils @@ -7,6 +5,30 @@ module PuppetTest::Support::Utils Puppet.warning "#{type}: #{ObjectSpace.each_object(type) { |o| }}" end + def basedir(*list) + unless defined? @@basedir + Dir.chdir(File.dirname(__FILE__)) do + @@basedir = File.dirname(File.dirname(File.dirname(File.dirname(Dir.getwd)))) + end + end + if list.empty? + @@basedir + else + File.join(@@basedir, *list) + end + end + + def fakedata(dir,pat='*') + glob = "#{basedir}/test/#{dir}/#{pat}" + files = Dir.glob(glob,File::FNM_PATHNAME) + raise Puppet::DevError, "No fakedata matching #{glob}" if files.empty? + files + end + + def datadir(*list) + File.join(basedir, "test", "data", *list) + end + # # TODO: I think this method needs to be renamed to something a little more # explanatory. @@ -38,10 +60,6 @@ module PuppetTest::Support::Utils config end - # stop any services that might be hanging around - def stopservices - end - # TODO: rewrite this to use the 'etc' module. # Define a variable that contains the name of my user. @@ -84,7 +102,7 @@ module PuppetTest::Support::Utils end def fakefile(name) - ary = [PuppetTest.basedir, "test"] + ary = [basedir, "test"] ary += name.split("/") file = File.join(ary) raise Puppet::DevError, "No fakedata file #{file}" unless FileTest.exists?(file) @@ -140,16 +158,3 @@ module PuppetTest::Support::Utils config end end - -module PuppetTest - include PuppetTest::Support::Utils - - def fakedata(dir,pat='*') - glob = "#{basedir}/test/#{dir}/#{pat}" - files = Dir.glob(glob,File::FNM_PATHNAME) - raise Puppet::DevError, "No fakedata matching #{glob}" if files.empty? - files - end - module_function :fakedata - -end |