2014-08-12 05:17:19 -04:00
|
|
|
require 'rake/testtask'
|
2014-08-12 05:29:21 -04:00
|
|
|
require 'rubygems/package_task'
|
|
|
|
|
|
|
|
dir = File.dirname(__FILE__)
|
2014-08-12 05:17:19 -04:00
|
|
|
|
|
|
|
def run_without_aborting(*tasks)
|
|
|
|
errors = []
|
|
|
|
|
|
|
|
tasks.each do |task|
|
|
|
|
begin
|
|
|
|
Rake::Task[task].invoke
|
|
|
|
rescue Exception
|
|
|
|
errors << task
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
abort "Errors running #{errors.join(', ')}" if errors.any?
|
|
|
|
end
|
|
|
|
|
|
|
|
task default: :test
|
|
|
|
|
2014-08-12 05:29:21 -04:00
|
|
|
ACTIVEJOB_ADAPTERS = %w(inline delayed_job qu que queue_classic resque sidekiq sneakers sucker_punch backburner)
|
2014-08-19 09:40:45 -04:00
|
|
|
ACTIVEJOB_ADAPTERS -= %w(queue_classic) if defined?(JRUBY_VERSION)
|
2014-08-12 05:17:19 -04:00
|
|
|
|
|
|
|
desc 'Run all adapter tests'
|
|
|
|
task :test do
|
2014-08-12 05:29:21 -04:00
|
|
|
tasks = ACTIVEJOB_ADAPTERS.map{|a| "test_#{a}" }
|
2014-08-12 05:17:19 -04:00
|
|
|
run_without_aborting(*tasks)
|
|
|
|
end
|
|
|
|
|
2014-08-12 05:29:21 -04:00
|
|
|
namespace :test do
|
|
|
|
desc 'Run all adapter tests in isolation'
|
|
|
|
task :isolated do
|
|
|
|
tasks = ACTIVEJOB_ADAPTERS.map{|a| "isolated_test_#{a}" }
|
|
|
|
run_without_aborting(*tasks)
|
|
|
|
end
|
2014-08-18 03:19:41 -04:00
|
|
|
|
|
|
|
desc 'Run all adapter integration tests'
|
|
|
|
task :integration do
|
|
|
|
tasks = ACTIVEJOB_ADAPTERS.map{|a| "integration_test_#{a}" }
|
|
|
|
run_without_aborting(*tasks)
|
|
|
|
end
|
2014-08-12 05:29:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
ACTIVEJOB_ADAPTERS.each do |adapter|
|
|
|
|
namespace :test do
|
|
|
|
Rake::TestTask.new(adapter => "#{adapter}:env") do |t|
|
|
|
|
t.description = ""
|
|
|
|
t.libs << 'test'
|
|
|
|
t.test_files = FileList['test/cases/**/*_test.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :isolated do
|
|
|
|
task adapter => "#{adapter}:env" do
|
|
|
|
Dir.glob("#{dir}/test/cases/**/*_test.rb").all? do |file|
|
|
|
|
sh(Gem.ruby, '-w', "-I#{dir}/lib", "-I#{dir}/test", file)
|
|
|
|
end or raise 'Failures'
|
|
|
|
end
|
|
|
|
end
|
2014-08-18 03:19:41 -04:00
|
|
|
|
|
|
|
namespace :integration do
|
|
|
|
Rake::TestTask.new(adapter => "#{adapter}:env") do |t|
|
|
|
|
t.description = ""
|
|
|
|
t.libs << 'test'
|
|
|
|
t.test_files = FileList['test/integration/**/*_test.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
end
|
2014-08-12 05:17:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
namespace adapter do
|
|
|
|
task test: "test_#{adapter}"
|
2014-08-12 05:29:21 -04:00
|
|
|
task isolated_test: "isolated_test_#{adapter}"
|
|
|
|
|
2014-08-12 05:17:19 -04:00
|
|
|
task(:env) { ENV['AJADAPTER'] = adapter }
|
2014-08-18 03:19:41 -04:00
|
|
|
|
|
|
|
namespace :isolated do
|
|
|
|
task(:env) { ENV['AJADAPTER'] = adapter }
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :integration do
|
|
|
|
task(:env) do
|
|
|
|
ENV['AJADAPTER'] = adapter
|
|
|
|
ENV['AJ_INTEGRATION_TESTS'] = "1"
|
|
|
|
end
|
|
|
|
end
|
2014-08-12 05:17:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-08-12 05:29:21 -04:00
|
|
|
desc "Run #{adapter} tests"
|
|
|
|
task "test_#{adapter}" => ["#{adapter}:env", "test:#{adapter}"]
|
2014-08-12 05:17:19 -04:00
|
|
|
|
2014-08-12 05:29:21 -04:00
|
|
|
desc "Run #{adapter} tests in isolation"
|
2014-08-18 03:19:41 -04:00
|
|
|
task "isolated_test_#{adapter}" => ["#{adapter}:isolated:env", "test:isolated:#{adapter}"]
|
|
|
|
|
|
|
|
desc "Run #{adapter} integration tests"
|
|
|
|
task "integration_test_#{adapter}" => ["#{adapter}:integration:env", "test:integration:#{adapter}"]
|
2014-08-12 05:17:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-08-12 05:29:21 -04:00
|
|
|
spec = eval(File.read('activejob.gemspec'))
|
|
|
|
|
|
|
|
Gem::PackageTask.new(spec) do |p|
|
|
|
|
p.gem_spec = spec
|
|
|
|
end
|
2014-08-12 05:17:19 -04:00
|
|
|
|
2014-08-12 05:29:21 -04:00
|
|
|
desc 'Release to rubygems'
|
|
|
|
task release: :package do
|
|
|
|
require 'rake/gemcutter'
|
|
|
|
Rake::Gemcutter::Tasks.new(spec).define
|
|
|
|
Rake::Task['gem:push'].invoke
|
2014-08-12 05:17:19 -04:00
|
|
|
end
|