1 # let Emacs know it's -*- ruby -*-
3 require 'rake/testtask'
5 $stderr.puts "You must have 'rake' installed to use this file"
14 $exclusions = %W(lib data)
15 $test_library_paths = %W(lib ../lib)
17 $: << File.join(Dir.getwd, "lib")
19 require 'rake/puppet_testtask'
21 filemap = Hash.new { |hash, key| hash[key] = [] }
25 # First collect the entire file list.
27 # Get rid of the leading ./
28 f = f.sub(/^\.\//, '')
30 file = File.basename(f)
33 # Prune . directories and excluded dirs
34 if (file =~ /^\./ and f != ".") or $exclusions.include?(File.basename(file))
41 # If we're a ruby script, then add it to the list of files for that dir
44 # Add it to all of the parent dirs, not just our own
45 parts = File.split(dir)
49 parts.each_with_index { |part, i|
50 path = File.join(parts[0..i])
56 desc "Run the full test suite"
57 Rake::PuppetTestTask.new :test do |t|
58 t.libs << $test_library_paths
60 # Add every file as a test file to run
61 t.test_files = allfiles
65 task :default => :test
67 # Now create a task for every directory
68 filemap.each do |dir, files|
69 ns = dir.gsub "/", ":"
71 # First create a separate task for each file in the namespace.
74 Rake::PuppetTestTask.new File.basename(file, '.rb').to_sym do |t|
75 t.libs << $test_library_paths + ['..']
76 t.test_files = [ file ]
82 # Then create a task that matches the directory itself.
83 Rake::PuppetTestTask.new dir do |t|
84 t.libs << $test_library_paths
86 t.test_files = ENV["TESTFILES"].split(/\s+/)
88 t.test_files = files.sort
93 # And alias it with a slash on the end
94 task(dir + "/" => dir)