Skip to content

Instantly share code, notes, and snippets.

@jitran
Last active August 29, 2015 14:08
Show Gist options
  • Save jitran/e729f2a89750f691050f to your computer and use it in GitHub Desktop.
Save jitran/e729f2a89750f691050f to your computer and use it in GitHub Desktop.
Rakefile for running spec tests for puppet modules
# Run the following tasks inside your puppet directory
# run unit tests
rake spec:unit
# run the default system tests
rake spec:system
# run the system tests for node1
rake spec:system[node1]
require 'rake'
require 'rspec/core/rake_task'
require 'yaml'
namespace :spec do
desc 'Run unit tests'
task :unit do
FileList["modules/*/Rakefile"].each do |project|
dir = project.pathmap("%d")
sh "cd #{dir}; rake spec:unit"
end
puts "Unit tests complete"
end
desc 'Run system tests'
task :system, [:node] do |t, args|
properties = YAML.load_file("tests.yml")
node = 'default'
if !args[:node].nil?
node = args[:node]
end
modules = properties[node]
if !modules.nil? && modules.any?
modules.sort.each do |project|
if !Dir.glob("modules/#{project}/spec/system/**/*_spec_system.rb").empty?
sh "cd modules/#{project}; rake spec:system"
end
end
end
puts "System tests complete"
end
end
# Define all the system tests for each node
default:
- 'network'
- 'firewall'
node1:
- 'network'
- 'java'
node2:
- 'network'
- 'python'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment