summaryrefslogtreecommitdiffstats
path: root/test/lib/puppettest/support/utils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/puppettest/support/utils.rb')
-rw-r--r--test/lib/puppettest/support/utils.rb45
1 files changed, 25 insertions, 20 deletions
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