1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activejob/Rakefile

84 lines
2.2 KiB
Text
Raw Normal View History

2017-07-09 13:49:52 -04:00
# frozen_string_literal: true
require "rake/testtask"
2014-08-12 05:29:21 -04:00
ACTIVEJOB_ADAPTERS = %w(async inline delayed_job queue_classic resque sidekiq sneakers sucker_punch backburner test)
ACTIVEJOB_ADAPTERS.delete("queue_classic") if defined?(JRUBY_VERSION)
task default: :test
task test: "test:default"
task :package
2014-08-12 05:29:21 -04:00
namespace :test do
desc "Run all adapter tests"
task :default do
run_without_aborting ACTIVEJOB_ADAPTERS.map { |a| "test:#{a}" }
end
desc "Run all adapter tests in isolation"
2014-08-12 05:29:21 -04:00
task :isolated do
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
desc "Run integration tests for all adapters"
2014-08-18 03:19:41 -04:00
task :integration do
run_without_aborting (ACTIVEJOB_ADAPTERS - ["test"]).map { |a| "test:integration:#{a}" }
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
ACTIVEJOB_ADAPTERS.each do |adapter|
task("env:#{adapter}") { ENV["AJ_ADAPTER"] = adapter }
2014-08-12 05:29:21 -04:00
Rake::TestTask.new(adapter => "test:env:#{adapter}") do |t|
t.description = "Run adapter tests for #{adapter}"
t.libs << "test"
t.test_files = FileList["test/cases/**/*_test.rb"]
2014-08-12 05:29:21 -04:00
t.verbose = true
t.warning = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
2014-08-12 05:29:21 -04:00
end
namespace :isolated do
task adapter => "test:env:#{adapter}" do
Dir.glob("#{__dir__}/test/cases/**/*_test.rb").all? do |file|
sh(Gem.ruby, "-w", "-I#{__dir__}/lib", "-I#{__dir__}/test", file)
end || raise("Failures")
2014-08-12 05:29:21 -04:00
end
end
2014-08-18 03:19:41 -04:00
namespace :integration do
Rake::TestTask.new(adapter => ["test:env:#{adapter}", "test:env:integration"]) do |t|
t.description = "Run integration tests for #{adapter}"
t.libs << "test"
t.test_files = FileList["test/integration/**/*_test.rb"]
2014-08-18 03:19:41 -04:00
t.verbose = true
t.warning = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
2014-08-18 03:19:41 -04:00
end
end
end
end
def run_without_aborting(tasks)
errors = []
2014-08-18 03:19:41 -04:00
tasks.each do |task|
puts "\n\n--- rake #{task}\n"
Rake::Task[task].invoke
rescue Exception
puts "\n^^^ +++"
errors << task
end
if errors.any?
puts "\n\n+++ Summary\n"
abort "Errors running #{errors.join(', ')}"
end
end