coverband 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +30 -1
- data/Rakefile +4 -1
- data/coverband.gemspec +5 -4
- data/lib/coverband/reporter.rb +3 -1
- data/lib/coverband/version.rb +1 -1
- data/test/unit/base_test.rb +0 -1
- data/test/unit/reporter_test.rb +21 -1
- metadata +30 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e98fd5cb692315012eaf942729c5dda8733dc1f2
|
4
|
+
data.tar.gz: f5aa2c9ed5c11d804a5849f17044c557545adb02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 520f5f7d174cbb4839b8d2aa8a763c5810efcc5102d32e0891ca1923a7cdf2a87183d6267cd24576159001f1829b7ac8eed4eddbc1d3f2eb196285d78adc80ea
|
7
|
+
data.tar.gz: 1398b2283ba65698d8ce5040b69742e365c3cf9c26a52300322baff70fad708e65152531487dec576ec4a8030fc6b1e1542645f21bb3c32f1d868d3eb16431d2
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -39,6 +39,19 @@ Or install it yourself as:
|
|
39
39
|
$ gem install coverband
|
40
40
|
```
|
41
41
|
|
42
|
+
That gives you the gem, but to get up and running then follow:
|
43
|
+
|
44
|
+
* [Coverband Configuration](https://github.com/danmayer/coverband#configuration)
|
45
|
+
* Rake integration
|
46
|
+
* Coverband config setup
|
47
|
+
* Require Coverband
|
48
|
+
* Insert middleware in stack
|
49
|
+
* run `bundle exec rake coverband:baseline` ([what is baseline?](https://github.com/danmayer/coverband#coverband-baseline))
|
50
|
+
* run `bundle exec rake coverband:coverage` this will show app initialization coverage
|
51
|
+
* run app and hit a controller (hit at least +1 time over your `config.startup_delay` setting default is 2)
|
52
|
+
* run `bundle exec rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
|
53
|
+
|
54
|
+
|
42
55
|
## Example Output
|
43
56
|
|
44
57
|
Since Coverband is [Simplecov](https://github.com/colszowka/simplecov) output compatible it should work with any of the `SimpleCov::Formatter`'s available. The output below is produced using the default Simplecov HTML formatter.
|
@@ -51,7 +64,13 @@ Details on a example Sinatra app
|
|
51
64
|
|
52
65
|
## Notes
|
53
66
|
|
54
|
-
* Coverband has been used on large scale production websites without large impacts on performance. Adjusting the
|
67
|
+
* Coverband has been used on large scale production websites without large impacts on performance. Adjusting the sample rate to achieve an acceptable trade-off on detailed information vs performance impact. Coverband started as a Ruby 1.9 project and the performance impact has been reduced by each Ruby release since.
|
68
|
+
|
69
|
+
## Coverband Baseline
|
70
|
+
|
71
|
+
__TLDR:__ Baseline is app initialization coverage, not captured during runtime.
|
72
|
+
|
73
|
+
The baseline seems to cause some confusion. Basically, when Coverband records code usage, it will not request initial startup code like method definition, it covers what it hit during run time. This would produce a fairly odd view of code usage. To cover things like defining routes, dynamic methods, and the like Coverband records a baseline. The baseline should capture coverage of app initialization and boot up, we don't want to do this on deploy as it can be slow. So we take a recording of boot up as a one time baseline Rake task `bundle exec rake coverband:baseline`.
|
55
74
|
|
56
75
|
## Configuration
|
57
76
|
|
@@ -73,6 +92,7 @@ Coverband.configure do |config|
|
|
73
92
|
config.ignore = ['vendor','lib/scrazy_i18n_patch_thats_hit_all_the_time.rb']
|
74
93
|
# Since rails and other frameworks lazy load code. I have found it is bad to allow
|
75
94
|
# initial requests to record with coverband. This ignores first 15 requests
|
95
|
+
# NOTE: If you are using a threaded webserver (example: Puma) this will ignore requests for each thread
|
76
96
|
config.startup_delay = Rails.env.production? ? 15 : 2
|
77
97
|
# Percentage of requests recorded
|
78
98
|
config.percentage = Rails.env.production? ? 30.0 : 100.0
|
@@ -290,6 +310,15 @@ Coverband::Reporter.report :additional_scov_data => [data]
|
|
290
310
|
|
291
311
|
You can also pass a `:additional_scov_data => [data]` option to `Coverband::Reporter.get_current_scov_data` to write out merged data.
|
292
312
|
|
313
|
+
### Coverband development
|
314
|
+
|
315
|
+
If you are working on adding features, PRs, or bugfixes to Coverband this section should help get you going.
|
316
|
+
|
317
|
+
* run tests: `bundle exec rake`
|
318
|
+
* view test coverage: `open coverage/index.html`
|
319
|
+
* run the benchmarks before and after your change to see impact
|
320
|
+
* `bundle exec rake benchmarks`
|
321
|
+
|
293
322
|
### Known issues
|
294
323
|
|
295
324
|
* If you don't have a baseline recorded your coverage can look odd like you are missing a bunch of data. It would be good if Coverband gave a more actionable warning in this situation.
|
data/Rakefile
CHANGED
@@ -6,6 +6,9 @@ task :default => :test
|
|
6
6
|
require 'rake/testtask'
|
7
7
|
Rake::TestTask.new(:test) do |test|
|
8
8
|
test.libs << 'lib' << 'test'
|
9
|
-
|
9
|
+
# exclude benchmark from the tests as the way it functions resets code coverage during executions
|
10
|
+
#test.pattern = 'test/unit/*_test.rb'
|
11
|
+
# using test files opposed to pattern as it outputs which files are run
|
12
|
+
test.test_files = FileList['test/unit/*_test.rb']
|
10
13
|
test.verbose = true
|
11
14
|
end
|
data/coverband.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Coverband::VERSION
|
9
9
|
spec.authors = ["Dan Mayer"]
|
10
10
|
spec.email = ["dan@mayerdan.com"]
|
11
|
-
spec.description = %q{Rack middleware to help measure production code
|
12
|
-
spec.summary = %q{Rack middleware to help measure production code
|
13
|
-
spec.homepage = ""
|
11
|
+
spec.description = %q{Rack middleware to help measure production code usage (LOC runtime usage)}
|
12
|
+
spec.summary = %q{Rack middleware to help measure production code usage (LOC runtime usage)}
|
13
|
+
spec.homepage = "https://github.com/danmayer/coverband"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -24,9 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "rack"
|
25
25
|
spec.add_development_dependency "rack-test"
|
26
26
|
spec.add_development_dependency "test-unit"
|
27
|
+
spec.add_development_dependency 'sinatra'
|
28
|
+
spec.add_development_dependency 'classifier-reborn'
|
27
29
|
spec.add_runtime_dependency "simplecov"
|
28
30
|
spec.add_runtime_dependency "json"
|
29
31
|
spec.add_runtime_dependency "redis"
|
30
32
|
spec.add_runtime_dependency 'aws-sdk', '~> 2'
|
31
|
-
spec.add_runtime_dependency 'sinatra'
|
32
33
|
end
|
data/lib/coverband/reporter.rb
CHANGED
@@ -146,7 +146,9 @@ module Coverband
|
|
146
146
|
Coverband.configuration.logger.info scov_style_report.inspect
|
147
147
|
end
|
148
148
|
|
149
|
-
|
149
|
+
# add in files never hit in coverband
|
150
|
+
SimpleCov.track_files "#{current_root}/{app,lib,config}/**/*.{rb,haml,erb,slim}"
|
151
|
+
SimpleCov::Result.new(SimpleCov.add_not_loaded_files(scov_style_report)).format!
|
150
152
|
if open_report
|
151
153
|
`open #{SimpleCov.coverage_dir}/index.html`
|
152
154
|
else
|
data/lib/coverband/version.rb
CHANGED
data/test/unit/base_test.rb
CHANGED
@@ -8,7 +8,6 @@ class BaseTest < Test::Unit::TestCase
|
|
8
8
|
assert_equal Coverband::RedisStore, coverband.instance_variable_get('@reporter').class
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
11
|
test 'configure memory caching' do
|
13
12
|
Coverband.configuration.memory_caching = true
|
14
13
|
coverband = Coverband::Base.instance.reset_instance
|
data/test/unit/reporter_test.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
3
3
|
class ReporterTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
test "record baseline" do
|
6
|
-
Coverage.expects(:start).at_least_once
|
6
|
+
Coverage.expects(:start).returns(true).at_least_once
|
7
7
|
Coverage.expects(:result).returns({'fake' => [0,1]}).at_least_once
|
8
8
|
File.expects(:open).once
|
9
9
|
|
@@ -37,6 +37,26 @@ class ReporterTest < Test::Unit::TestCase
|
|
37
37
|
Coverband::Reporter.report
|
38
38
|
end
|
39
39
|
|
40
|
+
test "report data with scov" do
|
41
|
+
Coverband.configure do |config|
|
42
|
+
config.redis = fake_redis
|
43
|
+
config.reporter = 'scov'
|
44
|
+
config.s3_bucket = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
Coverband::Reporter.expects(:current_root).at_least_once.returns('/root_dir')
|
48
|
+
fake_redis.expects(:smembers).with('coverband').returns(fake_coverband_members)
|
49
|
+
|
50
|
+
fake_coverband_members.each do |key|
|
51
|
+
File.expects(:exists?).with(key).returns(true)
|
52
|
+
File.expects(:foreach).with(key).returns(['a','b','c'])
|
53
|
+
fake_redis.expects(:smembers).with("coverband.#{key}").returns(["54", "55"])
|
54
|
+
end
|
55
|
+
|
56
|
+
Coverband.configuration.logger.stubs('info')
|
57
|
+
|
58
|
+
Coverband::Reporter.report(open_report: false)
|
59
|
+
end
|
40
60
|
|
41
61
|
####
|
42
62
|
# TODO
|
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: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,13 +95,13 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: sinatra
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
|
-
type: :
|
104
|
+
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
@@ -109,13 +109,13 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: classifier-reborn
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
|
-
type: :
|
118
|
+
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -137,21 +137,21 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: json
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '0'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: redis
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
@@ -164,7 +164,21 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
-
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: aws-sdk
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '2'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2'
|
181
|
+
description: Rack middleware to help measure production code usage (LOC runtime usage)
|
168
182
|
email:
|
169
183
|
- dan@mayerdan.com
|
170
184
|
executables: []
|
@@ -206,7 +220,7 @@ files:
|
|
206
220
|
- test/unit/reporter_test.rb
|
207
221
|
- test/unit/s3_report_writer_test.rb
|
208
222
|
- test/unit/s3_web_test.rb
|
209
|
-
homepage:
|
223
|
+
homepage: https://github.com/danmayer/coverband
|
210
224
|
licenses:
|
211
225
|
- MIT
|
212
226
|
metadata: {}
|
@@ -229,7 +243,7 @@ rubyforge_project:
|
|
229
243
|
rubygems_version: 2.5.1
|
230
244
|
signing_key:
|
231
245
|
specification_version: 4
|
232
|
-
summary: Rack middleware to help measure production code
|
246
|
+
summary: Rack middleware to help measure production code usage (LOC runtime usage)
|
233
247
|
test_files:
|
234
248
|
- test/benchmarks/.gitignore
|
235
249
|
- test/benchmarks/benchmark.rake
|