1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Filter method names only if filtering method name only

If sole `filter` option doesn't seem including test case name,
match with method name only.
And if the filter is a Regexp or String, it never matches method
name symbols.
This commit is contained in:
Nobuyoshi Nakada 2021-11-09 15:16:23 +09:00
parent 6cf7c0a48f
commit 3ff0a0b40c
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -240,6 +240,9 @@ module Test
filter = nil
elsif negative.empty? and positive.size == 1 and pos_pat !~ positive[0]
filter = positive[0]
unless /\A[A-Z]\w*(?:::[A-Z]\w*)*#/ =~ filter
filter = /##{Regexp.quote(filter)}\z/
end
else
filter = Regexp.union(*positive.map! {|s| Regexp.new(s[pos_pat, 1] || "\\A#{Regexp.quote(s)}\\z")})
end
@ -1497,15 +1500,9 @@ module Test
all_test_methods = suite.send "#{type}_methods"
if filter
if Regexp === filter
all_test_methods.select! {|method|
filter === "#{suite}##{method}"
}
else
all_test_methods.select! {|method|
filter === method || filter === "#{suite}##{method}"
}
end
all_test_methods.select! {|method|
filter === "#{suite}##{method}"
}
end
all_test_methods = @order.sort_by_name(all_test_methods)