1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[misc] Extracts testing Rake tasks to class

This commit is contained in:
Paul Thornthwaite 2012-11-12 12:31:00 +00:00
parent 88865d1203
commit f20a5f8dd2
2 changed files with 49 additions and 33 deletions

View file

@ -49,6 +49,9 @@ end
GEM_NAME = "#{name}"
task :default => :test
require "fog/rake/test_task"
Fog::Rake::TestTask.new
namespace :test do
task :dynect do
[false].each do |mock|
@ -58,39 +61,6 @@ namespace :test do
end
end
task :test do
Rake::Task[:mock_tests].invoke
end
def tests(mocked)
Formatador.display_line
start = Time.now.to_i
threads = []
Thread.main[:results] = []
Fog.providers.each do |key, value|
threads << Thread.new do
Thread.main[:results] << {
:provider => value,
:success => sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
}
end
end
threads.each do |thread|
thread.join
end
Formatador.display_table(Thread.main[:results].sort {|x,y| x[:provider] <=> y[:provider]})
Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
Formatador.display_line
end
task :mock_tests do
tests(true)
end
task :real_tests do
tests(false)
end
task :nuke do
Fog.providers.each do |provider|
next if ['Vmfusion'].include?(provider)

46
lib/fog/rake/test_task.rb Normal file
View file

@ -0,0 +1,46 @@
require "rake"
require "rake/tasklib"
module Fog
module Rake
class TestTask < ::Rake::TaskLib
def initialize
desc "Run the mocked tests"
task :test do
Rake::Task[:mock_tests].invoke
end
task :mock_tests do
tests(true)
end
task :real_tests do
tests(false)
end
end
def tests(mocked)
Formatador.display_line
start = Time.now.to_i
threads = []
Thread.main[:results] = []
Fog.providers.each do |key, value|
threads << Thread.new do
Thread.main[:results] << {
:provider => value,
:success => sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
}
end
end
threads.each do |thread|
thread.join
end
Formatador.display_table(Thread.main[:results].sort {|x,y| x[:provider] <=> y[:provider]})
Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
Formatador.display_line
end
end
end
end