corn 0.0.10 → 0.1.0

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: 8f340704b680e93b8d67aed7e12a2cc658ed5351
4
- data.tar.gz: ca441ce6c538e138ff1052692bf1144b1dc1abf8
3
+ metadata.gz: 1286a1c4fa1681980a80beb37f953ef73fdd9bbd
4
+ data.tar.gz: 102e0c92b4f5deddc98e29d9e525b7865b1d9743
5
5
  SHA512:
6
- metadata.gz: ac0b988e636fb559ac1a86508f479860c0d447d24552bc4bb8f6e7518954c365a6d93b5564fe174e266c395902095b31c429d62d204f99fcb48a6ba58934679e
7
- data.tar.gz: e5ecdc155d852046c650f4057c99cbb242b1d241ab6ac4173642088a0adad014d8f38a029067bf54580a228681b869e7d4ccd8a758ada6d9428cc1ec4fcbacd7
6
+ metadata.gz: cc856cd5c679a58da2f584ca1d1d66ab1beb59d1be9025db2e7f7d34c3590bc23307208aa59b3d609de53e4ab39042de52643993d10b8f137bc113df51cc39cb
7
+ data.tar.gz: e0ca9ab344dd596b379ff480c8920a932a2fa8d1954b0d5eabbb6243ed7c97b5abe08cf9a5f4c184b9e39c0a534ff5ccc03e0efdeda79b1e061c12b131f91f71
data/README.md CHANGED
@@ -1,15 +1,3 @@
1
1
  # Corn
2
2
 
3
- ## Examples:
4
-
5
- setup environments:
6
-
7
- CORN_CLIENT_ID
8
- CORN_BUILD_LABEL
9
-
10
- ```ruby
11
-
12
- # test/test_helper.rb, first line
13
- require 'corn/setup'
14
-
15
- ```
3
+ Corn is a simple benchmark report tool.
@@ -4,8 +4,6 @@ require 'logger'
4
4
  require 'csv'
5
5
 
6
6
  require 'corn/report'
7
- require 'corn/test_unit'
8
- require 'corn/mini_test'
9
7
 
10
8
  module Corn
11
9
  module_function
@@ -18,48 +16,35 @@ module Corn
18
16
  ENV['CORN_CLIENT_ID'] || raise('No environment vairable CORN_CLIENT_ID defined')
19
17
  end
20
18
 
21
- def build_label
22
- ENV['CORN_BUILD_LABEL'] || raise('No environment vairable CORN_BUILD_LABEL defined')
19
+ def configured?
20
+ !!ENV['CORN_CLIENT_ID']
23
21
  end
24
22
 
25
23
  def logger
26
24
  @logger ||= Logger.new(STDOUT)
27
25
  end
28
26
 
29
- def setup
30
- return unless ENV['CORN_CLIENT_ID']
31
-
32
- if RUBY_VERSION =~ /^1.8/
33
- if defined?(Test::Unit::TestCase)
34
- Test::Unit::TestCase.send(:include, TestUnit18)
35
- Test::Unit::UI::TestRunnerMediator.send(:include, TestRunnerMediator)
36
- end
37
- end
38
- if defined?(::MiniTest::Unit::TestCase)
39
- ::MiniTest::Unit::TestCase.send(:include, Corn::MiniTest)
40
- ::MiniTest::Unit.after_tests { submit }
41
- end
27
+ def create_report(name)
28
+ Thread.current[report_key] = Report.new(name)
42
29
  end
43
30
 
44
31
  def report(label=nil, &block)
45
- @report ||= Report.new
46
32
  if label
47
- @report.record(label, &block)
33
+ self.report.record(label, &block)
48
34
  else
49
- @report
35
+ Thread.current[report_key]
50
36
  end
51
37
  end
52
38
 
53
39
  def submit
54
- return if @report.nil? || @report.empty?
40
+ return if self.report.nil? || self.report.empty?
55
41
  log_error do
56
42
  data = {
57
- :client_id => client_id,
58
- :build_label => build_label,
59
- :reports => @report.to_csv
43
+ 'client_id' => client_id,
44
+ 'report[name]' => self.report.name,
45
+ 'report[records]' => self.report.to_csv
60
46
  }
61
47
  http_post(File.join(host, 'benchmarks'), data)
62
- @report = nil
63
48
  end
64
49
  end
65
50
 
@@ -86,4 +71,9 @@ module Corn
86
71
  "Report error: #{e.message}:\n#{e.backtrace.join("\n")}"
87
72
  end
88
73
  end
74
+
75
+ def report_key
76
+ '__corn_report__'
77
+ end
78
+
89
79
  end
@@ -37,8 +37,11 @@ module Corn
37
37
  end
38
38
  end
39
39
 
40
- def initialize(prefix=nil)
41
- @record = Record.new(prefix, nil)
40
+ attr_reader :name
41
+
42
+ def initialize(name)
43
+ @name = name
44
+ @record = Record.new(nil)
42
45
  end
43
46
 
44
47
  def record(label, &block)
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xiao Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
- Corn injects hook to test frameworks for collecting test running benchmark reports. It submits reports to Corn Server after all tests finished.
14
+ Corn provides simple api for collecting benchmark reports and submits reports to Corn Server.
15
15
  email:
16
16
  - swing1979@gmail.com
17
17
  executables: []
@@ -20,10 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - README.md
22
22
  - lib/corn.rb
23
- - lib/corn/mini_test.rb
24
23
  - lib/corn/report.rb
25
- - lib/corn/setup.rb
26
- - lib/corn/test_unit.rb
27
24
  homepage: https://github.com/xli/corn
28
25
  licenses:
29
26
  - MIT
@@ -47,5 +44,5 @@ rubyforge_project:
47
44
  rubygems_version: 2.2.0
48
45
  signing_key:
49
46
  specification_version: 4
50
- summary: Corn is a test benchmarking tool.
47
+ summary: Corn is a simple benchmark report tool.
51
48
  test_files: []
@@ -1,33 +0,0 @@
1
- module Corn
2
- module MiniTest
3
- def self.included(base)
4
- base.send(:alias_method, :run_without_corn, :run)
5
- base.send(:alias_method, :run, :run_with_corn)
6
- end
7
-
8
- def run_with_corn(runner, &block)
9
- label = "#{self.class.name}.#{__name__}"
10
- Corn.report(label) do
11
- run_without_corn(runner, &block)
12
- end
13
- end
14
-
15
- def before_setup
16
- Corn.report.record_start(:setup)
17
- end
18
-
19
- def after_setup
20
- Corn.report.record_end
21
- Corn.report.record_start(:run_test)
22
- end
23
-
24
- def before_teardown
25
- Corn.report.record_end
26
- Corn.report.record_start(:teardown)
27
- end
28
-
29
- def after_teardown
30
- Corn.report.record_end
31
- end
32
- end
33
- end
@@ -1,3 +0,0 @@
1
- require 'corn'
2
-
3
- Corn.setup
@@ -1,55 +0,0 @@
1
- require 'test/unit/testcase'
2
-
3
- module Corn
4
- module TestUnit18
5
- def self.included(base)
6
- base.send(:alias_method, :run_without_corn, :run)
7
- base.send(:alias_method, :run, :run_with_corn)
8
- end
9
-
10
- def run_with_corn(result, &block)
11
- label = "#{self.class.name}.#{@method_name}"
12
- Corn.report(label) do
13
- __run_with_corn__(result, &block)
14
- end
15
- end
16
-
17
- def __run_with_corn__(result, &block)
18
- yield(Test::Unit::TestCase::STARTED, name)
19
- @_result = result
20
- begin
21
- Corn.report(:setup) { setup }
22
- Corn.report(:run_test) { __send__(@method_name) }
23
- rescue AssertionFailedError => e
24
- add_failure(e.message, e.backtrace)
25
- rescue Exception
26
- raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
27
- add_error($!)
28
- ensure
29
- begin
30
- Corn.report(:teardown) { teardown }
31
- rescue AssertionFailedError => e
32
- add_failure(e.message, e.backtrace)
33
- rescue Exception
34
- raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
35
- add_error($!)
36
- end
37
- end
38
- result.add_run
39
- yield(Test::Unit::TestCase::FINISHED, name)
40
- end
41
- end
42
-
43
- module TestRunnerMediator
44
- def self.included(base)
45
- base.send(:alias_method, :run_suite_without_corn, :run_suite)
46
- base.send(:alias_method, :run_suite, :run_suite_with_corn)
47
- end
48
-
49
- def run_suite_with_corn
50
- run_suite_without_corn.tap do |r|
51
- Corn.submit
52
- end
53
- end
54
- end
55
- end