Sha256: 899e9549fa200c90fb16f9a1e970df8a48ff9859da5de031b2bc5d56418af20b

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

#! /usr/bin/env ruby
require 'optparse'
require 'rgot'

opts = {}
parser = OptionParser.new do |o|
  o.on '-v', '--verbose', "log all tests" do
    opts[:verbose] = true
  end
end
parser.parse!(ARGV)

target = ARGV[0]

if target
  if File.file?(target)
    require File.expand_path(target)
  elsif File.directory?(target)
    Dir.glob("./#{target}/**/*_test.rb") do |i|
      require i
    end
  else
    puts USAGE
  end
else
  Dir.glob("./**/*_test.rb") do |i|
    require i
  end
end

modules = Object.constants.select { |c|
  next if c == :FileTest
  /.*Test\z/ =~ c
}

if 1 != modules.length
  puts "can not load module. found #{modules.join(', ')}"
  exit 1
end

cases = []
main = nil
c = modules.first

test_module = Object.const_get(c)
test_module.instance_methods.grep(/\Atest_.*/).sort.each do |m|
  if m == :test_main && main.nil?
    main = Rgot::InternalTestType.new(test_module, m)
  else
    cases << Rgot::InternalTestType.new(test_module, m)
  end
end

m = Rgot::M.new(cases, opts)
duration = Rgot.now
at_exit {
  puts sprintf("ok\t%.3fs", Rgot.now - duration)
}
if main
  main.module.extend main.module
  main.module.instance_method(main.name).bind(main.module).call(m)
else
  exit m.run
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rgot-0.0.1 bin/rgot