method

setup_argv

Importance_0
v1_9_1_378 - Show latest stable - 0 notes - Class: Test::Unit
setup_argv(original_argv=ARGV) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/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 << '-v'
        when '-n', '--name'
          minitest_argv << arg
          minitest_argv << original_argv.shift
        when '-x'
          reject << original_argv.shift
        else
          files << arg
        end
      end

      if block_given?
        files = yield files
      end

      files.map! {|f|
        f = f.gsub(Regexp.compile(Regexp.quote(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(File.expand_path(f))
        unless $:.include? d
          $: << d
        end
        begin
          require f
        rescue LoadError
          puts "#{f}: #{$!}"
        end
      }

      ARGV.replace minitest_argv
    end
Register or log in to add new notes.