rgot 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7571a770fb9c1047be1ec5e1e46f00111aa66948
4
- data.tar.gz: 893e306ae56bf1c564fe174071d77f53035f2f3d
3
+ metadata.gz: fad880c302f5d362eda08135ab27437e1888969d
4
+ data.tar.gz: fbed3fac0716f0957c4a88864c0444e261f2ad74
5
5
  SHA512:
6
- metadata.gz: a66f756df701873ad1acdae4202d89586946c86251e9b28ddb64fe7baaa4fac2ec782a938f657d0215830420bbe1c8166b04ccdf6bbc3a389916ebcadc3d76d2
7
- data.tar.gz: 74f482d803f640563393a3395984a9e4b6f11ebc18f269dd1047839dab2d05b8f5164fff5d59f22c794872b1f5bc502bd5c432e7e06f16722374c0ccbcda61c2
6
+ metadata.gz: 60c14ab525a73c15392801891161bde4f45c21544037fc273c657b75ab96bab751efa0c8fc166a51fcfaf069b8b5ce0c452f84d8b8aaffc272a95c939634e8b6
7
+ data.tar.gz: 441094eb65219d7b2105bce7b7df8945abb14186025eb71f7af2e953269735f8df98e740cfe76c86ae8ef78fc7c3e10d238a3b76ba724cadd6777cba30bde84f
data/bin/rgot CHANGED
@@ -9,7 +9,7 @@ parser = OptionParser.new do |o|
9
9
  Rgot.class_eval{ @chatty = arg }
10
10
  end
11
11
  o.on '--version', "show Rgot version" do |arg|
12
- puts "Rgot v#{Rgot::VERSION}"
12
+ puts "rgot #{Rgot::VERSION} (ruby #{RUBY_VERSION})"
13
13
  exit 0
14
14
  end
15
15
  o.on '--bench [regexp]', "benchmark" do |arg|
@@ -42,8 +42,12 @@ require_paths.each do |path|
42
42
  require path
43
43
  end
44
44
 
45
- ARGV.each do |target|
46
- if target
45
+ if ARGV.empty?
46
+ Dir.glob("./**/*_test.rb") do |i|
47
+ require i
48
+ end
49
+ else
50
+ ARGV.each do |target|
47
51
  if File.file?(target)
48
52
  require File.expand_path(target)
49
53
  elsif File.directory?(target)
@@ -53,10 +57,6 @@ ARGV.each do |target|
53
57
  else
54
58
  puts target
55
59
  end
56
- else
57
- Dir.glob("./**/*_test.rb") do |i|
58
- require i
59
- end
60
60
  end
61
61
  end
62
62
 
@@ -80,7 +80,7 @@ modules.each do |test_module|
80
80
  benchmarks = []
81
81
  examples = []
82
82
  main = nil
83
- methods = test_module.instance_methods.sort
83
+ methods = test_module.instance_methods
84
84
  methods.grep(/\Atest_/).each do |m|
85
85
  if m == :test_main && main.nil?
86
86
  main = Rgot::InternalTest.new(test_module, m)
@@ -105,9 +105,10 @@ modules.each do |test_module|
105
105
  when SystemExit
106
106
  if $!.success?
107
107
  # exit 0
108
- puts sprintf(template, "ok", test_module, Rgot.now - duration)
108
+ puts sprintf(template, "ok ", test_module, Rgot.now - duration)
109
109
  else
110
110
  # exit 1
111
+ puts "exit status #{$!.status}"
111
112
  puts sprintf(template, "FAIL", test_module, Rgot.now - duration)
112
113
  end
113
114
  when NilClass
@@ -95,7 +95,13 @@ module Rgot
95
95
  if block
96
96
  block.call(self)
97
97
  else
98
- @module.instance_method(@name).bind(@module).call(self)
98
+ bench_method = @module.instance_method(@name).bind(@module)
99
+ if bench_method.arity == 0
100
+ path, line = bench_method.source_location
101
+ self.skip "#{path}:#{line} `#{bench_method.name}' is not running. It's a benchmark method name, But not have argument"
102
+ else
103
+ bench_method.call(self)
104
+ end
99
105
  end
100
106
  stop_timer
101
107
  end
@@ -1,4 +1,5 @@
1
1
  require 'thread'
2
+ require 'pathname'
2
3
 
3
4
  module Rgot
4
5
  class Common
@@ -1,5 +1,6 @@
1
1
  require 'stringio'
2
2
  require 'etc'
3
+ require 'timeout'
3
4
 
4
5
  module Rgot
5
6
  class M
@@ -45,7 +46,7 @@ module Rgot
45
46
  puts "FAIL"
46
47
  return 1
47
48
  end
48
- puts "PASS" if Rgot.verbose?
49
+ puts "PASS"
49
50
  run_benchmarks
50
51
  0
51
52
  end
@@ -57,7 +58,7 @@ module Rgot
57
58
  @tests.each do |test|
58
59
  t = T.new(test.module, test.name.to_sym)
59
60
  if Rgot.verbose?
60
- puts "=== RUN #{test.name}"
61
+ puts "=== RUN #{test.name}"
61
62
  end
62
63
  t.run
63
64
  t.report
@@ -105,8 +106,10 @@ module Rgot
105
106
  ok = true
106
107
  @examples.each do |example|
107
108
  if Rgot.verbose?
108
- puts "=== RUN #{example.name}"
109
+ puts "=== RUN #{example.name}"
109
110
  end
111
+
112
+ start = Rgot.now
110
113
  example.module.extend(example.module)
111
114
  method = example.module.instance_method(example.name).bind(example.module)
112
115
  out, err = capture do
@@ -116,12 +119,17 @@ module Rgot
116
119
  r = ExampleParser.new(File.read(file))
117
120
  r.parse
118
121
  e = r.examples.find{|e| e.name == example.name}
122
+
123
+ duration = Rgot.now - start
119
124
  if e && e.output.strip != out.strip
125
+ printf("--- FAIL: %s (%.2fs)\n", e.name, duration)
120
126
  ok = false
121
127
  puts "got:"
122
128
  puts out.strip
123
129
  puts "want:"
124
130
  puts e.output.strip
131
+ elsif Rgot.verbose?
132
+ printf("--- PASS: %s (%.2fs)\n", e.name, duration)
125
133
  end
126
134
  end
127
135
  ok
@@ -20,7 +20,7 @@ module Rgot
20
20
 
21
21
  def report
22
22
  duration = Rgot.now - @start
23
- template = "--- %s: %s (%.5fs)\n%s"
23
+ template = "--- %s: %s (%.2fs)\n%s"
24
24
  if failed?
25
25
  printf template, "FAIL", @name, duration, @output
26
26
  elsif Rgot.verbose?
@@ -34,7 +34,7 @@ module Rgot
34
34
 
35
35
  def call
36
36
  test_method = @module.instance_method(@name).bind(@module)
37
- if test_method.arity != 1
37
+ if test_method.arity == 0
38
38
  path, line = test_method.source_location
39
39
  warn "#{path}:#{line} `#{test_method.name}' is not running. It's a testing method name, But not have argument"
40
40
  else
@@ -1,3 +1,3 @@
1
1
  module Rgot
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.4.5.1
86
+ rubygems_version: 2.5.0
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Ruby + Golang Testing = Rgot