aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_unit
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-02-03 21:58:55 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2016-02-03 22:13:09 +0100
commite4f0608164b1a25bc3a35a1bd024efe425410758 (patch)
tree619fe135fc381fe3a33122bad9d6af4efc3f838e /railties/lib/rails/test_unit
parent6ece7df8d80c6d93db43878fa4c0278a0204072c (diff)
downloadrails-e4f0608164b1a25bc3a35a1bd024efe425410758.tar.gz
rails-e4f0608164b1a25bc3a35a1bd024efe425410758.tar.bz2
rails-e4f0608164b1a25bc3a35a1bd024efe425410758.zip
Fix line filters running tests from multiple runnables.
`derive_regexp` was written with the assumption that we were run from a blank slate — that if the filter didn't match we might as well return it because it was nil. This isn't the case because minitest calls `run` on every runnable. Which is any subclass of Minitest::Runnable, such as ActiveSupport::TestCase, ActionDispatch::IntegrationTest as well as any inheriting from those. Thus after the first `run` we'd have put in a composite filter in `options[:filter]` making the next `run` create a linked list when it failed to match the regexp and put the composite filter as the head. Every runnable would accumulate more and more of the same filters, which effectively acted like an expanding whitelist and we ran tests from other runnables. Clog the accumulation by returning nil if there's no filter to derive a regexp from. Note: we pass a seed in the tests because Minitest shuffles the runnables to ensure the whitelist is expanded enough that the failure is triggered.
Diffstat (limited to 'railties/lib/rails/test_unit')
-rw-r--r--railties/lib/rails/test_unit/line_filtering.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/railties/lib/rails/test_unit/line_filtering.rb b/railties/lib/rails/test_unit/line_filtering.rb
index dab4d3631d..b7635c71f4 100644
--- a/railties/lib/rails/test_unit/line_filtering.rb
+++ b/railties/lib/rails/test_unit/line_filtering.rb
@@ -26,7 +26,7 @@ module Rails
private
def derive_regexp(filter)
# Regexp filtering copied from Minitest.
- filter =~ %r%/(.*)/% ? Regexp.new($1) : filter
+ Regexp.new $1 if filter =~ %r%/(.*)/%
end
def derive_line_filters(patterns)