1
0
Fork 0
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:
Koichi Sasada 2019-08-09 16:08:15 +09:00
parent 26cf4c91ad
commit 3cbd56d574

View file

@ -865,6 +865,18 @@ module Test
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)
paths = [options.delete(:base_directory), nil].uniq
if reject = options.delete(:reject)
@ -872,6 +884,7 @@ module Test
end
files.map! {|f|
f = f.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
orig_f = f
while true
ret = ((paths if /\A\.\.?(?:\z|\/)/ !~ f) || [nil]).any? do |prefix|
if prefix
@ -898,11 +911,7 @@ module Test
end
end
if !ret
if /\.rb\z/ =~ f
raise ArgumentError, "file not found: #{f}"
else
f = "#{f}.rb"
end
f = complement_test_name(f, orig_f)
else
break ret
end