coverband 4.2.4.rc.1 → 4.2.4.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -19
- data/lib/coverband/adapters/redis_store.rb +4 -2
- data/lib/coverband/collectors/coverage.rb +1 -1
- data/lib/coverband/configuration.rb +3 -2
- data/lib/coverband/version.rb +1 -1
- data/test/coverband/adapters/hash_redis_store_test.rb +0 -1
- data/test/coverband/adapters/redis_store_test.rb +8 -0
- data/test/coverband/collectors/coverage_test.rb +9 -0
- data/test/coverband/collectors/view_tracker_test.rb +20 -0
- data/test/coverband/configuration_test.rb +2 -2
- data/test/rails5_dummy/config/coverband.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b7fc3e6e0997909a0db557caf78e6ed4ddbf61441b80b44a35eebd195036fb3
|
4
|
+
data.tar.gz: 1adc60c3e2b7a805fd2c0f2863a1a7ec820593b0a918788fbf1ff18b7cfb9d52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15db51c202c98481732a6092703fab2b83ef929dfbcd1fee0620f9275ec1be208e5f399b06ec29b2162ff2ca399dfa3db37b0e8e0e87c0abe2dd76eaa09fbaa7
|
7
|
+
data.tar.gz: b55cf6a2ef95973910ba21ec4bd6f6fd9172f70c0e77b10dcf62780ac37abbfeaec1d44611ebd9e4f2d1a3ef85a20b5b2869054c385bbd7cee5ce9bf775b1ce5
|
data/README.md
CHANGED
@@ -67,7 +67,7 @@ See [changelog](https://github.com/danmayer/coverband/blob/master/changes.md).
|
|
67
67
|
|
68
68
|
## Rails
|
69
69
|
|
70
|
-
The Railtie integration means you shouldn't need to do anything
|
70
|
+
The Railtie integration means you shouldn't need to do anything else other than ensure coverband is required after rails within your Gemfile. The only exception to this is gem tracking of `Bundle.require` which depends on requiring coverband within the application.rb. See [Collecting Gem / Library Usage](https://github.com/danmayer/coverband#collecting-gem--library-usage).
|
71
71
|
|
72
72
|
## Sinatra
|
73
73
|
|
@@ -114,7 +114,7 @@ The web endpoint is a barebones endpoint that you can either expose direct (afte
|
|
114
114
|
- **force coverage collection:** This triggers coverage collection on the current webserver process
|
115
115
|
- **clear coverage report:** This will clear the coverage data. This wipes out all collected data (**dangerous**)
|
116
116
|
- View individual file details
|
117
|
-
- **clear individual file coverage:** This will clear the details of the file you are looking at. This is helpful if you don't want to
|
117
|
+
- **clear individual file coverage:** This will clear the details of the file you are looking at. This is helpful if you don't want to lose all Coverage data but made a change that you expect would impact a particular file.
|
118
118
|
|
119
119
|
### Rake Tasks
|
120
120
|
|
@@ -278,22 +278,6 @@ rake coverband:clear # reset coverband coverage data
|
|
278
278
|
rake coverband:coverage # report runtime coverband code coverage
|
279
279
|
```
|
280
280
|
|
281
|
-
### Forcing Coverband to Track Coverage on files loaded during boot `safe_reload_files`
|
282
|
-
|
283
|
-
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.
|
284
|
-
|
285
|
-
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.
|
286
|
-
|
287
|
-
```
|
288
|
-
Coverband.configure do |config|
|
289
|
-
# ... a bunch of other options
|
290
|
-
# using the new safe reload to enforce files loaded
|
291
|
-
config.safe_reload_files = ['config/coverband.rb']
|
292
|
-
end
|
293
|
-
```
|
294
|
-
|
295
|
-
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.
|
296
|
-
|
297
281
|
### Collecting Gem / Library Usage
|
298
282
|
|
299
283
|
__WARNING:__ Gem Tracking is still in experimental stages and not recommended for production. We have some performance issues when view reports on large applications. Gem tracing also during background thread data collection has HIGH memory requirements, during report merging (seemingly around 128mb of extra memory, which is crazy). We recommend deploying WITHOUT `track_gems` first and only enabling it after confirming that Coverband is working and performing well.
|
@@ -386,7 +370,6 @@ If you submit a change please make sure the tests and benchmarks are passing.
|
|
386
370
|
- **total fail** on front end code, for line for line coverage, because of the precompiled template step basically coverage doesn't work well for `erb`, `slim`, and the like.
|
387
371
|
- 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
|
388
372
|
- **NOTE:** We now have file level coverage for view files, but don't support line level detail
|
389
|
-
- 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).
|
390
373
|
|
391
374
|
### Debugging Redis Store
|
392
375
|
|
@@ -77,7 +77,9 @@ module Coverband
|
|
77
77
|
def coverage(local_type = nil, opts = {})
|
78
78
|
local_type ||= opts.key?(:override_type) ? opts[:override_type] : type
|
79
79
|
data = redis.get type_base_key(local_type)
|
80
|
-
data ? JSON.parse(data) : {}
|
80
|
+
data = data ? JSON.parse(data) : {}
|
81
|
+
data.delete_if { |file_path, file_data| file_hash(file_path) != file_data['file_hash'] } unless opts[:skip_hash_check]
|
82
|
+
data
|
81
83
|
end
|
82
84
|
|
83
85
|
# Note: This could lead to slight race on redis
|
@@ -86,7 +88,7 @@ module Coverband
|
|
86
88
|
# and the tradeoff has always been acceptable
|
87
89
|
def save_report(report)
|
88
90
|
data = report.dup
|
89
|
-
data = merge_reports(data, coverage)
|
91
|
+
data = merge_reports(data, coverage(nil, skip_hash_check: true))
|
90
92
|
save_coverage(data)
|
91
93
|
end
|
92
94
|
|
@@ -71,7 +71,7 @@ module Coverband
|
|
71
71
|
###
|
72
72
|
def track_file?(file)
|
73
73
|
@ignore_patterns.none? do |pattern|
|
74
|
-
file.
|
74
|
+
file.match(pattern)
|
75
75
|
end && (file.start_with?(@project_directory) ||
|
76
76
|
(@track_gems &&
|
77
77
|
Coverband.configuration.gem_paths.any? { |path| file.start_with?(path) }))
|
@@ -30,6 +30,7 @@ module Coverband
|
|
30
30
|
'db:drop',
|
31
31
|
'db:seed',
|
32
32
|
'db:setup',
|
33
|
+
'db:test:prepare',
|
33
34
|
'db:structure:dump',
|
34
35
|
'db:structure:load',
|
35
36
|
'db:version']
|
@@ -37,7 +38,7 @@ module Coverband
|
|
37
38
|
# Heroku when building assets runs code from a dynamic directory
|
38
39
|
# /tmp was added to avoid coverage from /tmp/build directories during
|
39
40
|
# heroku asset compilation
|
40
|
-
IGNORE_DEFAULTS = %w[vendor .erb$ .slim$ /tmp internal:prelude schema.rb]
|
41
|
+
IGNORE_DEFAULTS = %w[vendor/ .erb$ .slim$ /tmp internal:prelude schema.rb]
|
41
42
|
|
42
43
|
# Add in missing files which were never loaded
|
43
44
|
# we need to know what all paths to check for unloaded files
|
@@ -153,7 +154,7 @@ module Coverband
|
|
153
154
|
|
154
155
|
# by default we ignore vendor where many deployments put gems
|
155
156
|
# we will remove this default if track_gems is set
|
156
|
-
@ignore.delete('vendor')
|
157
|
+
@ignore.delete('vendor/')
|
157
158
|
# while we want to allow vendored gems we don't want to track vendored ruby STDLIB
|
158
159
|
@ignore << 'vendor/ruby-*' unless @ignore.include?('vendor/ruby-*')
|
159
160
|
add_group('App', root)
|
data/lib/coverband/version.rb
CHANGED
@@ -123,7 +123,6 @@ class HashRedisStoreTest < Minitest::Test
|
|
123
123
|
assert_equal [0, nil, 1, 2], @store.coverage['./dog.rb']['data']
|
124
124
|
@store.instance_eval { @file_hash_cache = {} }
|
125
125
|
mock_file_hash(hash: '123')
|
126
|
-
$debug = true
|
127
126
|
assert_nil @store.coverage['./dog.rb']
|
128
127
|
end
|
129
128
|
|
@@ -36,6 +36,14 @@ unless ENV['COVERBAND_HASH_REDIS_STORE']
|
|
36
36
|
assert current_time <= @store.coverage['app_path/dog.rb']['last_updated_at']
|
37
37
|
end
|
38
38
|
|
39
|
+
def test_file_hash_change
|
40
|
+
mock_file_hash(hash: 'abc')
|
41
|
+
@store.save_report('app_path/dog.rb' => [0, nil, 1, 2])
|
42
|
+
assert_equal [0, nil, 1, 2], @store.coverage['app_path/dog.rb']['data']
|
43
|
+
mock_file_hash(hash: '123')
|
44
|
+
assert_nil @store.coverage['app_path/dog.rb']
|
45
|
+
end
|
46
|
+
|
39
47
|
def test_store_coverage_by_type
|
40
48
|
mock_file_hash
|
41
49
|
expected = basic_coverage
|
@@ -82,6 +82,15 @@ class CollectorsCoverageTest < Minitest::Test
|
|
82
82
|
assert_equal false, @coverband.send(:track_file?, heroku_build_file)
|
83
83
|
end
|
84
84
|
|
85
|
+
# verifies a fix where we were storing, merging, and tracking ignored files
|
86
|
+
# then just filtering them out of the final report
|
87
|
+
test 'ignores uses regex same as reporter does' do
|
88
|
+
regex_file = Coverband.configuration.current_root + '/config/initializers/fake.rb'
|
89
|
+
assert_equal true, @coverband.send(:track_file?, regex_file)
|
90
|
+
@coverband.instance_variable_set(:@ignore_patterns, ['config/initializers/*'])
|
91
|
+
assert_equal false, @coverband.send(:track_file?, regex_file)
|
92
|
+
end
|
93
|
+
|
85
94
|
test 'one shot line coverage disabled for ruby >= 2.6' do
|
86
95
|
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
|
87
96
|
|
@@ -32,6 +32,26 @@ class ReporterTest < Minitest::Test
|
|
32
32
|
assert_equal [file_path], tracker.logged_views
|
33
33
|
end
|
34
34
|
|
35
|
+
test 'track partials that include the word vendor in the path' do
|
36
|
+
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
37
|
+
store = fake_store
|
38
|
+
file_path = "#{File.expand_path(Coverband.configuration.root)}/vendor_relations/file"
|
39
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: 'dir')
|
40
|
+
tracker.track_views('name', 'start', 'finish', 'id', identifier: file_path)
|
41
|
+
tracker.report_views_tracked
|
42
|
+
assert_equal [file_path], tracker.used_views.keys
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'ignore partials that include the folder vendor in the path' do
|
46
|
+
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
47
|
+
store = fake_store
|
48
|
+
file_path = "#{File.expand_path(Coverband.configuration.root)}/vendor/file"
|
49
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: 'dir')
|
50
|
+
tracker.track_views('name', 'start', 'finish', 'id', identifier: file_path)
|
51
|
+
tracker.report_views_tracked
|
52
|
+
assert_equal Hash.new, tracker.used_views
|
53
|
+
end
|
54
|
+
|
35
55
|
test 'track layouts' do
|
36
56
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
37
57
|
store = fake_store
|
@@ -18,7 +18,7 @@ class BaseTest < Minitest::Test
|
|
18
18
|
|
19
19
|
test 'ignore works with equal' do
|
20
20
|
coverband = Coverband::Collectors::Coverage.instance.reset_instance
|
21
|
-
expected = ['vendor', '.erb$', '.slim$', '/tmp', 'internal:prelude', 'schema.rb', 'config/envionments']
|
21
|
+
expected = ['vendor/', '.erb$', '.slim$', '/tmp', 'internal:prelude', 'schema.rb', 'config/envionments']
|
22
22
|
assert_equal expected, Coverband.configuration.ignore
|
23
23
|
end
|
24
24
|
|
@@ -27,7 +27,7 @@ class BaseTest < Minitest::Test
|
|
27
27
|
config.ignore += ['config/initializers']
|
28
28
|
end
|
29
29
|
coverband = Coverband::Collectors::Coverage.instance.reset_instance
|
30
|
-
expected = ['vendor',
|
30
|
+
expected = ['vendor/',
|
31
31
|
'.erb$',
|
32
32
|
'.slim$',
|
33
33
|
'/tmp',
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Coverband.configure do |config|
|
4
4
|
config.root = Dir.pwd
|
5
5
|
config.store = Coverband::Adapters::RedisStore.new(Redis.new(db: 2, url: ENV['REDIS_URL']), redis_namespace: 'coverband_test') if defined? Redis
|
6
|
-
config.ignore = %w[
|
6
|
+
config.ignore = %w[.erb$ .slim$]
|
7
7
|
config.root_paths = []
|
8
8
|
config.logger = Rails.logger
|
9
9
|
config.verbose = true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coverband
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.4.rc.
|
4
|
+
version: 4.2.4.rc.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-10-
|
12
|
+
date: 2019-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-s3
|