bin/rgot in rgot-0.0.2 vs bin/rgot in rgot-0.0.3
- old
+ new
@@ -14,10 +14,13 @@
opts[:bench] = arg
end
o.on '--benchtime [sec]', "benchmark running time" do |arg|
opts[:benchtime] = arg
end
+ o.on '--timeout [sec]', "set timeout sec to testing" do |arg|
+ opts[:timeout] = arg
+ end
end
parser.parse!(ARGV)
target = ARGV[0]
@@ -47,30 +50,37 @@
exit 1
end
tests = []
benchmarks = []
+examples = []
main = nil
c = modules.first
test_module = Object.const_get(c)
-methods = test_module.instance_methods
-methods.grep(/\Atest_.*/).sort.each do |m|
+methods = test_module.instance_methods.sort
+methods.grep(/\Atest_/).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|
+methods.grep(/\Abenchmark_/).each do |m|
benchmarks << Rgot::InternalBenchmark.new(test_module, m)
end
-m = Rgot::M.new(tests: tests, benchmarks: benchmarks, opts: opts)
+methods.grep(/\Aexample_?/).each do |m|
+ examples << Rgot::InternalExample.new(test_module, m)
+end
+
+m = Rgot::M.new(tests: tests, benchmarks: benchmarks, examples: examples, opts: opts)
duration = Rgot.now
at_exit {
- puts sprintf("ok\t%.3fs", Rgot.now - duration)
+ if !$!
+ puts sprintf("ok\t%.3fs", Rgot.now - duration)
+ end
}
if main
main.module.extend main.module
main.module.instance_method(main.name).bind(main.module).call(m)
else