Skip to content

Instantly share code, notes, and snippets.

@maxlinc
Created June 28, 2013 03:10
Show Gist options
  • Save maxlinc/5882219 to your computer and use it in GitHub Desktop.
Save maxlinc/5882219 to your computer and use it in GitHub Desktop.
Fast acceptance test runner
namespace :module do
desc 'Run acceptance tests for each module'
task :acceptance do
run "vagrant up --no-provision"
run "vagrant sandbox on"
Dir['my_modules/*/tests/*.pp'].each do |test_file|
puts "Running test #{test_file}"
run "MANIFEST_FILE=/etc/puppet/#{test_file} vagrant provision"
run "vagrant sandbox rollback"
end
end
end
def run(cmd)
Bundler.with_clean_env do
sh "cd my_modules && #{cmd}"
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.synced_folder "..", "/etc/puppet"
config.vm.provision :shell, :inline => "puppet apply --modulepath '/etc/puppet/modules:/etc/puppet/my_modules/' #{ENV['MANIFEST_FILE']} --detailed-exitcodes || [ $? -eq 2 ]"
config.vm.box = "ubuntu_precise64"
config.vm.hostname = "module-test.example.com"
config.vm.box_url = "http://f.willianfernandes.com.br/vagrant-boxes/UbuntuServer12.04amd64.box"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment