Sha256: 967c49d38a9b0b019bc795d243ed6e96a0d27fdf9d4f5fbcddae97e55b4b36ec
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
#! /usr/bin/env ruby require 'optparse' require 'rgot' opts = {} parser = OptionParser.new do |o| o.on '-v', '--verbose', "log all tests" do |arg| opts[:verbose] = arg end o.on '-b', '--bench [regexp]', "benchmark" do |arg| unless arg raise Rgot::OptionError, "missing argument for flag --bench" end opts[:bench] = arg end o.on '--benchtime [sec]', "benchmark running time" do |arg| opts[:benchtime] = arg 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 target 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 tests = [] benchmarks = [] main = nil c = modules.first test_module = Object.const_get(c) methods = test_module.instance_methods methods.grep(/\Atest_.*/).sort.each do |m| if m == :test_main && main.nil? main = Rgot::InternalTest.new(test_module, m) else tests << Rgot::InternalTest.new(test_module, m) end end methods.grep(/\Abenchmark_.*/).sort.each do |m| benchmarks << Rgot::InternalBenchmark.new(test_module, m) end m = Rgot::M.new(tests: tests, benchmarks: benchmarks, opts: 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.2 | bin/rgot |