Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ Allow filtering tests by suite name as well as test name. (lazyatom)

[git-p4: depot-paths = "//src/minitest/dev/": change = 8161]
  • Loading branch information...
commit 3dd26d4c190129c59f48e191f94ec309c338a9df 1 parent ef04d90
@zenspider zenspider authored
View
6 lib/minitest/parallel_each.rb
@@ -27,6 +27,12 @@ def grep pattern # :nodoc:
self.class.new super
end
+ def select(&block) # :nodoc:
+ self.class.new super
+ end
+
+ alias find_all select # :nodoc:
+
##
# Starts N threads that yield each element to your block. Joins the
# threads at the end.
View
7 lib/minitest/unit.rb
@@ -908,7 +908,12 @@ def _run_suite suite, type
filter = options[:filter] || '/./'
filter = Regexp.new $1 if filter =~ /\/(.*)\//
- assertions = suite.send("#{type}_methods").grep(filter).map { |method|
+ all_test_methods = suite.send "#{type}_methods"
+ filtered_test_methods = all_test_methods.find_all { |m|
+ "#{suite}##{m}" =~ filter

I think you might need to use something like match here, because IIRC if the filter option isn't a Regexp (i.e. -n "test_something" then the =~ operation will fail with a type mismatch.

@zenspider Owner
@zenspider Owner

No problem, glad to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+
+ assertions = filtered_test_methods.map { |method|
inst = suite.new method
inst._assertions = 0
View
26 test/minitest/test_minitest_unit.rb
@@ -389,6 +389,32 @@ def test_failure
assert_report expected, %w[--name /some|thing/ --seed 42]
end
+ def test_run_filtered_including_suite_name
+ alpha = Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert false
+ end
+ end
+ self.class.const_set(:Alpha, alpha)
+
+ beta = Class.new MiniTest::Unit::TestCase do
+ def test_something
+ assert true
+ end
+ end
+ self.class.const_set(:Beta, beta)
+
+ expected = clean <<-EOM
+ .
+
+ Finished tests in 0.00
+
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_report expected, %w[--name /Beta#test_something/ --seed 42]
+ end
+
def test_run_passing
Class.new MiniTest::Unit::TestCase do
def test_something
Please sign in to comment.
Something went wrong with that request. Please try again.