corn 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -7
- data/lib/corn.rb +20 -22
- data/lib/corn/report.rb +29 -0
- data/lib/corn/test_unit.rb +38 -5
- metadata +29 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 607a7f0ddaf8c0d778472a489584bae965435d46
|
4
|
+
data.tar.gz: bbd395af2e6c79c364ac5ed250994a49baedd9d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ab8d249138a7a9ae6246e130b9af1f9b1d15366f59114f826aef86f00f755118a617754b5fa721919ef75660179cdd6ab88255a4aa9fad5f7f74d8920ccb3c59
|
7
|
+
data.tar.gz: 2b375bf3db20fffee3e335f6fde8a841f72f955c8767d2a72f9fb371cca9a32ad08ceaa4ff8d77ffe916013ce6064d9f9c51847dadf9bfed294c81cd0257e518
|
data/lib/corn.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
require 'corn/test_unit'
|
2
1
|
require 'net/http'
|
3
2
|
require 'net/https'
|
4
3
|
require 'logger'
|
5
4
|
|
5
|
+
require 'corn/report'
|
6
|
+
require 'corn/test_unit'
|
7
|
+
|
6
8
|
module Corn
|
7
9
|
module_function
|
8
10
|
|
@@ -26,31 +28,27 @@ module Corn
|
|
26
28
|
Test::Unit::TestCase.send(:include, Corn::TestUnit)
|
27
29
|
end
|
28
30
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
def report(test_name, &block)
|
32
|
+
rep = report_start
|
33
|
+
begin
|
34
|
+
yield(rep)
|
35
|
+
ensure
|
36
|
+
report_end(test_name, rep)
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
|
-
def
|
37
|
-
|
38
|
-
start_at = Time.now
|
39
|
-
begin
|
40
|
-
block.call
|
41
|
-
ensure
|
42
|
-
realtime = Time.now - start_at
|
43
|
-
reports << [label, start_at.to_i, realtime]
|
44
|
-
end
|
45
|
-
end
|
40
|
+
def report_start
|
41
|
+
Report.new
|
46
42
|
end
|
47
43
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
def report_end(test_name, report)
|
45
|
+
log_error do
|
46
|
+
head = [['client_id', client_id],
|
47
|
+
['build_id', build_id],
|
48
|
+
['test_name', test_name]]
|
49
|
+
data = head.concat(report.records.map {|r| ['reports[]', r.join(",")]})
|
50
|
+
http_post(File.join(host, 'benchmarks'), data)
|
51
|
+
end
|
54
52
|
end
|
55
53
|
|
56
54
|
def http_post(url, data)
|
data/lib/corn/report.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Corn
|
2
|
+
class Report
|
3
|
+
attr_reader :records
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@records = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def record(label, &block)
|
10
|
+
record_start(label)
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
record_end
|
14
|
+
end
|
15
|
+
|
16
|
+
def record_start(label)
|
17
|
+
@record = [label, Time.now]
|
18
|
+
end
|
19
|
+
|
20
|
+
def record_end
|
21
|
+
@record << Time.now - @record[1]
|
22
|
+
@records << @record
|
23
|
+
end
|
24
|
+
|
25
|
+
def record_time
|
26
|
+
Time.now - @start_at
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/corn/test_unit.rb
CHANGED
@@ -8,7 +8,7 @@ module Corn
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run_with_corn(result, &block)
|
11
|
-
Corn.
|
11
|
+
Corn.report(name) do |report|
|
12
12
|
__run_with_corn__(report, result, &block)
|
13
13
|
end
|
14
14
|
end
|
@@ -17,8 +17,8 @@ module Corn
|
|
17
17
|
yield(Test::Unit::TestCase::STARTED, name)
|
18
18
|
@_result = result
|
19
19
|
begin
|
20
|
-
report.
|
21
|
-
report.
|
20
|
+
report.record(:setup) { setup }
|
21
|
+
report.record(@method_name) { __send__(@method_name) }
|
22
22
|
rescue AssertionFailedError => e
|
23
23
|
add_failure(e.message, e.backtrace)
|
24
24
|
rescue Exception
|
@@ -26,7 +26,7 @@ module Corn
|
|
26
26
|
add_error($!)
|
27
27
|
ensure
|
28
28
|
begin
|
29
|
-
report.
|
29
|
+
report.record(:teardown) { teardown }
|
30
30
|
rescue AssertionFailedError => e
|
31
31
|
add_failure(e.message, e.backtrace)
|
32
32
|
rescue Exception
|
@@ -38,5 +38,38 @@ module Corn
|
|
38
38
|
yield(Test::Unit::TestCase::FINISHED, name)
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
|
+
module TestUnit19
|
43
|
+
def self.included(base)
|
44
|
+
base.send(:alias_method, :run_without_corn, :run)
|
45
|
+
base.send(:alias_method, :run, :run_with_corn)
|
46
|
+
end
|
47
|
+
|
48
|
+
def run_with_corn(runner, &block)
|
49
|
+
Corn.report("#{__name__}(#{self.class.name})") do |report|
|
50
|
+
@__corn_report__ = report
|
51
|
+
run_without_corn(runner, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def before_setup
|
56
|
+
@__corn_report__.record_start(:setup)
|
57
|
+
end
|
58
|
+
|
59
|
+
def after_setup
|
60
|
+
@__corn_report__.record_end
|
61
|
+
@__corn_report__.record_start(__name__)
|
62
|
+
end
|
63
|
+
|
64
|
+
def before_teardown
|
65
|
+
@__corn_report__.record_end
|
66
|
+
@__corn_report__.record_start(:teardown)
|
67
|
+
end
|
68
|
+
|
69
|
+
def after_teardown
|
70
|
+
@__corn_report__.record_end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
TestUnit = RUBY_VERSION =~ /^1.8/ ? TestUnit18 : TestUnit19
|
42
75
|
end
|
metadata
CHANGED
@@ -1,56 +1,49 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: corn
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
|
6
|
+
authors:
|
7
|
+
- Xiao Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
date: 2014-01-29 00:00:00 Z
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
|
15
13
|
description: TBD
|
16
|
-
email:
|
17
|
-
|
14
|
+
email:
|
15
|
+
- swing1979@gmail.com
|
18
16
|
executables: []
|
19
|
-
|
20
17
|
extensions: []
|
21
|
-
|
22
18
|
extra_rdoc_files: []
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
files:
|
20
|
+
- README.md
|
21
|
+
- lib/corn.rb
|
22
|
+
- lib/corn/report.rb
|
23
|
+
- lib/corn/setup.rb
|
24
|
+
- lib/corn/test_unit.rb
|
29
25
|
homepage: https://github.com/xli/corn
|
30
|
-
licenses:
|
31
|
-
|
26
|
+
licenses:
|
27
|
+
- MIT
|
32
28
|
metadata: {}
|
33
|
-
|
34
29
|
post_install_message:
|
35
30
|
rdoc_options: []
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
48
43
|
requirements: []
|
49
|
-
|
50
44
|
rubyforge_project:
|
51
|
-
rubygems_version: 2.
|
45
|
+
rubygems_version: 2.2.0
|
52
46
|
signing_key:
|
53
47
|
specification_version: 4
|
54
48
|
summary: TBD
|
55
49
|
test_files: []
|
56
|
-
|