Permalink
Browse files

extract test info from the command line and set up the test task

  • Loading branch information...
1 parent 7f698da commit 88cf64a6690e3c7cc05bd644bd5ad9a000192ebd @tenderlove tenderlove committed Apr 5, 2013
Showing with 28 additions and 5 deletions.
  1. +6 −4 railties/lib/rails/test_unit/testing.rake
  2. +22 −1 railties/test/application/test_runner_test.rb
@@ -48,12 +48,14 @@ task default: :test
desc 'Runs test:units, test:functionals, test:integration together'
task :test do
- tasks = Rake.application.top_level_tasks
- test_files = tasks.grep(/^test\//)
- if test_files.any?
+ info = Rails::TestTask.test_info Rake.application.top_level_tasks
+ if info.files.any?
Rails::TestTask.new('test:single') { |t|
- t.test_files = test_files
+ t.test_files = info.files
}
+ ENV['TESTOPTS'] ||= info.opts
+ Rake.application.top_level_tasks.replace info.tasks
+
Rake::Task['test:single'].invoke
else
Rake::Task[ENV['TEST'] ? 'test:single' : 'test:run'].invoke
@@ -155,7 +155,28 @@ def test_sanae
end
RUBY
- run_test_command('test/unit/chu_2_koi_test.rb TESTOPTS="-n test_rikka"').tap do |output|
+ run_test_command('test/unit/chu_2_koi_test.rb test_rikka').tap do |output|
+ assert_match "Rikka", output
+ assert_no_match "Sanae", output
+ end
+ end
+
+ def test_run_matched_test
+ app_file 'test/unit/chu_2_koi_test.rb', <<-RUBY
+ require 'test_helper'
+
+ class Chu2KoiTest < ActiveSupport::TestCase
+ def test_rikka
+ puts 'Rikka'
+ end
+
+ def test_sanae
+ puts 'Sanae'
+ end
+ end
+ RUBY
+
+ run_test_command('test/unit/chu_2_koi_test.rb /rikka/').tap do |output|
assert_match "Rikka", output
assert_no_match "Sanae", output
end

0 comments on commit 88cf64a

Please sign in to comment.