module Test::Unit::Collector
Public Class Methods
new()
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 4 def initialize @filters = [] end
Public Instance Methods
add_suite(destination, suite)
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 17 def add_suite(destination, suite) to_delete = suite.tests.find_all do |test| test.is_a?(TestCase) and !include?(test) end suite.delete_tests(to_delete) destination << suite unless suite.empty? end
add_test_cases(suite, test_cases)
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 25 def add_test_cases(suite, test_cases) children_map = {} test_cases.each do |test_case| ancestor_classes = test_case.ancestors.find_all do |ancestor| ancestor.is_a?(Class) end parent = ancestor_classes[1] children_map[parent] ||= [] children_map[parent] << test_case end root_test_cases = children_map.keys - test_cases root_test_cases.each do |root_test_case| add_test_case(suite, root_test_case, children_map) end end
filter=(filters)
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 8 def filter=(filters) @filters = case(filters) when Proc [filters] when Array filters end end
include?(test)
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 42 def include?(test) return true if(@filters.empty?) @filters.each do |filter| return false if filter[test] == false end true end
sort(suites)
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 50 def sort(suites) suites.sort_by do |suite| [suite.priority, suite.name || suite.to_s] end end
Private Instance Methods
add_test_case(suite, test_case, children_map)
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 57 def add_test_case(suite, test_case, children_map) children = children_map[test_case] return if children.nil? sub_suites = [] children.each do |child| sub_suite = child.suite add_test_case(sub_suite, child, children_map) add_suite(sub_suites, sub_suite) end sort(sub_suites).each do |sub_suite| suite << sub_suite end end
adjust_ractor_tests(suite)
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 72 def adjust_ractor_tests(suite) return if suite.nil? ractor_suites = extract_ractor_tests(suite) ractor_suites.each do |ractor_suite| suite << ractor_suite end end
extract_ractor_tests(suite)
click to toggle source
# File test-unit-3.6.2/lib/test/unit/collector.rb, line 80 def extract_ractor_tests(suite) ractor_suites = [] ractor_tests = [] suite.tests.each do |test| case test when TestSuite ractor_suites.concat(extract_ractor_tests(test)) else next unless test[:ractor] ractor_tests << test end end unless ractor_tests.empty? suite.delete_tests(ractor_tests) ractor_suite = TestSuite.new(suite.name, suite.test_case) ractor_tests.each do |ractor_test| ractor_suite << ractor_test end ractor_suites << ractor_suite end ractor_suites end