From 4d9f76ad2653542e53a8020be9eeadb8f354837c Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Wed, 21 Oct 2009 22:10:02 -0700 Subject: Fix for #2745 fakedata tests not working The old fakedata test facility was not playing nicely with the spec tests; although it looped through all the files failures in any example file after the first were being ignored because of the way fakedataparse was interacting with the before blocks. Signed-off-by: Markus Roberts --- test/lib/puppettest/support/utils.rb | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'test/lib') diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb index 7491095de..655308d3b 100644 --- a/test/lib/puppettest/support/utils.rb +++ b/test/lib/puppettest/support/utils.rb @@ -91,22 +91,6 @@ module PuppetTest::Support::Utils return trans end - # If there are any fake data files, retrieve them - def fakedata(dir) - ary = [basedir, "test"] - ary += dir.split("/") - dir = File.join(ary) - - unless FileTest.exists?(dir) - raise Puppet::DevError, "No fakedata dir %s" % dir - end - files = Dir.entries(dir).reject { |f| f =~ /^\./ }.collect { |f| - File.join(dir, f) - } - - return files - end - def fakefile(name) ary = [PuppetTest.basedir, "test"] ary += name.split("/") @@ -169,4 +153,12 @@ end module PuppetTest include PuppetTest::Support::Utils + + def self.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 + end -- cgit