File: Rakefile

package info (click to toggle)
rails 2:6.0.3.5+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 69,996 kB
  • sloc: ruby: 270,788; javascript: 18,996; yacc: 46; sql: 43; makefile: 28; sh: 18
file content (77 lines) | stat: -rw-r--r-- 2,136 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# frozen_string_literal: true

require "rake/testtask"

ACTIVEJOB_ADAPTERS = %w(async inline delayed_job sidekiq 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