提交 efa445c7 编写于 作者: K Kasper Timm Hansen

Merge pull request #22833 from sivagollapalli/test_runner_with_multiple_lines

Running tests with multiple line numbers
......@@ -30,9 +30,14 @@ def derive_regexp(filter)
end
def derive_line_filters(patterns)
patterns.map do |file_and_line|
file, line = file_and_line.split(':')
Filter.new(@runnable, file, line) if file
patterns.flat_map do |file_and_line|
file, *lines = file_and_line.split(':')
if lines.empty?
Filter.new(@runnable, file, nil) if file
else
lines.map { |line| Filter.new(@runnable, file, line) }
end
end
end
end
......
......@@ -15,7 +15,7 @@ def require_files(patterns)
private
def expand_patterns(patterns)
patterns.map do |arg|
arg = arg.gsub(/:(\d+)?$/, '')
arg = arg.gsub(/(:\d*)+?$/, '')
if Dir.exist?(arg)
"#{arg}/**/*_test.rb"
else
......
......@@ -294,6 +294,84 @@ def test_line_filter_does_not_run_this
end
end
def test_more_than_one_line_filter
app_file 'test/models/post_test.rb', <<-RUBY
require 'test_helper'
class PostTest < ActiveSupport::TestCase
test "first filter" do
puts 'PostTest:FirstFilter'
assert true
end
test "second filter" do
puts 'PostTest:SecondFilter'
assert true
end
test "test line filter does not run this" do
assert true
end
end
RUBY
run_test_command('test/models/post_test.rb:4:9').tap do |output|
assert_match 'PostTest:FirstFilter', output
assert_match 'PostTest:SecondFilter', output
assert_match '2 runs, 2 assertions', output
end
end
def test_more_than_one_line_filter_with_multiple_files
app_file 'test/models/account_test.rb', <<-RUBY
require 'test_helper'
class AccountTest < ActiveSupport::TestCase
test "first filter" do
puts 'AccountTest:FirstFilter'
assert true
end
test "second filter" do
puts 'AccountTest:SecondFilter'
assert true
end
test "line filter does not run this" do
assert true
end
end
RUBY
app_file 'test/models/post_test.rb', <<-RUBY
require 'test_helper'
class PostTest < ActiveSupport::TestCase
test "first filter" do
puts 'PostTest:FirstFilter'
assert true
end
test "second filter" do
puts 'PostTest:SecondFilter'
assert true
end
test "line filter does not run this" do
assert true
end
end
RUBY
run_test_command('test/models/account_test.rb:4:9 test/models/post_test:4:9').tap do |output|
assert_match 'AccountTest:FirstFilter', output
assert_match 'AccountTest:SecondFilter', output
assert_match 'PostTest:FirstFilter', output
assert_match 'PostTest:SecondFilter', output
assert_match '4 runs, 4 assertions', output
end
end
def test_multiple_line_filters
create_test_file :models, 'account'
create_test_file :models, 'post'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册