summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/test/unit.rb54
1 files changed, 32 insertions, 22 deletions
diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index 3df6774d61..5a980603a5 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -871,31 +871,41 @@ module Test
end
files.map! {|f|
f = f.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
- ((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix|
- if prefix
- path = f.empty? ? prefix : "#{prefix}/#{f}"
- else
- next if f.empty?
- path = f
- end
- if f.end_with?(File::SEPARATOR) or !f.include?(File::SEPARATOR) or File.directory?(path)
- match = (Dir["#{path}/**/#{@@testfile_prefix}_*.rb"] + Dir["#{path}/**/*_#{@@testfile_suffix}.rb"]).uniq
- else
- match = Dir[path]
+ while true
+ ret = ((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix|
+ if prefix
+ path = f.empty? ? prefix : "#{prefix}/#{f}"
+ else
+ next if f.empty?
+ path = f
+ end
+ if f.end_with?(File::SEPARATOR) or !f.include?(File::SEPARATOR) or File.directory?(path)
+ match = (Dir["#{path}/**/#{@@testfile_prefix}_*.rb"] + Dir["#{path}/**/*_#{@@testfile_suffix}.rb"]).uniq
+ else
+ match = Dir[path]
+ end
+ if !match.empty?
+ if reject
+ match.reject! {|n|
+ n = n[(prefix.length+1)..-1] if prefix
+ reject_pat =~ n
+ }
+ end
+ break match
+ elsif !reject or reject_pat !~ f and File.exist? path
+ break path
+ end
end
- if !match.empty?
- if reject
- match.reject! {|n|
- n = n[(prefix.length+1)..-1] if prefix
- reject_pat =~ n
- }
+ if !ret
+ if /\.rb\z/ =~ f
+ raise ArgumentError, "file not found: #{f}"
+ else
+ f = "#{f}.rb"
end
- break match
- elsif !reject or reject_pat !~ f and File.exist? path
- break path
+ else
+ break ret
end
- end or
- raise ArgumentError, "file not found: #{f}"
+ end
}
files.flatten!
super(files, options)