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
Ryuta Kamizono 892e38c78e Enable Style/RedundantBegin cop to avoid newly adding redundant begin block
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).

I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
2018-12-21 06:12:42 +09:00

77 lines
2.1 KiB
Ruby

# frozen_string_literal: true
require "rake/testtask"
ACTIVEJOB_ADAPTERS = %w(async inline delayed_job que 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
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"
task :isolated do
run_without_aborting ACTIVEJOB_ADAPTERS.map { |a| "test:isolated:#{a}" }
end
desc "Run integration tests for all adapters"
task :integration do
run_without_aborting (ACTIVEJOB_ADAPTERS - ["test"]).map { |a| "test:integration:#{a}" }
end
task "env:integration" do
ENV["AJ_INTEGRATION_TESTS"] = "1"
ENV["SKIP_REQUIRE_WEBPACKER"] = "true"
end
ACTIVEJOB_ADAPTERS.each do |adapter|
task("env:#{adapter}") { ENV["AJ_ADAPTER"] = adapter }
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"]
t.verbose = true
t.warning = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
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")
end
end
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"]
t.verbose = true
t.warning = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end
end
end
end
def run_without_aborting(tasks)
errors = []
tasks.each do |task|
Rake::Task[task].invoke
rescue Exception
errors << task
end
abort "Errors running #{errors.join(', ')}" if errors.any?
end