Method: Test::Unit::GlobOption#non_options

Defined in:
lib/test/unit.rb

#non_options(files, options) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/test/unit.rb', line 173

def non_options(files, options)
  paths = [options.delete(:base_directory), nil].uniq
  if reject = options.delete(:reject)
    reject_pat = Regexp.union(reject.map {|r| /#{r}/ })
  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 !(match = Dir["#{path}/**/#{@@testfile_prefix}_*.rb"]).empty?
        if reject
          match.reject! {|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 or
      raise ArgumentError, "file not found: #{f}"
  }
  files.flatten!
  super(files, options)
end