Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lib/test/unit.rb: separate common preparation
* lib/test/unit.rb (Test::Unit::Runner#_prepare_run): separate common
  preparation from _run_suite.
  • Loading branch information
nobu committed May 7, 2012
commit 0b352ee5fc00624b2dfa05df545306a7beb69b3c
14 changes: 10 additions & 4 deletions lib/test/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ def _run_parallel suites, type, result
end

def _run_suites suites, type
_prepare_run(suites, type)
@interrupt = nil
result = []
GC.start
Expand All @@ -643,16 +644,21 @@ def _run_suites suites, type
result
end

def _prepare_run(suites, type)
if /\A\/(.*)\/\z/ =~ (filter = options[:filter])
options[:filter] = filter = Regexp.new($1)
end
end

alias mini_run_suite _run_suite

def _run_suite suite, type
header = "#{type}_suite_header"
puts send(header, suite) if respond_to? header

filter = options[:filter] || '/./'
filter = Regexp.new $1 if filter =~ /\A\/(.*)\/\z/

assertions = suite.send("#{type}_methods").grep(filter).map { |method|
tests = suite.send("#{type}_methods")
filter = options[:filter] and tests = tests.grep(filter)
assertions = tests.map { |method|
inst = suite.new method
inst._assertions = 0
_run_testcase(inst)
Expand Down