提交 7a36686c 编写于 作者: A Aaron Patterson

make sure `rake test` respects TESTOPTS

We should be able to pass options to minitest via TESTOPTS environment
variable
上级 35378265
require "active_support/core_ext/module/attribute_accessors"
require "rails/test_unit/reporter"
require "rails/test_unit/test_requirer"
require 'shellwords'
module Minitest
class SuppressedSummaryReporter < SummaryReporter
......@@ -60,7 +61,7 @@ def self.plugin_rails_options(opts, options)
# as the patterns would also contain the other Rake tasks.
def self.rake_run(patterns) # :nodoc:
@rake_patterns = patterns
passed = run
passed = run(Shellwords.split(ENV['TESTOPTS'] || ''))
exit passed unless passed
passed
end
......
......@@ -502,6 +502,19 @@ def test_pass_TEST_env_on_rake_test
assert_match '1 runs, 1 assertions', output
end
def test_rake_passes_TESTOPTS_to_minitest
create_test_file :models, 'account'
output = Dir.chdir(app_path) { `bin/rake test TESTOPTS=-v` }
assert_match "AccountTest#test_truth", output, "passing TEST= should run selected test"
end
def test_rake_passes_multiple_TESTOPTS_to_minitest
create_test_file :models, 'account'
output = Dir.chdir(app_path) { `bin/rake test TESTOPTS='-v --seed=1234'` }
assert_match "AccountTest#test_truth", output, "passing TEST= should run selected test"
assert_match "seed=1234", output, "passing TEST= should run selected test"
end
private
def run_test_command(arguments = 'test/unit/test_test.rb')
Dir.chdir(app_path) { `bin/rails t #{arguments}` }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册