mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
complement test_
prefix.
`make test-all TESTS=name` can specify running test files by name. name can be dirname ('dir/') or a file ('.../test_foo.rb'). This patch complement `test_` prefix for a test. So we only need to specify `TESTS=ruby/hash` which means `TESTS=ruby/test_hash.rb`.
This commit is contained in:
parent
26cf4c91ad
commit
3cbd56d574
1 changed files with 14 additions and 5 deletions
|
@ -865,6 +865,18 @@ module Test
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def complement_test_name f, orig_f
|
||||||
|
basename = File.basename(f)
|
||||||
|
|
||||||
|
if /\.rb\z/ !~ basename
|
||||||
|
return File.join(File.dirname(f), basename+'.rb')
|
||||||
|
elsif /\Atest_/ !~ basename
|
||||||
|
return File.join(File.dirname(f), 'test_'+basename)
|
||||||
|
end if /#{basename}\z/ =~ f # otherwise basename is dirname/
|
||||||
|
|
||||||
|
raise ArgumentError, "file not found: #{orig_f}"
|
||||||
|
end
|
||||||
|
|
||||||
def non_options(files, options)
|
def non_options(files, options)
|
||||||
paths = [options.delete(:base_directory), nil].uniq
|
paths = [options.delete(:base_directory), nil].uniq
|
||||||
if reject = options.delete(:reject)
|
if reject = options.delete(:reject)
|
||||||
|
@ -872,6 +884,7 @@ module Test
|
||||||
end
|
end
|
||||||
files.map! {|f|
|
files.map! {|f|
|
||||||
f = f.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
f = f.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
||||||
|
orig_f = f
|
||||||
while true
|
while true
|
||||||
ret = ((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix|
|
ret = ((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix|
|
||||||
if prefix
|
if prefix
|
||||||
|
@ -898,11 +911,7 @@ module Test
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !ret
|
if !ret
|
||||||
if /\.rb\z/ =~ f
|
f = complement_test_name(f, orig_f)
|
||||||
raise ArgumentError, "file not found: #{f}"
|
|
||||||
else
|
|
||||||
f = "#{f}.rb"
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
break ret
|
break ret
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue