diff options
author | Koichi Sasada <ko1@atdot.net> | 2019-07-14 17:48:11 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2019-07-14 17:52:19 +0900 |
commit | 47e571c9510a6d6e3f7d98a8a8800f391694bd19 (patch) | |
tree | 31de5e3e7c7fab236ef03b5a01ba7f93954dbf55 /tool | |
parent | b67b07bd5bd94433051b5e0a5db800f8b22361b4 (diff) | |
download | ruby-47e571c9510a6d6e3f7d98a8a8800f391694bd19.tar.gz |
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.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/lib/test/unit.rb | 54 |
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) |