corn 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/corn.rb +12 -30
- data/lib/corn/mini_test.rb +9 -8
- data/lib/corn/report.rb +43 -6
- data/lib/corn/test_unit.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8772493b9949b6c7b4867b7c7f2c3c7efa8b5ab5
|
4
|
+
data.tar.gz: 6dc258e0d06b44a8548b6b2a9efb8e1a9daf253f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db292f19239353bc7eb1abc990dbd4a88f48e9afdf922d4a4833e0b7568aaa61a10d5a64bfd7ea723682e1c272c5de28a9dc306ae01a2bc786bb156b62dd605c
|
7
|
+
data.tar.gz: 2141b7349b808cef1a5e74e79096cf798e3483deb98ffa0fde3f8c22d6017026338ac1d576593345b90144f7cce257a118d5adb0d32e95a088aa8dd9ec0f0ef2
|
data/lib/corn.rb
CHANGED
@@ -37,41 +37,23 @@ module Corn
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def report(
|
41
|
-
|
42
|
-
|
43
|
-
yield(rep)
|
44
|
-
ensure
|
45
|
-
report_end(test_name, rep)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def report_start
|
50
|
-
@reports ||= create_reports
|
51
|
-
Report.new
|
40
|
+
def report(label, &block)
|
41
|
+
@report ||= Report.new
|
42
|
+
@report.record(label, &block)
|
52
43
|
end
|
53
44
|
|
54
|
-
def
|
55
|
-
|
45
|
+
def exit_submit_hook
|
46
|
+
at_exit { submit }
|
56
47
|
end
|
57
48
|
|
58
|
-
def
|
59
|
-
|
60
|
-
[]
|
61
|
-
end
|
62
|
-
|
63
|
-
def submit_reports
|
64
|
-
return if @reports.nil? || @reports.empty?
|
49
|
+
def submit(report=@report)
|
50
|
+
return if report.empty?
|
65
51
|
log_error do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
data = { client_id: client_id,
|
72
|
-
build_label: build_label,
|
73
|
-
reports: reports_csv }
|
74
|
-
@reports = []
|
52
|
+
data = {
|
53
|
+
:client_id => client_id,
|
54
|
+
:build_label => build_label,
|
55
|
+
:reports => report.to_csv
|
56
|
+
}
|
75
57
|
http_post(File.join(host, 'benchmarks'), data)
|
76
58
|
end
|
77
59
|
end
|
data/lib/corn/mini_test.rb
CHANGED
@@ -6,28 +6,29 @@ module Corn
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def run_with_corn(runner, &block)
|
9
|
-
|
10
|
-
|
9
|
+
label = "#{self.class.name}.#{__name__}"
|
10
|
+
Corn.report(label) do |report|
|
11
|
+
@corn_report = report
|
11
12
|
run_without_corn(runner, &block)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
def before_setup
|
16
|
-
@
|
17
|
+
@corn_report.record_start(:setup)
|
17
18
|
end
|
18
19
|
|
19
20
|
def after_setup
|
20
|
-
@
|
21
|
-
@
|
21
|
+
@corn_report.record_end
|
22
|
+
@corn_report.record_start(:run_test)
|
22
23
|
end
|
23
24
|
|
24
25
|
def before_teardown
|
25
|
-
@
|
26
|
-
@
|
26
|
+
@corn_report.record_end
|
27
|
+
@corn_report.record_start(:teardown)
|
27
28
|
end
|
28
29
|
|
29
30
|
def after_teardown
|
30
|
-
@
|
31
|
+
@corn_report.record_end
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
data/lib/corn/report.rb
CHANGED
@@ -1,29 +1,66 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
1
3
|
module Corn
|
2
4
|
class Report
|
3
|
-
attr_reader :records
|
4
5
|
|
5
|
-
def initialize
|
6
|
+
def initialize(prefix=nil)
|
7
|
+
@prefix = prefix
|
6
8
|
@records = []
|
7
9
|
end
|
8
10
|
|
9
11
|
def record(label, &block)
|
10
12
|
record_start(label)
|
11
|
-
yield
|
13
|
+
yield(sub_report)
|
12
14
|
ensure
|
13
15
|
record_end
|
14
16
|
end
|
15
17
|
|
18
|
+
# start record a benchmark time by label
|
16
19
|
def record_start(label)
|
17
|
-
@record = [label, Time.now]
|
20
|
+
@record = [record_label(label), Time.now]
|
21
|
+
end
|
22
|
+
|
23
|
+
# should only be called between record_start and record_end to generate
|
24
|
+
# sub report for current report
|
25
|
+
def sub_report
|
26
|
+
@sub_report ||= Report.new(@record[0])
|
18
27
|
end
|
19
28
|
|
29
|
+
# should only be called after record_start
|
20
30
|
def record_end
|
21
31
|
@record << Time.now - @record[1]
|
22
32
|
@records << @record
|
33
|
+
if @sub_report
|
34
|
+
@records.concat @sub_report.to_a
|
35
|
+
@sub_report = nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def empty?
|
40
|
+
@records.empty?
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_a
|
44
|
+
@records
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_csv
|
48
|
+
if RUBY_VERSION =~ /1.8/
|
49
|
+
buf = ''
|
50
|
+
@records.each do |r|
|
51
|
+
CSV.generate_row(r, r.size, buf)
|
52
|
+
end
|
53
|
+
buf
|
54
|
+
else
|
55
|
+
CSV.generate do |csv|
|
56
|
+
@records.each { |r| csv << r }
|
57
|
+
end
|
58
|
+
end
|
23
59
|
end
|
24
60
|
|
25
|
-
|
26
|
-
|
61
|
+
private
|
62
|
+
def record_label(label)
|
63
|
+
[@prefix, label].compact.join('.').to_sym
|
27
64
|
end
|
28
65
|
end
|
29
66
|
end
|
data/lib/corn/test_unit.rb
CHANGED