complement '.rb' on `test-all TESTS=test_xxx`

for test-all rule, we can specify a file with TESTS option like
`TESTS=test_xxx.rb`. However, we can eliminate last '.rb' suffix
so this patch try with '.rb' suffix if the given path is not available.
This commit is contained in:
Koichi Sasada 2019-07-14 17:48:11 +09:00
Родитель b67b07bd5b
Коммит 47e571c951
1 изменённых файлов: 33 добавлений и 23 удалений

Просмотреть файл

@ -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]
end
if !match.empty?
if reject
match.reject! {|n|
n = n[(prefix.length+1)..-1] if prefix
reject_pat =~ n
}
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
break match
elsif !reject or reject_pat !~ f and File.exist? path
break path
end
end or
raise ArgumentError, "file not found: #{f}"
if !ret
if /\.rb\z/ =~ f
raise ArgumentError, "file not found: #{f}"
else
f = "#{f}.rb"
end
else
break ret
end
end
}
files.flatten!
super(files, options)