coverband 3.0.1 → 4.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ require 'rack'
5
5
 
6
6
  class FullStackTest < Test::Unit::TestCase
7
7
  BASE_KEY = Coverband::Adapters::RedisStore::BASE_KEY
8
- TEST_RACK_APP = '../fake_app/basic_rack.rb'.freeze
8
+ TEST_RACK_APP = '../fake_app/basic_rack.rb'
9
9
 
10
10
  def setup
11
11
  Coverband::Collectors::Coverage.instance.reset_instance
@@ -13,6 +13,7 @@ class FullStackTest < Test::Unit::TestCase
13
13
  config.reporting_frequency = 100.0
14
14
  config.store = Coverband::Adapters::RedisStore.new(Redis.new)
15
15
  config.s3_bucket = nil
16
+ config.background_reporting_enabled = false
16
17
  end
17
18
  Coverband.configuration.store.clear!
18
19
  Coverband.start
@@ -9,6 +9,7 @@ class MiddlewareTest < Test::Unit::TestCase
9
9
  def setup
10
10
  Coverband.configure do |config|
11
11
  config.store = Coverband::Adapters::RedisStore.new(Redis.new)
12
+ config.background_reporting_enabled = false
12
13
  end
13
14
  end
14
15
 
@@ -27,6 +28,24 @@ class MiddlewareTest < Test::Unit::TestCase
27
28
  app.call(env)
28
29
  end
29
30
 
31
+ test 'starts background reporter when configured' do
32
+ request = Rack::MockRequest.env_for('/anything.json')
33
+ Coverband.configuration.stubs(:background_reporting_enabled).returns(true)
34
+ Coverband::Collectors::Coverage.instance.expects(:report_coverage).never
35
+ Coverband::Background.expects(:start)
36
+ middleware = Coverband::Middleware.new(fake_app)
37
+ middleware.call(request)
38
+ end
39
+
40
+ test 'reports coverage when not set to background mode' do
41
+ request = Rack::MockRequest.env_for('/anything.json')
42
+ Coverband.configuration.stubs(:background_reporting_enabled).returns(false)
43
+ Coverband::Collectors::Coverage.instance.expects(:report_coverage)
44
+ Coverband::Background.expects(:start).never
45
+ middleware = Coverband::Middleware.new(fake_app)
46
+ middleware.call(request)
47
+ end
48
+
30
49
  test 'never be report coverage with reporting_frequency of 0' do
31
50
  request = Rack::MockRequest.env_for('/anything.json')
32
51
  Coverband::Collectors::Coverage.instance.reset_instance
@@ -10,7 +10,51 @@ class RailsFullStackTest < ActionDispatch::IntegrationTest
10
10
  test 'this is how we do it' do
11
11
  get '/dummy/show'
12
12
  assert_response :success
13
- assert_equal "I am no dummy", response.body
13
+ assert_equal 'I am no dummy', response.body
14
14
  assert_equal [1, 1, 1, nil, nil], Coverband.configuration.store.coverage["#{Rails.root}/app/controllers/dummy_controller.rb"]
15
15
  end
16
+
17
+ ###
18
+ # Please keep this test starting on line 22
19
+ # as we run it in single test mode via the benchmarks.
20
+ # Add new tests below this test
21
+ ###
22
+ test 'memory usage' do
23
+ return unless ENV['COVERBAND_MEMORY_TEST']
24
+ # we don't want this to run during our standard test suite
25
+ # as the below profiler changes the runtime
26
+ # and shold only be included for isolated processes
27
+ begin
28
+ require 'memory_profiler'
29
+
30
+ # warmup
31
+ 3.times do
32
+ get '/dummy/show'
33
+ assert_response :success
34
+ Coverband::Collectors::Coverage.instance.report_coverage(true)
35
+ end
36
+
37
+ previous_out = $stdout
38
+ capture = StringIO.new
39
+ $stdout = capture
40
+
41
+ MemoryProfiler.report do
42
+ 15.times do
43
+ get '/dummy/show'
44
+ assert_response :success
45
+ Coverband::Collectors::Coverage.instance.report_coverage(true)
46
+ # this is expected to retain memory across requests
47
+ # clear it to remove the false positive from test
48
+ Coverband::Collectors::Coverage.instance.send(:add_previous_results, nil)
49
+ end
50
+ end.pretty_print
51
+ data = $stdout.string
52
+ $stdout = previous_out
53
+ if data.match(/retained objects by gem(.*)retained objects by file/m)[0]&.match(/coverband/)
54
+ raise 'leaking memory!!!'
55
+ end
56
+ ensure
57
+ $stdout = previous_out
58
+ end
59
+ end
16
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-21 00:00:00.000000000 Z
11
+ date: 2018-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -53,21 +53,21 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: mocha
56
+ name: m
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.14.0
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.14.0
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rack
70
+ name: memory_profiler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,21 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rack-test
84
+ name: mocha
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.14.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.14.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: rake
98
+ name: rack
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: redis
112
+ name: rack-test
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: test-unit
126
+ name: rake
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: m
140
+ name: test-unit
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: memory_profiler
154
+ name: classifier-reborn
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: classifier-reborn
168
+ name: pry-byebug
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -179,13 +179,13 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: pry-byebug
182
+ name: redis
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
- type: :development
188
+ type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
@@ -239,6 +239,7 @@ files:
239
239
  - lib/coverband/reporters/console_report.rb
240
240
  - lib/coverband/reporters/simple_cov_report.rb
241
241
  - lib/coverband/reporters/web.rb
242
+ - lib/coverband/utils/railtie.rb
242
243
  - lib/coverband/utils/s3_report.rb
243
244
  - lib/coverband/utils/tasks.rb
244
245
  - lib/coverband/version.rb
@@ -295,12 +296,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
295
296
  version: '0'
296
297
  required_rubygems_version: !ruby/object:Gem::Requirement
297
298
  requirements:
298
- - - ">="
299
+ - - ">"
299
300
  - !ruby/object:Gem::Version
300
- version: '0'
301
+ version: 1.3.1
301
302
  requirements: []
302
303
  rubyforge_project:
303
- rubygems_version: 2.5.1
304
+ rubygems_version: 2.7.3
304
305
  signing_key:
305
306
  specification_version: 4
306
307
  summary: Rack middleware to help measure production code usage (LOC runtime usage)