mirror of https://github.com/rails/rails
Active Record bin/test command runs only its own adapter tests
There are two ways to run unit tests. `bundle exec rake test` and `bin/test`. Active Record `bundle exec rake test` only executes its own adapter specific tests. on the other hand, `bin/test` executes all adapter specfic tests then some test files need to have `if current_adapter?`, which can be removed. - Removed `require_relative "../../tools/test"` to require its own one - `default_test_exclude_glob` excludes all of adapter specific tests. - `list_tests(argv)` adds its own adapter specific tests - `adapter_short` method extracted to get the short hand adapter name like `sqlite3`, `mysql2` and `postgresql` via `ENV["ARCONN"]`
This commit is contained in:
parent
39b305c0b7
commit
a3f1eb5ebe
|
@ -8,7 +8,7 @@ if adapter_index
|
|||
end
|
||||
|
||||
COMPONENT_ROOT = File.expand_path("..", __dir__)
|
||||
require_relative "../../tools/test"
|
||||
require_relative "../test/support/tools"
|
||||
|
||||
module Minitest
|
||||
def self.plugin_active_record_options(opts, options)
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
$: << File.expand_path("test", COMPONENT_ROOT)
|
||||
|
||||
require "bundler/setup"
|
||||
|
||||
require "rails/test_unit/runner"
|
||||
require "rails/test_unit/reporter"
|
||||
require "rails/test_unit/line_filtering"
|
||||
require "active_support"
|
||||
require "active_support/test_case"
|
||||
|
||||
require "rake/testtask"
|
||||
Rails::TestUnit::Runner.singleton_class.prepend Module.new {
|
||||
private
|
||||
def list_tests(argv)
|
||||
tests = super
|
||||
tests.concat FileList["test/cases/adapters/#{adapter_short}/**/*_test.rb"]
|
||||
end
|
||||
|
||||
def default_test_exclude_glob
|
||||
ENV["DEFAULT_TEST_EXCLUDE"] || "test/cases/adapters/*/*_test.rb"
|
||||
end
|
||||
|
||||
def adapter_short
|
||||
ENV["ARCONN"] || "sqlite3"
|
||||
end
|
||||
}
|
||||
|
||||
ActiveSupport::TestCase.extend Rails::LineFiltering
|
||||
Rails::TestUnitReporter.app_root = COMPONENT_ROOT
|
||||
Rails::TestUnitReporter.executable = "bin/test"
|
||||
|
||||
Rails::TestUnit::Runner.parse_options(ARGV)
|
||||
Rails::TestUnit::Runner.run(ARGV)
|
Loading…
Reference in New Issue