2014-08-12 05:17:19 -04:00
|
|
|
require 'rake/testtask'
|
2014-08-12 05:29:21 -04:00
|
|
|
require 'rubygems/package_task'
|
|
|
|
|
2014-12-30 10:53:42 -05:00
|
|
|
ACTIVEJOB_ADAPTERS = %w(inline delayed_job qu que queue_classic resque sidekiq sneakers sucker_punch backburner test)
|
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
|
|
|
|
2014-09-14 04:21:55 -04:00
|
|
|
task default: :test
|
|
|
|
task test: 'test:default'
|
2014-08-12 05:17:19 -04:00
|
|
|
|
2014-08-12 05:29:21 -04:00
|
|
|
namespace :test do
|
2014-09-14 04:21:55 -04:00
|
|
|
desc 'Run all adapter tests'
|
|
|
|
task :default do
|
|
|
|
run_without_aborting ACTIVEJOB_ADAPTERS.map { |a| "test:#{a}" }
|
|
|
|
end
|
|
|
|
|
2014-08-12 05:29:21 -04:00
|
|
|
desc 'Run all adapter tests in isolation'
|
|
|
|
task :isolated do
|
2014-09-14 04:21:55 -04:00
|
|
|
run_without_aborting ACTIVEJOB_ADAPTERS.map { |a| "test:isolated:#{a}" }
|
2014-08-12 05:29:21 -04:00
|
|
|
end
|
2014-08-18 03:19:41 -04:00
|
|
|
|
2014-09-14 04:21:55 -04:00
|
|
|
desc 'Run integration tests for all adapters'
|
2014-08-18 03:19:41 -04:00
|
|
|
task :integration do
|
2015-01-01 22:09:10 -05:00
|
|
|
run_without_aborting (ACTIVEJOB_ADAPTERS - ['test']).map { |a| "test:integration:#{a}" }
|
2014-09-14 04:21:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
task 'env:integration' do
|
|
|
|
ENV['AJ_INTEGRATION_TESTS'] = "1"
|
2014-08-18 03:19:41 -04:00
|
|
|
end
|
2014-08-12 05:29:21 -04:00
|
|
|
|
2014-09-14 04:21:55 -04:00
|
|
|
ACTIVEJOB_ADAPTERS.each do |adapter|
|
2015-02-22 10:11:21 -05:00
|
|
|
task("env:#{adapter}") { ENV['AJ_ADAPTER'] = adapter }
|
2014-08-12 05:29:21 -04:00
|
|
|
|
2014-09-14 04:21:55 -04:00
|
|
|
Rake::TestTask.new(adapter => "test:env:#{adapter}") do |t|
|
|
|
|
t.description = "Run adapter tests for #{adapter}"
|
2014-08-12 05:29:21 -04:00
|
|
|
t.libs << 'test'
|
|
|
|
t.test_files = FileList['test/cases/**/*_test.rb']
|
|
|
|
t.verbose = true
|
2015-05-03 17:01:10 -04:00
|
|
|
t.warning = false
|
2014-09-27 10:37:44 -04:00
|
|
|
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
|
2014-08-12 05:29:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
namespace :isolated do
|
2014-09-14 04:21:55 -04:00
|
|
|
task adapter => "test:env:#{adapter}" do
|
|
|
|
dir = File.dirname(__FILE__)
|
2014-08-12 05:29:21 -04:00
|
|
|
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
|
2014-09-14 04:21:55 -04:00
|
|
|
Rake::TestTask.new(adapter => ["test:env:#{adapter}", 'test:env:integration']) do |t|
|
|
|
|
t.description = "Run integration tests for #{adapter}"
|
2014-08-18 03:19:41 -04:00
|
|
|
t.libs << 'test'
|
|
|
|
t.test_files = FileList['test/integration/**/*_test.rb']
|
|
|
|
t.verbose = true
|
2015-05-03 17:01:10 -04:00
|
|
|
t.warning = false
|
2014-09-27 10:37:44 -04:00
|
|
|
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
|
2014-08-18 03:19:41 -04:00
|
|
|
end
|
|
|
|
end
|
2014-08-12 05:17:19 -04:00
|
|
|
end
|
2014-09-14 04:21:55 -04:00
|
|
|
end
|
2014-08-12 05:17:19 -04:00
|
|
|
|
2014-09-14 04:21:55 -04:00
|
|
|
def run_without_aborting(tasks)
|
|
|
|
errors = []
|
2014-08-18 03:19:41 -04:00
|
|
|
|
2014-09-14 04:21:55 -04:00
|
|
|
tasks.each do |task|
|
|
|
|
begin
|
|
|
|
Rake::Task[task].invoke
|
|
|
|
rescue Exception
|
|
|
|
errors << task
|
2014-08-18 03:19:41 -04:00
|
|
|
end
|
2014-08-12 05:17:19 -04:00
|
|
|
end
|
|
|
|
|
2014-09-14 04:21:55 -04:00
|
|
|
abort "Errors running #{errors.join(', ')}" if errors.any?
|
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
|