Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • test/unit.rb
  • test/unit/assertions.rb
  • test/unit/testcase.rb

Class/Module Index [+]

Quicksearch

Test::Unit

Public Class Methods

setup_argv(original_argv=ARGV) click to toggle source
 
               # File test/unit.rb, line 11
def self.setup_argv(original_argv=ARGV)
  minitest_argv = []
  files = []
  reject = []
  original_argv = original_argv.dup
  while arg = original_argv.shift
    case arg
    when '-v'
      minitest_argv << arg
    when /\A(-n)(.+)?/, /\A(--name)=?\b(.+)?/
      minitest_argv << $1
      minitest_argv << ($2 || original_argv.shift)
    when /\A-x(.+)?/
      reject << ($1 || original_argv.shift)
    else
      files << arg
    end
  end

  if block_given?
    files = yield files
  end

  files.map! {|f|
    f = f.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
    if File.directory? f
      Dir["#{f}/**/test_*.rb"]
    elsif File.file? f
      f
    else
      raise ArgumentError, "file not found: #{f}"
    end
  }
  files.flatten!

  reject_pat = Regexp.union(reject.map {|r| /#{r}/ })
  files.reject! {|f| reject_pat =~ f }

  files.each {|f|
    d = File.dirname(path = File.expand_path(f))
    unless $:.include? d
      $: << d
    end
    begin
      require path
    rescue LoadError
      puts "#{f}: #{$!}"
    end
  }

  ARGV.replace minitest_argv
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus