mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
modify to pass the correct argument to the test runner from rake
test runner sets file to be tested in plugin_rails_options, but in plugin_rails_options, processing has been made to the argument of the actual command rather than the argument of Minitest.run. For example, if you run `./bin rake db:migrate test`, the options[:patterns], `db:migrate test` was incorrectly set.
This commit is contained in:
parent
084a3908fc
commit
df744b56cc
2 changed files with 15 additions and 6 deletions
|
@ -29,12 +29,21 @@ module Minitest
|
||||||
options[:patterns] = opts.order!
|
options[:patterns] = opts.order!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Running several Rake tasks in a single command would trip up the runner,
|
||||||
|
# as the patterns would also contain the other Rake tasks.
|
||||||
|
def self.rake_run(patterns) # :nodoc:
|
||||||
|
@rake_patterns = patterns
|
||||||
|
run
|
||||||
|
end
|
||||||
|
|
||||||
def self.plugin_rails_init(options)
|
def self.plugin_rails_init(options)
|
||||||
self.run_with_rails_extension = true
|
self.run_with_rails_extension = true
|
||||||
|
|
||||||
ENV["RAILS_ENV"] = options[:environment] || "test"
|
ENV["RAILS_ENV"] = options[:environment] || "test"
|
||||||
|
|
||||||
::Rails::TestRequirer.require_files options[:patterns] unless run_with_autorun
|
unless run_with_autorun
|
||||||
|
::Rails::TestRequirer.require_files @rake_patterns || options[:patterns]
|
||||||
|
end
|
||||||
|
|
||||||
unless options[:full_backtrace] || ENV["BACKTRACE"]
|
unless options[:full_backtrace] || ENV["BACKTRACE"]
|
||||||
# Plugin can run without Rails loaded, check before filtering.
|
# Plugin can run without Rails loaded, check before filtering.
|
||||||
|
|
|
@ -7,7 +7,7 @@ task default: :test
|
||||||
desc "Runs all tests in test folder"
|
desc "Runs all tests in test folder"
|
||||||
task :test do
|
task :test do
|
||||||
$: << "test"
|
$: << "test"
|
||||||
Minitest.run(['test'])
|
Minitest.rake_run(["test"])
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
|
@ -24,22 +24,22 @@ namespace :test do
|
||||||
["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name|
|
["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name|
|
||||||
task name => "test:prepare" do
|
task name => "test:prepare" do
|
||||||
$: << "test"
|
$: << "test"
|
||||||
Minitest.run(["test/#{name}"])
|
Minitest.rake_run(["test/#{name}"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :generators => "test:prepare" do
|
task :generators => "test:prepare" do
|
||||||
$: << "test"
|
$: << "test"
|
||||||
Minitest.run(["test/lib/generators"])
|
Minitest.rake_run(["test/lib/generators"])
|
||||||
end
|
end
|
||||||
|
|
||||||
task :units => "test:prepare" do
|
task :units => "test:prepare" do
|
||||||
$: << "test"
|
$: << "test"
|
||||||
Minitest.run(["test/models", "test/helpers", "test/unit"])
|
Minitest.rake_run(["test/models", "test/helpers", "test/unit"])
|
||||||
end
|
end
|
||||||
|
|
||||||
task :functionals => "test:prepare" do
|
task :functionals => "test:prepare" do
|
||||||
$: << "test"
|
$: << "test"
|
||||||
Minitest.run(["test/controllers", "test/mailers", "test/functional"])
|
Minitest.rake_run(["test/controllers", "test/mailers", "test/functional"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue