test-unit/lib/test/unit/collector/load.rb in activeldap-1.2.1 vs test-unit/lib/test/unit/collector/load.rb in activeldap-1.2.2
- old
+ new
@@ -12,12 +12,12 @@
attr_reader :patterns, :excludes, :base
def initialize
super
@system_excludes = [/~\z/, /\A\.\#/]
- @system_directory_excludes = [/\A(?:CVS|\.svn)\z/]
- @patterns = [/\Atest[_\-].+\.rb\z/m]
+ @system_directory_excludes = [/\A(?:CVS|\.svn|\.git)\z/]
+ @patterns = [/\Atest[_\-].+\.rb\z/m, /[_\-]test\.rb\z/]
@excludes = []
@base = nil
end
def base=(base)
@@ -26,15 +26,21 @@
end
def collect(*froms)
add_load_path(@base) do
froms = ["."] if froms.empty?
- test_suites = froms.collect do |from|
- test_suite = collect_recursive(resolve_path(from), find_test_cases)
- test_suite = nil if test_suite.tests.empty?
- test_suite
- end.compact
+ test_suites = []
+ already_gathered = find_test_cases
+ froms.each do |from|
+ from = resolve_path(from)
+ if from.directory?
+ test_suite = collect_recursive(from, already_gathered)
+ test_suites << test_suite unless test_suite.tests.empty?
+ else
+ collect_file(from, test_suites, already_gathered)
+ end
+ end
if test_suites.size > 1
test_suite = TestSuite.new("[#{froms.join(', ')}]")
sort(test_suites).each do |sub_test_suite|
test_suite << sub_test_suite
@@ -86,9 +92,11 @@
end
test_suite
end
def collect_file(path, test_suites, already_gathered)
+ @program_file ||= File.expand_path($0)
+ return if @program_file == path.to_s
add_load_path(path.expand_path.dirname) do
require(path.to_s)
find_test_cases(already_gathered).each do |test_case|
add_suite(test_suites, test_case.suite)
end