bin/rgot in rgot-0.0.1 vs bin/rgot in rgot-0.0.2
- old
+ new
@@ -2,13 +2,22 @@
require 'optparse'
require 'rgot'
opts = {}
parser = OptionParser.new do |o|
- o.on '-v', '--verbose', "log all tests" do
- opts[:verbose] = true
+ 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]
@@ -18,11 +27,11 @@
elsif File.directory?(target)
Dir.glob("./#{target}/**/*_test.rb") do |i|
require i
end
else
- puts USAGE
+ puts target
end
else
Dir.glob("./**/*_test.rb") do |i|
require i
end
@@ -36,23 +45,29 @@
if 1 != modules.length
puts "can not load module. found #{modules.join(', ')}"
exit 1
end
-cases = []
+tests = []
+benchmarks = []
main = nil
c = modules.first
test_module = Object.const_get(c)
-test_module.instance_methods.grep(/\Atest_.*/).sort.each do |m|
+methods = test_module.instance_methods
+methods.grep(/\Atest_.*/).sort.each do |m|
if m == :test_main && main.nil?
- main = Rgot::InternalTestType.new(test_module, m)
+ main = Rgot::InternalTest.new(test_module, m)
else
- cases << Rgot::InternalTestType.new(test_module, m)
+ tests << Rgot::InternalTest.new(test_module, m)
end
end
-m = Rgot::M.new(cases, opts)
+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