1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/bin/test
Yasuo Honda a3f1eb5ebe 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"]`
2021-09-07 21:34:56 +09:00

27 lines
725 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
adapter_index = ARGV.index("--adapter") || ARGV.index("-a")
if adapter_index
ARGV.delete_at(adapter_index)
ENV["ARCONN"] = ARGV.delete_at(adapter_index).strip
end
COMPONENT_ROOT = File.expand_path("..", __dir__)
require_relative "../test/support/tools"
module Minitest
def self.plugin_active_record_options(opts, options)
opts.separator ""
opts.separator "Active Record options:"
opts.on("-a", "--adapter [ADAPTER]",
"Run tests using a specific adapter (sqlite3, sqlite3_mem, mysql2, postgresql)") do |adapter|
ENV["ARCONN"] = adapter.strip
end
opts
end
end
Minitest.load_plugins
Minitest.extensions.unshift "active_record"