diff options
Diffstat (limited to 'test/lib')
| -rwxr-xr-x | test/lib/puppettest.rb | 8 | ||||
| -rw-r--r-- | test/lib/puppettest/fileparsing.rb | 22 | ||||
| -rw-r--r-- | test/lib/puppettest/support/utils.rb | 9 |
3 files changed, 19 insertions, 20 deletions
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index eb50077b8..7bd2f107d 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -79,10 +79,6 @@ module PuppetTest end end - def cleanup(&block) - @@cleaners << block - end - def datadir(*list) File.join(basedir, "test", "data", *list) end @@ -101,6 +97,10 @@ module PuppetTest module_function :basedir, :datadir, :exampledir + def cleanup(&block) + @@cleaners << block + end + # Rails clobbers RUBYLIB, thanks def libsetup curlibs = ENV["RUBYLIB"].split(":") diff --git a/test/lib/puppettest/fileparsing.rb b/test/lib/puppettest/fileparsing.rb index 9f7716ab2..11de00220 100644 --- a/test/lib/puppettest/fileparsing.rb +++ b/test/lib/puppettest/fileparsing.rb @@ -2,20 +2,11 @@ module PuppetTest::FileParsing # Run an isomorphism test on our parsing process. def fakedataparse(*files) files.each do |file| - oldtarget = @provider.default_target - cleanup do - @provider.default_target = oldtarget - end - @provider.default_target = file + @provider.stubs(:default_target).returns(file) - assert_nothing_raised("failed to fetch %s" % file) { - @provider.prefetch - } + @provider.prefetch - text = nil - assert_nothing_raised("failed to generate %s" % file) do - text = @provider.to_file(@provider.target_records(file)) - end + text = @provider.to_file(@provider.target_records(file)) text.gsub!(/^# HEADER.+\n/, '') yield if block_given? @@ -23,8 +14,11 @@ module PuppetTest::FileParsing oldlines = File.readlines(file) newlines = text.chomp.split "\n" oldlines.zip(newlines).each do |old, new| - assert_equal(old.chomp.gsub(/\s+/, ''), new.gsub(/\s+/, ''), - "Lines are not equal in %s" % file) + if self.is_a?(Test::Unit::TestCase) + assert_equal(old.chomp.gsub(/\s+/, ''), new.gsub(/\s+/, ''), "File was not written back out correctly") + else + new.gsub(/\s+/, '').should == old.chomp.gsub(/\s+/, '') + end end end end diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb index ee29a8875..d9bd6b2b6 100644 --- a/test/lib/puppettest/support/utils.rb +++ b/test/lib/puppettest/support/utils.rb @@ -1,6 +1,8 @@ require 'puppettest' -module PuppetTest +module PuppetTest::Support +end +module PuppetTest::Support::Utils def gcdebug(type) Puppet.warning "%s: %s" % [type, ObjectSpace.each_object(type) { |o| }] end @@ -112,7 +114,7 @@ module PuppetTest end def fakefile(name) - ary = [basedir, "test"] + ary = [PuppetTest.basedir, "test"] ary += name.split("/") file = File.join(ary) unless FileTest.exists?(file) @@ -171,3 +173,6 @@ module PuppetTest end end +module PuppetTest + include PuppetTest::Support::Utils +end |
