aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_unit
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-02-04 23:06:33 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2016-02-05 21:53:27 +0100
commit84b72a812f9fb488241f06ec573dd751d52f7a67 (patch)
tree839aa365467d45fdb84e080db26cb9eb8c357a1f /railties/lib/rails/test_unit
parentd666a5a5cfd4692cb8ff3914d7ff0e3885c7eb5c (diff)
downloadrails-84b72a812f9fb488241f06ec573dd751d52f7a67.tar.gz
rails-84b72a812f9fb488241f06ec573dd751d52f7a67.tar.bz2
rails-84b72a812f9fb488241f06ec573dd751d52f7a67.zip
Fix mixing line filters with Minitest's -n filter.
Previous commit accidentally broke mixing line filters with string -n filter. Fix by checking if it is a string and returning it. We also need to ensure the -n filter carry forward into any other composite filters. Fix by letting the named filter be extractable, so we'll keep this for the next runnable's run.
Diffstat (limited to 'railties/lib/rails/test_unit')
-rw-r--r--railties/lib/rails/test_unit/line_filtering.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/railties/lib/rails/test_unit/line_filtering.rb b/railties/lib/rails/test_unit/line_filtering.rb
index b7635c71f4..dd9732bb12 100644
--- a/railties/lib/rails/test_unit/line_filtering.rb
+++ b/railties/lib/rails/test_unit/line_filtering.rb
@@ -13,9 +13,12 @@ module Rails
end
class CompositeFilter # :nodoc:
+ attr_reader :named_filter
+
def initialize(runnable, filter, patterns)
@runnable = runnable
- @filters = [ derive_regexp(filter), *derive_line_filters(patterns) ].compact
+ @named_filter = derive_named_filter(filter)
+ @filters = [ @named_filter, *derive_line_filters(patterns) ].compact
end
# Minitest uses === to find matching filters.
@@ -24,9 +27,14 @@ module Rails
end
private
- def derive_regexp(filter)
- # Regexp filtering copied from Minitest.
- Regexp.new $1 if filter =~ %r%/(.*)/%
+ def derive_named_filter(filter)
+ if filter.respond_to?(:named_filter)
+ filter.named_filter
+ elsif filter =~ %r%/(.*)/% # Regexp filtering copied from Minitest.
+ Regexp.new $1
+ elsif filter.is_a?(String)
+ filter
+ end
end
def derive_line_filters(patterns)