summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorgan Haskel <morgan@puppetlabs.com>2014-05-16 18:23:33 -0400
committerMorgan Haskel <morgan@puppetlabs.com>2014-05-16 18:23:33 -0400
commit4021245ebb54878c691d50efe3f9ce712734e4b6 (patch)
treec90946d658b055f8a565416f3e8d9190c2607bee
parentb30acce599e25e803ba333217d3b0d49d1815169 (diff)
parent79c4a4e6e9638aa4b5f3e7366ada7c3ddbafb8a3 (diff)
downloadpuppet-vcsrepo-4021245ebb54878c691d50efe3f9ce712734e4b6.tar.gz
puppet-vcsrepo-4021245ebb54878c691d50efe3f9ce712734e4b6.tar.bz2
Merge pull request #140 from cyberious/RakeTask
Add rake tasks to test both beaker and beaker-rspec in one go
-rwxr-xr-x[-rw-r--r--]Rakefile57
1 files changed, 57 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index cd3d379..3ccf664 100644..100755
--- a/Rakefile
+++ b/Rakefile
@@ -1 +1,58 @@
require 'puppetlabs_spec_helper/rake_tasks'
+require 'rake'
+
+task 'beaker:test',[:host,:type] => :set_beaker_variables do |t,args|
+
+ Rake::Task['beaker-rspec:test'].invoke(args)
+
+ if File.exists?('./acceptance')
+ Dir.chdir('./acceptance')
+ exec(build_beaker_command args)
+ Dir.chdir('../')
+ else
+ puts "No acceptance directory found, not running beaker tests"
+ end
+
+end
+
+desc "Run beaker rspec tasks against pe"
+RSpec::Core::RakeTask.new('beaker-rspec:test',[:host,:type]=>:set_beaker_variables) do |t,args|
+ t.pattern = 'spec/acceptance'
+ t.rspec_opts = '--color'
+ t.verbose = true
+end
+
+desc "Run beaker and beaker-rspec tasks"
+task 'beaker:test:pe',:host do |t,args|
+ args.with_defaults(:type=> 'pe')
+ Rake::Task['beaker:test'].invoke(args[:host],args[:type])
+end
+
+task 'beaker:test:git',:host do |t,args|
+ args.with_defaults({:type=> 'git'})
+ Rake::Task['beaker:test'].invoke(args[:host],args[:type])
+end
+
+task :set_beaker_variables do |t,args|
+ puts 'Setting environment variables for testing'
+ if args[:host]
+ ENV['BEAKER_set'] = args[:host]
+ puts "Host to test #{ENV['BEAKER_set']}"
+ end
+ ENV['BEAKER_IS_PE'] = args[:type] == 'pe'? "true": "false"
+end
+
+def build_beaker_command(args)
+ cmd = ["beaker"]
+ cmd << "--type #{args[:type]}" unless !args[:type]
+ if File.exists?("./.beaker-#{args[:type]}.cfg")
+ cmd << "--options-file ./.beaker-#{args[:type]}.cfg"
+ end
+ if File.exists?("config/#{args[:host]}.cfg")
+ cmd << "--hosts config/#{args[:host]}.cfg"
+ end
+ if File.exists?("./tests")
+ cmd << "--tests ./tests"
+ end
+ cmd.join(" ")
+end