coverband 4.0.1 → 4.2.0
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 +5 -5
- data/.gitignore +6 -1
- data/.travis.yml +8 -2
- data/Gemfile +2 -0
- data/Gemfile.rails4 +2 -0
- data/README.md +135 -157
- data/Rakefile +1 -1
- data/changes.md +56 -5
- data/coverband.gemspec +5 -3
- data/lib/coverband/adapters/base.rb +44 -11
- data/lib/coverband/adapters/file_store.rb +8 -0
- data/lib/coverband/adapters/redis_store.rb +65 -8
- data/lib/coverband/at_exit.rb +37 -0
- data/lib/coverband/collectors/coverage.rb +43 -72
- data/lib/coverband/collectors/delta.rb +67 -0
- data/lib/coverband/configuration.rb +71 -2
- data/lib/coverband/integrations/background.rb +9 -10
- data/lib/coverband/integrations/middleware.rb +3 -2
- data/lib/coverband/integrations/rack_server_check.rb +4 -1
- data/lib/coverband/integrations/resque.rb +27 -0
- data/lib/coverband/reporters/base.rb +24 -36
- data/lib/coverband/reporters/html_report.rb +40 -15
- data/lib/coverband/reporters/web.rb +52 -10
- data/lib/coverband/utils/file_groups.rb +53 -0
- data/lib/coverband/utils/file_path_helper.rb +57 -0
- data/lib/coverband/utils/gem_list.rb +31 -0
- data/lib/coverband/utils/html_formatter.rb +50 -8
- data/lib/coverband/utils/railtie.rb +9 -1
- data/lib/coverband/utils/result.rb +16 -19
- data/lib/coverband/utils/results.rb +63 -0
- data/lib/coverband/utils/source_file.rb +23 -1
- data/lib/coverband/utils/tasks.rb +17 -17
- data/lib/coverband/version.rb +1 -1
- data/lib/coverband.rb +32 -2
- data/public/application.css +5 -0
- data/public/application.js +117 -1640
- data/public/dependencies.js +1581 -0
- data/public/favicon.png +0 -0
- data/test/benchmarks/benchmark.rake +36 -1
- data/test/benchmarks/coverage_fork.sh +37 -0
- data/test/{unit/adapters_base_test.rb → coverband/adapters/base_test.rb} +1 -1
- data/test/{unit/adapters_file_store_test.rb → coverband/adapters/file_store_test.rb} +1 -1
- data/test/{unit/adapters_redis_store_test.rb → coverband/adapters/redis_store_test.rb} +28 -11
- data/test/coverband/at_exit_test.rb +13 -0
- data/test/coverband/collectors/coverage_test.rb +73 -0
- data/test/coverband/collectors/delta_test.rb +52 -0
- data/test/coverband/configuration_test.rb +67 -0
- data/test/{unit → coverband}/coverband_test.rb +7 -0
- data/test/coverband/integrations/background_test.rb +31 -0
- data/test/{unit → coverband/integrations}/middleware_test.rb +3 -2
- data/test/{unit/rack_server_checkout_test.rb → coverband/integrations/rack_server_check_test.rb} +1 -1
- data/test/coverband/integrations/resque_worker_test.rb +42 -0
- data/test/coverband/integrations/test_resque_job.rb +7 -0
- data/test/coverband/reporters/base_test.rb +168 -0
- data/test/{unit/reports_console_test.rb → coverband/reporters/console_test.rb} +8 -7
- data/test/coverband/reporters/html_test.rb +45 -0
- data/test/coverband/reporters/web_test.rb +52 -0
- data/test/coverband/utils/file_groups_test.rb +55 -0
- data/test/{unit → coverband}/utils/file_list_test.rb +1 -1
- data/test/coverband/utils/gem_list_test.rb +48 -0
- data/test/{unit → coverband}/utils/source_file_test.rb +1 -1
- data/test/{unit → integration}/full_stack_test.rb +25 -12
- data/test/{unit → integration}/rails_full_stack_test.rb +27 -7
- data/test/rails4_dummy/config/application.rb +1 -1
- data/test/rails4_dummy/config/coverband.rb +4 -1
- data/test/rails4_dummy/tmp/.keep +0 -0
- data/test/rails5_dummy/config/application.rb +1 -1
- data/test/rails5_dummy/config/coverband.rb +3 -1
- data/test/rails5_dummy/tmp/.keep +0 -0
- data/test/rails_test_helper.rb +13 -8
- data/test/test_helper.rb +12 -17
- data/test/unique_files.rb +23 -0
- data/views/file_list.erb +33 -20
- data/views/gem_list.erb +54 -0
- data/views/layout.erb +13 -4
- data/views/settings.erb +35 -0
- data/views/source_file.erb +16 -4
- data/views/source_file_loader.erb +7 -0
- metadata +108 -62
- data/test/unit/background_test.rb +0 -29
- data/test/unit/collectors_coverage_test.rb +0 -48
- data/test/unit/configuration_test.rb +0 -23
- data/test/unit/reports_base_test.rb +0 -109
- data/test/unit/reports_html_test.rb +0 -29
- data/test/unit/reports_web_test.rb +0 -39
- /data/test/{unit → coverband}/utils/lines_classifier_test.rb +0 -0
- /data/test/{unit → coverband}/utils/result_test.rb +0 -0
- /data/test/{unit → coverband}/utils/s3_report_test.rb +0 -0
- /data/test/{unit → coverband}/utils/source_file_line_test.rb +0 -0
- /data/test/{unit/dog.rb → dog.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1e214b1bd6119046657daa64ed6d69f77f821c6c670b72e98d307ede5f08e61f
|
|
4
|
+
data.tar.gz: 469d9470799f90b5b52d53d3a630fae75b3b6bff0390375987902331878f530e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1b0f503941ab9dbc2dee6a184fe6d6d937a5f505a5c9112ae7343197372586d6cb42df758f24effde0ee30fb359c0e2e651c64a1f5ee4c9a588a4499683dc73
|
|
7
|
+
data.tar.gz: ee700abfe4c730011dcc5c1c8521f55a2cc7ec5149e44b08187c8d09419023160a0f7c8aaba4b2aa0bb405eb13f4aeee1d8ce9cabce4860738d4ea94cac63c04
|
data/.gitignore
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
.yardoc
|
|
6
6
|
.idea/
|
|
7
7
|
.ruby-version
|
|
8
|
+
assets/.DS_Store
|
|
9
|
+
.DS_Store
|
|
8
10
|
Gemfile*lock
|
|
9
11
|
InstalledFiles
|
|
10
12
|
_yardoc
|
|
@@ -16,7 +18,10 @@ rdoc
|
|
|
16
18
|
spec/reports
|
|
17
19
|
test/tmp
|
|
18
20
|
test/version_tmp
|
|
19
|
-
tmp
|
|
21
|
+
/tmp/
|
|
22
|
+
temp_results
|
|
20
23
|
.byebug_history
|
|
21
24
|
.env
|
|
22
25
|
log/
|
|
26
|
+
test/unique_files
|
|
27
|
+
test/rails5_dummy/tmp
|
data/.travis.yml
CHANGED
|
@@ -3,11 +3,17 @@ rvm:
|
|
|
3
3
|
- "2.3"
|
|
4
4
|
- "2.4"
|
|
5
5
|
- "2.5"
|
|
6
|
-
- "2.6"
|
|
6
|
+
- "2.6.1"
|
|
7
7
|
gemfile:
|
|
8
8
|
- Gemfile
|
|
9
9
|
- Gemfile.rails4
|
|
10
10
|
services:
|
|
11
11
|
- redis-server
|
|
12
12
|
before_install:
|
|
13
|
-
-
|
|
13
|
+
- echo 'this is a hack to clear default bundler and force bundler 1.17.3'
|
|
14
|
+
- ls /home/travis/.rvm/gems/
|
|
15
|
+
- rm /home/travis/.rvm/gems/ruby-2.3.7@global/specifications/bundler-2.0.1.gemspec || true
|
|
16
|
+
- rm /home/travis/.rvm/gems/ruby-2.5.4@global/specifications/bundler-2.0.1.gemspec || true
|
|
17
|
+
- gem uninstall bundler || true
|
|
18
|
+
- gem install bundler -v '1.17.3'
|
|
19
|
+
- bundler --version
|
data/Gemfile
CHANGED
data/Gemfile.rails4
CHANGED
data/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<img src="https://raw.github.com/danmayer/coverband/master/docs/assets/logo/heads.svg?sanitize=true" width='300'>
|
|
2
|
+
|
|
1
3
|
# Coverband
|
|
2
4
|
|
|
3
5
|
[](https://travis-ci.org/danmayer/coverband)
|
|
@@ -6,32 +8,39 @@
|
|
|
6
8
|
<p align="center">
|
|
7
9
|
<a href="#key-features">Key Features</a> •
|
|
8
10
|
<a href="#installation">Installation</a> •
|
|
9
|
-
<a href="#
|
|
10
|
-
<a href="#
|
|
11
|
-
<a href="#
|
|
11
|
+
<a href="#coverage-report">Coverage Report</a> •
|
|
12
|
+
<a href="#verify-correct-installation">Verify Correct Installation</a> •
|
|
13
|
+
<a href="#advanced-config">Advanced Config</a> •
|
|
12
14
|
<a href="#license">License</a> •
|
|
13
15
|
<a href="/changes.md">Change Log / Roadmap</a>
|
|
14
16
|
</p>
|
|
15
17
|
|
|
16
18
|
A gem to measure production code usage, showing a counter for the number of times each line of code that is executed. Coverband allows easy configuration to collect and report on production code usage. It reports in the background via a thread or can be used as Rack middleware, or manually configured to meet any need.
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
**Note:** Coverband is not intended for test code coverage, for that we recommended using [SimpleCov](https://github.com/colszowka/simplecov).
|
|
19
21
|
|
|
20
22
|
## Key Features
|
|
21
23
|
|
|
22
24
|
The primary goal of Coverband is giving deep insight into your production runtime usage of your application code, while having the least impact on performance possible.
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
- Low performance overhead
|
|
27
|
+
- Very simple setup and configuration
|
|
28
|
+
- Out of the box support for all standard code execution paths (web, cron, background jobs, rake tasks, etc)
|
|
29
|
+
- Easy to understand actionable insights from the report
|
|
30
|
+
- Development mode, offers deep insight of code usage details (number of LOC execution during single request, etc) during development.
|
|
31
|
+
- Mountable web interface to easily share reports
|
|
31
32
|
|
|
32
33
|
# Installation
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
## Redis
|
|
36
|
+
|
|
37
|
+
Coverband stores coverage data in Redis. The Redis endpoint is looked for in this order:
|
|
38
|
+
|
|
39
|
+
1. `ENV['COVERBAND_REDIS_URL']`
|
|
40
|
+
2. `ENV['REDIS_URL']`
|
|
41
|
+
3. `localhost`
|
|
42
|
+
|
|
43
|
+
The redis store can also be explicitly defined within the coverband.rb. See [advanced config](#advanced-config).
|
|
35
44
|
|
|
36
45
|
## Gem Installation
|
|
37
46
|
|
|
@@ -41,12 +50,11 @@ Add this line to your application's `Gemfile`, remember to `bundle install` afte
|
|
|
41
50
|
gem 'coverband'
|
|
42
51
|
```
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
If [tracking gem usage](#collecting-gem--library-usage), be sure to include coverband before other gems you would like to track.
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
## Rails
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
* Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
|
|
57
|
+
The Railtie integration means you shouldn't need to do anything anything else other than ensure coverband is required after rails within your Gemfile.
|
|
50
58
|
|
|
51
59
|
## Sinatra
|
|
52
60
|
|
|
@@ -60,137 +68,88 @@ use Coverband::Middleware
|
|
|
60
68
|
run ActionController::Dispatcher.new
|
|
61
69
|
```
|
|
62
70
|
|
|
63
|
-
# Report
|
|
64
|
-
|
|
65
|
-
There are two primary ways to generate and view the report
|
|
66
|
-
|
|
67
|
-
## Rake Tasks
|
|
71
|
+
# Coverage Report
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
Coverband comes with a mountable rack app for viewing reports. For Rails this can be done in `config/routes.rb` with:
|
|
70
74
|
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
```ruby
|
|
76
|
+
Rails.application.routes.draw do
|
|
77
|
+
mount Coverband::Reporters::Web.new, at: '/coverage'
|
|
78
|
+
end
|
|
75
79
|
```
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
`rake coverband:coverage`
|
|
80
|
-
|
|
81
|
-
This should auto-open in your browser, but if it doesn't the output file should be in `coverage/index.html`
|
|
81
|
+
But don't forget to _protect your source code with proper authentication_. Something like this when using devise:
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
First setup Coverband to [write reports to S3](#writing-coverband-results-to-s3) you can host the S3 file with a built in rack app in Coverband. Just configure your Rails route `config/routes.rb`
|
|
86
|
-
|
|
87
|
-
```
|
|
83
|
+
```ruby
|
|
88
84
|
Rails.application.routes.draw do
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
authenticate :user, lambda { |u| u.admin? } do
|
|
86
|
+
mount Coverband::Reporters::Web.new, at: '/coverage'
|
|
87
|
+
end
|
|
91
88
|
end
|
|
92
89
|
```
|
|
93
90
|
|
|
94
|
-
|
|
91
|
+
### Coverband Web Endpoint
|
|
95
92
|
|
|
96
|
-
|
|
93
|
+
The web endpoint is a barebones endpoint that you can either expose direct (after authentication) or you can just link to the actions you wish to expose. The index is intended as a example to showcase all the features.
|
|
97
94
|
|
|
98
|
-
|
|
99
|
-
# protect with existing Rails devise configuration
|
|
100
|
-
devise_constraint = lambda do |request|
|
|
101
|
-
request.env['warden'] && request.env['warden'].authenticate? && request.env['warden'].user.admin?
|
|
102
|
-
end
|
|
95
|
+

|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
# curl --user foo:bar http://localhost:3000/coverage
|
|
106
|
-
Rails.application.routes.draw do
|
|
107
|
-
# ... lots of routes
|
|
97
|
+
> The web index as available on the Coverband Demo site
|
|
108
98
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
username == 'foo' && password == 'bar'
|
|
113
|
-
end
|
|
99
|
+
- **force coverage collection:** This triggers coverage collection on the current webserver process
|
|
100
|
+
- **reload Coverband files:** This has Coverband reload files as configured (force reload of some files that might not capture Coverage on boot). This can be used to reload files on demand.
|
|
101
|
+
- **clear coverage report:** This will clear the coverage data. This wipes out all collected data (**dangerous**)
|
|
114
102
|
|
|
115
|
-
|
|
116
|
-
end
|
|
103
|
+
### Rake Tasks
|
|
117
104
|
|
|
118
|
-
|
|
119
|
-
mount AuthenticatedCoverband, at: '/coverage'
|
|
120
|
-
end
|
|
121
|
-
```
|
|
105
|
+
The rake task generates a report locally and opens a browser pointing to `coverage/index.html`.
|
|
122
106
|
|
|
123
|
-
|
|
107
|
+
`rake coverband:coverage`
|
|
124
108
|
|
|
125
|
-
|
|
126
|
-
* run app and hit a controller (via a web request, at least one request must complete)
|
|
127
|
-
* run `rake coverband:coverage` this will show app initialization coverage
|
|
128
|
-
* make another request, or enough that your reporting frequency will trigger
|
|
129
|
-
* run `rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
|
|
109
|
+
This is mostly useful in your local development environment.
|
|
130
110
|
|
|
131
|
-
|
|
111
|
+
##### Example Output
|
|
132
112
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
# How To Use
|
|
113
|
+
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.
|
|
136
114
|
|
|
137
|
-
|
|
115
|
+
Index Page
|
|
116
|
+

|
|
138
117
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* Validate data collection and code coverage with `rake coverband:coverage`
|
|
142
|
-
* If you see app startup and recent visits showing, setup is correct
|
|
143
|
-
* I generally configure the mountable web endpoint to [view the data via the web-app](https://github.com/danmayer/coverband#viewing--hosting-s3-coverband-results-in-app)
|
|
144
|
-
* After Coverband has been verified to be working on production, I let it run for a few weeks.
|
|
145
|
-
* Then I view the report and start submitting PRs for the team to review delete large related sets of code that no longer are in use.
|
|
118
|
+
Details on an example Sinatra app
|
|
119
|
+

|
|
146
120
|
|
|
147
|
-
|
|
121
|
+
# Verify Correct Installation
|
|
148
122
|
|
|
149
|
-
|
|
123
|
+
- boot up your application
|
|
124
|
+
- run app and hit a controller (via a web request, at least one request must complete)
|
|
125
|
+
- run `rake coverband:coverage` this will show app initialization coverage
|
|
126
|
+
- make another request, or enough that your reporting frequency will trigger
|
|
127
|
+
- run `rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
|
|
150
128
|
|
|
151
|
-
|
|
152
|
-
> The web index as available on the Coverband Demo site
|
|
129
|
+
# Coverband Demo
|
|
153
130
|
|
|
154
|
-
|
|
155
|
-
* it triggers a coverage collection on the current webserver process
|
|
156
|
-
* it generates a new html coverage report and pushes it to S3
|
|
157
|
-
* it then loads that report for you to view
|
|
158
|
-
* __view coverage report:__ Don't need to update the data just view the current report
|
|
159
|
-
* __update coverage data (collect coverage):__ This triggers coverage collection on the current webserver process
|
|
160
|
-
* __update coverage report (rebuild report):__ This will rebuild the HTML report from the latest available data
|
|
161
|
-
* __clear coverage report:__ This will clear the coverage data. This wipes out all collected data (__dangerous__)
|
|
162
|
-
* __reload Coverband files:__ This has Coverband reload files as configured (force reload of some files that might not capture Coverage on boot)
|
|
131
|
+
Take Coverband for a spin on the live Heroku deployed [Coverband Demo](https://coverband-demo.herokuapp.com/). The [full source code for the demo](https://github.com/danmayer/coverband_demo) is available to help with installation, configuration, and understanding of basic usage.
|
|
163
132
|
|
|
164
133
|
### Example apps
|
|
165
134
|
|
|
166
|
-
- [Rails 5.2.x App](https://github.com/danmayer/
|
|
135
|
+
- [Rails 5.2.x App](https://github.com/danmayer/coverband_demo)
|
|
167
136
|
- [Sinatra app](https://github.com/danmayer/churn-site)
|
|
168
137
|
- [Non Rack Ruby app](https://github.com/danmayer/coverband_examples)
|
|
169
138
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
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.
|
|
173
|
-
|
|
174
|
-
Index Page
|
|
175
|
-

|
|
176
|
-
|
|
177
|
-
Details on a example Sinatra app
|
|
178
|
-

|
|
179
|
-
|
|
180
|
-
### Advanced Coverband Config
|
|
139
|
+
# Advanced Config
|
|
181
140
|
|
|
182
|
-
|
|
141
|
+
If you need to configure coverband, this can be done by creating a `config/coverband.rb` file relative to your project root.
|
|
183
142
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
* By default Coverband will try to stored data to Redis
|
|
187
|
-
* Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
|
|
143
|
+
- See [lib/coverband/configuration.rb](https://github.com/danmayer/coverband/blob/master/lib/coverband/configuration.rb) for all options
|
|
144
|
+
- By default Coverband will try to stored data to Redis \* Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
|
|
188
145
|
|
|
189
|
-
|
|
146
|
+
Below is an example config file for a Rails 5 app:
|
|
190
147
|
|
|
191
148
|
```ruby
|
|
192
149
|
#config/coverband.rb
|
|
193
150
|
Coverband.configure do |config|
|
|
151
|
+
config.store = Coverband::Adapters::RedisStore.new(Redis.new(url: ENV['MY_REDIS_URL']))
|
|
152
|
+
config.logger = Rails.logger
|
|
194
153
|
# configure S3 integration
|
|
195
154
|
config.s3_bucket = 'coverband-demo'
|
|
196
155
|
config.s3_region = 'us-east-1'
|
|
@@ -205,6 +164,20 @@ Coverband.configure do |config|
|
|
|
205
164
|
end
|
|
206
165
|
```
|
|
207
166
|
|
|
167
|
+
### Ignoring Files
|
|
168
|
+
|
|
169
|
+
Sometimes you have files that are known to be valuable perhaps in other environments or something that is just run very infrequently. Opposed to having to mentally filter them out of the report, you can just have them ignored in the Coverband reporting by using `config.ignore` as shown below. Ignore takes a string but can also match with regex rules see how below ignores all rake tasks as an example.
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
config.ignore += ['config/application.rb',
|
|
173
|
+
'config/boot.rb',
|
|
174
|
+
'config/puma.rb',
|
|
175
|
+
'config/schedule.rb',
|
|
176
|
+
'bin/*'
|
|
177
|
+
'config/environments/*',
|
|
178
|
+
'lib/tasks/*']
|
|
179
|
+
```
|
|
180
|
+
|
|
208
181
|
### Writing Coverband Results to S3
|
|
209
182
|
|
|
210
183
|
If you add some additional Coverband configuration your coverage html report will be written directly to S3, update `config/coverband.rb` like below.
|
|
@@ -226,9 +199,17 @@ ENV['AWS_ACCESS_KEY_ID']
|
|
|
226
199
|
ENV['AWS_SECRET_ACCESS_KEY']
|
|
227
200
|
```
|
|
228
201
|
|
|
202
|
+
### Coverage Data Migration
|
|
203
|
+
|
|
204
|
+
Between the release of 4.0 and 4.1 our data format changed. This resets all your coverage data. If you want to restore your previous coverage data, feel free to migrate.
|
|
205
|
+
|
|
206
|
+
`rake coverband:migrate`
|
|
207
|
+
|
|
208
|
+
- We will be working to support migrations going forward, when possible
|
|
209
|
+
|
|
229
210
|
### Clear Coverage
|
|
230
211
|
|
|
231
|
-
Now that Coverband uses MD5 hashes there should be no reason to manually clear coverage unless one is testing, changing versions, possibly debugging
|
|
212
|
+
Now that Coverband uses MD5 hashes there should be no reason to manually clear coverage unless one is testing, changing versions, possibly debugging Coverband itself.
|
|
232
213
|
|
|
233
214
|
`rake coverband:clear`
|
|
234
215
|
|
|
@@ -254,9 +235,9 @@ rake coverband:coverage # report runtime coverband code coverage
|
|
|
254
235
|
|
|
255
236
|
### Forcing Coverband to Track Coverage on files loaded during boot `safe_reload_files`
|
|
256
237
|
|
|
257
|
-
|
|
238
|
+
Coverband will report code usage for anything `required` or `loaded` after calling `Coverband.start` which happens automatically when coverband is required. This means some of the files loaded before coverband such as the Rails application.rb will be reported as having no coverage.
|
|
258
239
|
|
|
259
|
-
The `safe_reload_files` reload option in the configuration options can help to ensure you can track any files
|
|
240
|
+
The `safe_reload_files` reload option in the configuration options can help to ensure you can track any files regardless of loading before Coverband. For example if I wanted to show the coverage of `config/coverband.rb`, which has to be loaded before calling `Coverband.start`, I could do that by adding that path to the `safe_reload_files` option.
|
|
260
241
|
|
|
261
242
|
```
|
|
262
243
|
Coverband.configure do |config|
|
|
@@ -265,21 +246,44 @@ Coverband.configure do |config|
|
|
|
265
246
|
config.safe_reload_files = ['config/coverband.rb']
|
|
266
247
|
end
|
|
267
248
|
```
|
|
268
|
-
By adding any files above you will get reporting on those files as part of your coverage runtime report.
|
|
269
249
|
|
|
250
|
+
By adding any files above you will get reporting on those files as part of your coverage runtime report. The files are reloaded when Coverband first starts, you can also trigger a reload via the web interface.
|
|
270
251
|
|
|
271
252
|
### Collecting Gem / Library Usage
|
|
272
253
|
|
|
273
|
-
|
|
254
|
+
Gem usage can be tracked by enabling the `track_gems` config.
|
|
274
255
|
|
|
275
|
-
|
|
256
|
+
```
|
|
257
|
+
Coverband.configure do |config|
|
|
258
|
+
config.track_gems = true
|
|
259
|
+
end
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The `track_gems` feature exposes a Gems tab in the report which prints out the percentage usage of each Gem. See demo [here](https://coverband-demo.herokuapp.com/coverage?#_Gems).
|
|
276
263
|
|
|
277
|
-
|
|
278
|
-
* --- or ---
|
|
279
|
-
* ensure you call `require 'coverband'` which triggers `Coverband.start` before loading all your gems
|
|
280
|
-
* while possible this is currently hard as Rails and most environments load your whole Gemfile
|
|
281
|
-
* we are looking for an improve and easier way to support this.
|
|
264
|
+
When tracking gems, it is important that `Coverband#start` is called before the gems to be tracked are required. Since `Coverband#start` is automatically called by default when coverband is required, list coverband before the other gems to be tracked within your Gemfile. The exception to this are gems like rails and resque. Since coverband has some specific intergrations for these frameworks, these two gems should be required first.
|
|
282
265
|
|
|
266
|
+
The track_gems config only exposes the overall usage of a gem. In order to see the detail of each file, enable the `gem_details` flag.
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
Coverband.configure do |config|
|
|
270
|
+
config.track_gems = true
|
|
271
|
+
config.gem_details = true
|
|
272
|
+
end
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
This flag exposes line by line usage of gem files. Unfortunately due to the way the coverband report is currently rendered, enabling `gem_details` slows down viewing of the coverage report in the browser and is not yet recommended.
|
|
276
|
+
|
|
277
|
+
### Manually Starting Coverband
|
|
278
|
+
|
|
279
|
+
Coverband starts on require of the the library which is usually done within the Gemfile. This can be disabled by setting the `COVERBAND_DISABLE_AUTO_START` environment variable. This environment variable can be useful to toggle coverband on and off in certain environments.
|
|
280
|
+
|
|
281
|
+
In order to start coverband manually yourself when this flag is enabled, call `Coverband.configure` followed by `Coverband.start`.
|
|
282
|
+
|
|
283
|
+
```ruby
|
|
284
|
+
Coverband.configure
|
|
285
|
+
Coverband.start
|
|
286
|
+
```
|
|
283
287
|
|
|
284
288
|
### Verbose Debug / Development Mode
|
|
285
289
|
|
|
@@ -305,35 +309,10 @@ If you are trying to debug locally wondering what code is being run during a req
|
|
|
305
309
|
...
|
|
306
310
|
[517, 1617], [516, 38577]]
|
|
307
311
|
|
|
308
|
-
|
|
309
|
-
### Conflicting .Simplecov: Issue with Missing or 0% Coverage Report
|
|
310
|
-
|
|
311
|
-
If you use SimpleCov to generate code coverage for your tests. You might have setup a `.simplecov` file to help control and focus it's output. Often the settings you want for your test's code coverage report are different than what you want Coverband to be reporting on. Since Coverband uses the SimpleCov HTML formatter to prepare it's report.
|
|
312
|
-
|
|
313
|
-
So if you had something like this in a `.simplecov` file in the root of your project, as reported in [issue 83](https://github.com/danmayer/coverband/issues/83)
|
|
314
|
-
|
|
315
|
-
```
|
|
316
|
-
require 'simplecov'
|
|
317
|
-
|
|
318
|
-
SimpleCov.start do
|
|
319
|
-
add_filter 'app/admin'
|
|
320
|
-
add_filter '/spec/'
|
|
321
|
-
add_filter '/config/'
|
|
322
|
-
add_filter '/vendor/'
|
|
323
|
-
add_filter 'userevents'
|
|
324
|
-
end
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
You could see some confusing results... To avoid this issue Coverband has a Rake task that will ignore all Simplecov filters.
|
|
328
|
-
|
|
329
|
-
`rake coverband:coverage_no_filters`
|
|
330
|
-
|
|
331
|
-
This will build the report after disabling any `.simplecov` applied settings.
|
|
332
|
-
|
|
333
312
|
# Prerequisites
|
|
334
313
|
|
|
335
|
-
|
|
336
|
-
|
|
314
|
+
- Coverband 3.0.X+ requires Ruby 2.3+
|
|
315
|
+
- Coverband currently requires Redis for production usage
|
|
337
316
|
|
|
338
317
|
# Contributing To Coverband
|
|
339
318
|
|
|
@@ -350,19 +329,18 @@ If you are working on adding features, PRs, or bugfixes to Coverband this sectio
|
|
|
350
329
|
|
|
351
330
|
If you submit a change please make sure the tests and benchmarks are passing.
|
|
352
331
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
332
|
+
- run tests:
|
|
333
|
+
- `bundle exec rake`
|
|
334
|
+
- `BUNDLE_GEMFILE=Gemfile.rails4 bundle exec rake` (Same tests using rails 4 instead of 5)
|
|
335
|
+
- view test coverage: `open coverage/index.html`
|
|
336
|
+
- run the benchmarks before and after your change to see impact
|
|
337
|
+
- `rake benchmarks`
|
|
359
338
|
|
|
360
339
|
### Known Issues
|
|
361
340
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
* coverage doesn't show for Rails `config/application.rb` or `config/boot.rb` as they get loaded when loading the Rake environment prior to starting the `Coverage` library.
|
|
341
|
+
- **total fail** on front end code, because of the precompiled template step basically coverage doesn't work well for `erb`, `slim`, and the like.
|
|
342
|
+
- related it will try to report something, but the line numbers reported for `ERB` files are often off and aren't considered useful. I recommend filtering out .erb using the `config.ignore` option. The default configuration excludes these files
|
|
343
|
+
- coverage doesn't show for Rails `config/application.rb` or `config/boot.rb` as they get loaded when loading the Rake environment prior to starting the `Coverage` library. See [reload files section](#forcing-coverband-to-track-coverage-on-files-loaded-during-boot-safe_reload_files).
|
|
366
344
|
|
|
367
345
|
### Debugging Redis Store
|
|
368
346
|
|
data/Rakefile
CHANGED
|
@@ -13,7 +13,7 @@ Rake::TestTask.new(:test) do |test|
|
|
|
13
13
|
# exclude benchmark from the tests as the way it functions resets code coverage during executions
|
|
14
14
|
# test.pattern = 'test/unit/*_test.rb'
|
|
15
15
|
# using test files opposed to pattern as it outputs which files are run
|
|
16
|
-
test.test_files = FileList['test/
|
|
16
|
+
test.test_files = FileList['test/integration/**/*_test.rb', 'test/coverband/**/*_test.rb']
|
|
17
17
|
test.verbose = true
|
|
18
18
|
end
|
|
19
19
|
|
data/changes.md
CHANGED
|
@@ -24,7 +24,6 @@ Will be the fully modern release that drops maintenance legacy support in favor
|
|
|
24
24
|
- add coverage timerange support
|
|
25
25
|
- Drop Simplecov dependency
|
|
26
26
|
- improved web reporting
|
|
27
|
-
- no longer relying directly on HTML in S3 but dynamically generated from any adapter
|
|
28
27
|
- lists current config options
|
|
29
28
|
- eventually allow updating remote config
|
|
30
29
|
- full theming
|
|
@@ -32,12 +31,22 @@ Will be the fully modern release that drops maintenance legacy support in favor
|
|
|
32
31
|
- additional adapters: Memcache, S3, and ActiveRecord
|
|
33
32
|
- add articles / podcasts like prontos readme https://github.com/prontolabs/pronto
|
|
34
33
|
- Add detailed Gem usage report, if we collect and send gem usage we can give percentage of gem code used, which should help application developers know when to remove gem dependencies (0%) or perhaps inline single methods for little usage (using <= 5%) for example.
|
|
35
|
-
- add additional config / protection options on Coverage clear
|
|
36
34
|
- add meta data information first seen last recorded to the coverage report views (probably need to drop simplecov for that).
|
|
37
35
|
- more details in this issue: https://github.com/danmayer/coverband/issues/118
|
|
38
36
|
- Make good video on setup, install, usage
|
|
39
37
|
- See if we can add support for views / templates
|
|
40
|
-
- using this technique https://github.com/ioquatix/covered
|
|
38
|
+
- using this technique https://github.com/ioquatix/covered
|
|
39
|
+
- Better default grouping (could use groups features for gems for rails controllers, models, lib, etc)
|
|
40
|
+
- Improved logging for easier debugging and development
|
|
41
|
+
- drop the verbose mode and better support standard logger levels
|
|
42
|
+
- Possibly setup a build assets system
|
|
43
|
+
- my JS rules expanded the compressed JS at the top of application.js, basically we want to stitch together JS
|
|
44
|
+
- I guess we could also load multiple JS files as most of the JS is just default compressed JS and a tiny amount of actual app JS.
|
|
45
|
+
- lazy load for Coverband results
|
|
46
|
+
- view layer file coverage
|
|
47
|
+
- move all code to work with relative paths leaving only stdlib Coverage working on full paths
|
|
48
|
+
- add gem_safe_lists to track only some gems
|
|
49
|
+
- add gem_details_safe list to report on details on some gems
|
|
41
50
|
|
|
42
51
|
### Coverband_jam_session
|
|
43
52
|
|
|
@@ -64,12 +73,54 @@ Feature Ideas:
|
|
|
64
73
|
|
|
65
74
|
# Alpha
|
|
66
75
|
|
|
67
|
-
### Coverband 4.0
|
|
76
|
+
### Coverband 4.3.0?
|
|
68
77
|
|
|
78
|
+
- further improvements on eager_loading detection
|
|
69
79
|
- ?
|
|
70
80
|
|
|
71
81
|
# Released
|
|
72
82
|
|
|
83
|
+
### Coverband 4.2.0
|
|
84
|
+
|
|
85
|
+
**NOTE:** This release introduces load time and runtime Coverage. To get the full benifit of this feature you need to reset you coverage data (`rake coverband:clear` or clear via the web UI). Until you clear the combined result is still correct, but your runtime data will be mixed with previous data. This is due to an additive change in how we store coverage. We didn't reset by default as the coverage history for some folks may be more important than runtime breakdown.
|
|
86
|
+
|
|
87
|
+
- loadtime vs runtime coverage
|
|
88
|
+
- This fixes the coverage last seen date to exclude just load time data
|
|
89
|
+
- now you can see boot time coverage vs code hit during production execution
|
|
90
|
+
- list view shows runtime percentage and runtime hits
|
|
91
|
+
- file view shows line hits load, runtime, and combined
|
|
92
|
+
- perf speedup on gem details views
|
|
93
|
+
- ajax load code views for more responsive pages on large projects
|
|
94
|
+
- fix for issues with COVERBAND_DISABLE_AUTO_START
|
|
95
|
+
- silence warnings
|
|
96
|
+
- move from thread based reporter instance to process based instance
|
|
97
|
+
- thanks Karl Baum for much of the above mentioned work
|
|
98
|
+
- clear coverage on individual files
|
|
99
|
+
- we have a logo, thanks Dave Woodall
|
|
100
|
+
|
|
101
|
+
### Coverband 4.1.1
|
|
102
|
+
|
|
103
|
+
- fix bug on info page when using namespaces
|
|
104
|
+
- fix bug related to forking Ruby processes (Resque for example)
|
|
105
|
+
- bug caused negative line hits
|
|
106
|
+
- bug seemed to cause memory leaks (not entirely sure how)
|
|
107
|
+
- various test improvements
|
|
108
|
+
- fix bad requests on coverband web admin to `/coverage/favicon.png`
|
|
109
|
+
- improved documentation
|
|
110
|
+
|
|
111
|
+
### Coverband 4.1.0
|
|
112
|
+
|
|
113
|
+
- default disabled web clear, add config option to allow it
|
|
114
|
+
- out of the box support for resque
|
|
115
|
+
- readme improvements
|
|
116
|
+
- fix on regression of merging directory changing deployments
|
|
117
|
+
- fixes for duplicate root paths
|
|
118
|
+
- pilot release of Gems tracking (disabled by default) - todos - support multiple gem paths (various version managers setup multiple gem paths) - speed up page load by allowing multiple pages
|
|
119
|
+
- added web settings and debug views
|
|
120
|
+
- added support for seeing coverage data size consumed in redis
|
|
121
|
+
- support coverage data migrations from 4.0.x to 4.1.0
|
|
122
|
+
- fixes for heroku /tmp asset building
|
|
123
|
+
|
|
73
124
|
### Coverband 4.0.1
|
|
74
125
|
|
|
75
126
|
- drops Simplecov runtime dependency
|
|
@@ -78,7 +129,7 @@ Feature Ideas:
|
|
|
78
129
|
- reduced the S3 dependencies to minimal set (not loading all of aws-sdk, only aws-sdk-s3), ensured they are optional
|
|
79
130
|
- Improved Coverband web admin
|
|
80
131
|
- Coverage reports include timestamps of Coverage collection
|
|
81
|
-
- Added Coveralls to the dev process thanks @dondonz
|
|
132
|
+
- Added Coveralls to the dev process thanks @dondonz
|
|
82
133
|
- now tested under Ruby 2.6.0 thanks @Kbaum
|
|
83
134
|
- improved full stack testing for Rails 5 & 4
|
|
84
135
|
- warning before clear coverage on coverband web
|
data/coverband.gemspec
CHANGED
|
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
# to test sdk 2 use this one
|
|
25
25
|
spec.add_development_dependency 'aws-sdk-s3', '~> 1'
|
|
26
26
|
spec.add_development_dependency 'benchmark-ips'
|
|
27
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
28
27
|
spec.add_development_dependency 'capybara'
|
|
29
28
|
spec.add_development_dependency 'm'
|
|
30
29
|
spec.add_development_dependency 'memory_profiler'
|
|
@@ -33,8 +32,9 @@ Gem::Specification.new do |spec|
|
|
|
33
32
|
spec.add_development_dependency 'rack'
|
|
34
33
|
spec.add_development_dependency 'rack-test'
|
|
35
34
|
spec.add_development_dependency 'rake'
|
|
36
|
-
spec.add_development_dependency '
|
|
37
|
-
|
|
35
|
+
spec.add_development_dependency 'resque'
|
|
36
|
+
# temporarily needed to fun tests for classifier-reborn as part of benchmarks
|
|
37
|
+
spec.add_development_dependency 'minitest-reporters'
|
|
38
38
|
|
|
39
39
|
# TODO: used for benchmarking and tests I think we have other better benchmarking
|
|
40
40
|
# perhaps time to drop this and refactor.
|
|
@@ -44,6 +44,8 @@ Gem::Specification.new do |spec|
|
|
|
44
44
|
# require 'byebug'; byebug
|
|
45
45
|
spec.add_development_dependency 'pry-byebug'
|
|
46
46
|
|
|
47
|
+
spec.add_development_dependency 'minitest-profile'
|
|
48
|
+
|
|
47
49
|
# TODO: Remove when other production adapters exist
|
|
48
50
|
# because the default configuration of redis store, we really do require
|
|
49
51
|
# redis now. I was reluctant to add this, but until we offer another production
|