Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
efa445c7
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
efa445c7
编写于
1月 10, 2016
作者:
K
Kasper Timm Hansen
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22833 from sivagollapalli/test_runner_with_multiple_lines
Running tests with multiple line numbers
上级
56c93bba
78b5a012
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
87 addition
and
4 deletion
+87
-4
railties/lib/rails/test_unit/line_filtering.rb
railties/lib/rails/test_unit/line_filtering.rb
+8
-3
railties/lib/rails/test_unit/test_requirer.rb
railties/lib/rails/test_unit/test_requirer.rb
+1
-1
railties/test/application/test_runner_test.rb
railties/test/application/test_runner_test.rb
+78
-0
未找到文件。
railties/lib/rails/test_unit/line_filtering.rb
浏览文件 @
efa445c7
...
@@ -30,9 +30,14 @@ def derive_regexp(filter)
...
@@ -30,9 +30,14 @@ def derive_regexp(filter)
end
end
def
derive_line_filters
(
patterns
)
def
derive_line_filters
(
patterns
)
patterns
.
map
do
|
file_and_line
|
patterns
.
flat_map
do
|
file_and_line
|
file
,
line
=
file_and_line
.
split
(
':'
)
file
,
*
lines
=
file_and_line
.
split
(
':'
)
Filter
.
new
(
@runnable
,
file
,
line
)
if
file
if
lines
.
empty?
Filter
.
new
(
@runnable
,
file
,
nil
)
if
file
else
lines
.
map
{
|
line
|
Filter
.
new
(
@runnable
,
file
,
line
)
}
end
end
end
end
end
end
end
...
...
railties/lib/rails/test_unit/test_requirer.rb
浏览文件 @
efa445c7
...
@@ -15,7 +15,7 @@ def require_files(patterns)
...
@@ -15,7 +15,7 @@ def require_files(patterns)
private
private
def
expand_patterns
(
patterns
)
def
expand_patterns
(
patterns
)
patterns
.
map
do
|
arg
|
patterns
.
map
do
|
arg
|
arg
=
arg
.
gsub
(
/
:(\d+)
?$/
,
''
)
arg
=
arg
.
gsub
(
/
(:\d*)+
?$/
,
''
)
if
Dir
.
exist?
(
arg
)
if
Dir
.
exist?
(
arg
)
"
#{
arg
}
/**/*_test.rb"
"
#{
arg
}
/**/*_test.rb"
else
else
...
...
railties/test/application/test_runner_test.rb
浏览文件 @
efa445c7
...
@@ -294,6 +294,84 @@ def test_line_filter_does_not_run_this
...
@@ -294,6 +294,84 @@ def test_line_filter_does_not_run_this
end
end
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
def
test_multiple_line_filters
create_test_file
:models
,
'account'
create_test_file
:models
,
'account'
create_test_file
:models
,
'post'
create_test_file
:models
,
'post'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录