coverband 4.2.0.beta → 4.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -8
- data/Rakefile +1 -1
- data/changes.md +28 -7
- data/coverband.gemspec +2 -0
- data/lib/coverband.rb +5 -0
- data/lib/coverband/adapters/base.rb +20 -4
- data/lib/coverband/adapters/file_store.rb +8 -0
- data/lib/coverband/adapters/redis_store.rb +33 -2
- data/lib/coverband/at_exit.rb +1 -1
- data/lib/coverband/collectors/coverage.rb +11 -1
- data/lib/coverband/configuration.rb +18 -2
- data/lib/coverband/integrations/background.rb +6 -1
- data/lib/coverband/integrations/resque.rb +7 -2
- data/lib/coverband/reporters/base.rb +8 -38
- data/lib/coverband/reporters/html_report.rb +1 -1
- data/lib/coverband/reporters/web.rb +3 -3
- data/lib/coverband/utils/file_path_helper.rb +57 -0
- data/lib/coverband/utils/html_formatter.rb +9 -1
- data/lib/coverband/utils/railtie.rb +1 -1
- data/lib/coverband/utils/tasks.rb +9 -0
- data/lib/coverband/version.rb +1 -1
- 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} +1 -1
- data/test/{unit → coverband}/at_exit_test.rb +0 -0
- data/test/{unit/collectors_coverage_test.rb → coverband/collectors/coverage_test.rb} +16 -2
- data/test/{unit → coverband}/configuration_test.rb +13 -3
- data/test/{unit → coverband}/coverband_test.rb +0 -0
- data/test/{unit → coverband/integrations}/background_test.rb +1 -1
- data/test/{unit → coverband/integrations}/middleware_test.rb +1 -1
- data/test/{unit/rack_server_checkout_test.rb → coverband/integrations/rack_server_check_test.rb} +1 -1
- data/test/{unit → coverband/integrations}/resque_worker_test.rb +9 -8
- data/test/{unit → coverband/integrations}/test_resque_job.rb +0 -0
- data/test/coverband/reporters/base_test.rb +168 -0
- data/test/{unit/reports_console_test.rb → coverband/reporters/console_test.rb} +6 -5
- data/test/{unit/reports_html_test.rb → coverband/reporters/html_test.rb} +1 -1
- data/test/{unit/reports_web_test.rb → coverband/reporters/web_test.rb} +2 -2
- data/test/{unit → coverband}/utils/file_groups_test.rb +0 -0
- data/test/{unit → coverband}/utils/file_list_test.rb +0 -0
- data/test/{unit → coverband}/utils/gem_list_test.rb +0 -0
- 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 → coverband}/utils/source_file_test.rb +0 -0
- data/test/{unit/dog.rb → dog.rb} +0 -0
- data/test/{unit → integration}/full_stack_test.rb +4 -2
- data/test/{unit → integration}/rails_full_stack_test.rb +4 -3
- data/test/{unit → integration}/rails_gems_full_stack_test.rb +2 -1
- data/views/layout.erb +1 -1
- data/views/settings.erb +35 -0
- metadata +78 -59
- data/test/unit/reports_base_test.rb +0 -117
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6f8d36b44cdc8402a49224920afd6c7a896a88a06ca81d7237566dc3784283a
|
4
|
+
data.tar.gz: 5968d46ebf2badb624044a0af99ac13b3d1cf4f9aa390786da7cc52debc4fe57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b16934f2a74fb43a2868648cc2008100a8abb7c099f087b6b3eb28fd5e9acc2aa697b8c38189e1a510efbcbc363eefb72582d70ad095c451399735299ebbf31
|
7
|
+
data.tar.gz: c8bdb22ed7aab4f36e3daee17ee4f070e3e529c3ce47689e9c14ef4b7499e8d3cad53140dee308b235deb5666ab13f9cc1a493fca0f93dd612374831c19ab308
|
data/README.md
CHANGED
@@ -38,6 +38,8 @@ Coverband stores coverage data in Redis. The Redis endpoint is looked for in thi
|
|
38
38
|
2. `ENV['REDIS_URL']`
|
39
39
|
3. `localhost`
|
40
40
|
|
41
|
+
The redis store can also be explicitly defined within the coverband.rb. See [advanced config](#advanced-config).
|
42
|
+
|
41
43
|
## Gem Installation
|
42
44
|
|
43
45
|
Add this line to your application's `Gemfile`, remember to `bundle install` after updating:
|
@@ -46,9 +48,11 @@ Add this line to your application's `Gemfile`, remember to `bundle install` afte
|
|
46
48
|
gem 'coverband'
|
47
49
|
```
|
48
50
|
|
51
|
+
If [tracking gem usage](#collecting-gem--library-usage), be sure to include coverband before other gems you would like to track.
|
52
|
+
|
49
53
|
## Rails
|
50
54
|
|
51
|
-
The Railtie integration means you shouldn't need to do anything anything else
|
55
|
+
The Railtie integration means you shouldn't need to do anything anything else other than ensure coverband is required after rails within your Gemfile.
|
52
56
|
|
53
57
|
|
54
58
|
## Sinatra
|
@@ -198,6 +202,15 @@ ENV['AWS_ACCESS_KEY_ID']
|
|
198
202
|
ENV['AWS_SECRET_ACCESS_KEY']
|
199
203
|
```
|
200
204
|
|
205
|
+
### Coverage Data Migration
|
206
|
+
|
207
|
+
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.
|
208
|
+
|
209
|
+
`rake coverband:migrate`
|
210
|
+
|
211
|
+
* We will be working to support migrations going forward, when possible
|
212
|
+
|
213
|
+
|
201
214
|
### Clear Coverage
|
202
215
|
|
203
216
|
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.
|
@@ -242,16 +255,28 @@ By adding any files above you will get reporting on those files as part of your
|
|
242
255
|
|
243
256
|
### Collecting Gem / Library Usage
|
244
257
|
|
245
|
-
|
258
|
+
Gem usage can be tracked by enabling the `track_gems` config.
|
259
|
+
|
260
|
+
```
|
261
|
+
Coverband.configure do |config|
|
262
|
+
config.track_gems = true
|
263
|
+
end
|
264
|
+
```
|
265
|
+
|
266
|
+
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).
|
267
|
+
|
268
|
+
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.
|
246
269
|
|
247
|
-
|
270
|
+
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.
|
248
271
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
272
|
+
```
|
273
|
+
Coverband.configure do |config|
|
274
|
+
config.track_gems = true
|
275
|
+
config.gem_details = true
|
276
|
+
end
|
277
|
+
```
|
254
278
|
|
279
|
+
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.
|
255
280
|
|
256
281
|
### Verbose Debug / Development Mode
|
257
282
|
|
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/**/*_test.rb']
|
17
17
|
test.verbose = true
|
18
18
|
end
|
19
19
|
|
data/changes.md
CHANGED
@@ -65,20 +65,41 @@ Feature Ideas:
|
|
65
65
|
|
66
66
|
### Coverband 4.2.0.alpha
|
67
67
|
|
68
|
-
|
68
|
+
???
|
69
|
+
|
70
|
+
### Coverband 4.1.0.beta
|
71
|
+
|
72
|
+
- default disabled web clear, add config option to allow it
|
73
|
+
- out of the box support for resque
|
74
|
+
- readme improvements
|
75
|
+
- fix on regression of merging directory changing deployments
|
76
|
+
- fixes for duplicate root paths
|
77
|
+
- pilot release of Gems tracking (disabled by default)
|
69
78
|
- todos
|
70
79
|
- support multiple gem paths (various version managers setup multiple gem paths)
|
71
80
|
- speed up page load by allowing multiple pages
|
72
|
-
- web settings and debug views
|
73
|
-
|
81
|
+
- added web settings and debug views
|
82
|
+
- added support for seeing coverage data size consumed in redis
|
83
|
+
- support coverage data migrations from 4.0.x to 4.1.0
|
84
|
+
- fixes for heroku /tmp asset building
|
85
|
+
|
86
|
+
# Released
|
74
87
|
|
75
|
-
### Coverband 4.1.0
|
88
|
+
### Coverband 4.1.0
|
76
89
|
|
77
90
|
- default disabled web clear, add config option to allow it
|
78
91
|
- out of the box support for resque
|
79
92
|
- readme improvements
|
80
|
-
|
81
|
-
|
93
|
+
- fix on regression of merging directory changing deployments
|
94
|
+
- fixes for duplicate root paths
|
95
|
+
- pilot release of Gems tracking (disabled by default)
|
96
|
+
- todos
|
97
|
+
- support multiple gem paths (various version managers setup multiple gem paths)
|
98
|
+
- speed up page load by allowing multiple pages
|
99
|
+
- added web settings and debug views
|
100
|
+
- added support for seeing coverage data size consumed in redis
|
101
|
+
- support coverage data migrations from 4.0.x to 4.1.0
|
102
|
+
- fixes for heroku /tmp asset building
|
82
103
|
|
83
104
|
### Coverband 4.0.1
|
84
105
|
|
@@ -88,7 +109,7 @@ Feature Ideas:
|
|
88
109
|
- reduced the S3 dependencies to minimal set (not loading all of aws-sdk, only aws-sdk-s3), ensured they are optional
|
89
110
|
- Improved Coverband web admin
|
90
111
|
- Coverage reports include timestamps of Coverage collection
|
91
|
-
- Added Coveralls to the dev process thanks @dondonz
|
112
|
+
- Added Coveralls to the dev process thanks @dondonz
|
92
113
|
- now tested under Ruby 2.6.0 thanks @Kbaum
|
93
114
|
- improved full stack testing for Rails 5 & 4
|
94
115
|
- warning before clear coverage on coverband web
|
data/coverband.gemspec
CHANGED
@@ -42,6 +42,8 @@ Gem::Specification.new do |spec|
|
|
42
42
|
# require 'byebug'; byebug
|
43
43
|
spec.add_development_dependency 'pry-byebug'
|
44
44
|
|
45
|
+
spec.add_development_dependency 'minitest-profile'
|
46
|
+
|
45
47
|
# TODO: Remove when other production adapters exist
|
46
48
|
# because the default configuration of redis store, we really do require
|
47
49
|
# redis now. I was reluctant to add this, but until we offer another production
|
data/lib/coverband.rb
CHANGED
@@ -7,6 +7,7 @@ require 'redis'
|
|
7
7
|
require 'coverband/version'
|
8
8
|
require 'coverband/at_exit'
|
9
9
|
require 'coverband/configuration'
|
10
|
+
require 'coverband/utils/file_path_helper'
|
10
11
|
require 'coverband/adapters/base'
|
11
12
|
require 'coverband/adapters/redis_store'
|
12
13
|
require 'coverband/adapters/file_store'
|
@@ -49,6 +50,10 @@ module Coverband
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
53
|
+
def self.report_coverage(force_report = false)
|
54
|
+
Coverband::Collectors::Coverage.instance.report_coverage(force_report)
|
55
|
+
end
|
56
|
+
|
52
57
|
def self.configuration
|
53
58
|
self.configuration_data ||= Configuration.new
|
54
59
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Coverband
|
4
4
|
module Adapters
|
5
5
|
class Base
|
6
|
+
include Coverband::Utils::FilePathHelper
|
7
|
+
|
6
8
|
def initialize
|
7
9
|
@file_hash_cache = {}
|
8
10
|
end
|
@@ -11,13 +13,25 @@ module Coverband
|
|
11
13
|
raise 'abstract'
|
12
14
|
end
|
13
15
|
|
16
|
+
def migrate!
|
17
|
+
raise 'abstract'
|
18
|
+
end
|
19
|
+
|
20
|
+
def size
|
21
|
+
raise 'abstract'
|
22
|
+
end
|
23
|
+
|
24
|
+
def size_in_mib
|
25
|
+
format('%.2f', (size.to_f / 2**20))
|
26
|
+
end
|
27
|
+
|
14
28
|
# Note: This could lead to slight race on redis
|
15
29
|
# where multiple processes pull the old coverage and add to it then push
|
16
30
|
# the Coverband 2 had the same issue,
|
17
31
|
# and the tradeoff has always been acceptable
|
18
32
|
def save_report(report)
|
19
33
|
data = report.dup
|
20
|
-
merge_reports(data, get_report)
|
34
|
+
data = merge_reports(data, get_report)
|
21
35
|
save_coverage(data)
|
22
36
|
end
|
23
37
|
|
@@ -49,6 +63,7 @@ module Coverband
|
|
49
63
|
end
|
50
64
|
|
51
65
|
def expand_report(report)
|
66
|
+
expanded = {}
|
52
67
|
report_time = Time.now.to_i
|
53
68
|
report.each_pair do |key, line_data|
|
54
69
|
extended_data = {
|
@@ -57,12 +72,13 @@ module Coverband
|
|
57
72
|
'file_hash' => file_hash(key),
|
58
73
|
'data' => line_data
|
59
74
|
}
|
60
|
-
|
75
|
+
expanded[full_path_to_relative(key)] = extended_data
|
61
76
|
end
|
77
|
+
expanded
|
62
78
|
end
|
63
79
|
|
64
|
-
def merge_reports(new_report, old_report)
|
65
|
-
new_report = expand_report(new_report)
|
80
|
+
def merge_reports(new_report, old_report, options = {})
|
81
|
+
new_report = expand_report(new_report) unless options[:skip_expansion]
|
66
82
|
keys = (new_report.keys + old_report.keys).uniq
|
67
83
|
keys.each do |file|
|
68
84
|
new_report[file] = if new_report[file] &&
|
@@ -20,6 +20,14 @@ module Coverband
|
|
20
20
|
File.delete(path) if File.exist?(path)
|
21
21
|
end
|
22
22
|
|
23
|
+
def size
|
24
|
+
File.size?(path).to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
def migrate!
|
28
|
+
raise NotImplementedError, "FileStore doesn't support migrations"
|
29
|
+
end
|
30
|
+
|
23
31
|
private
|
24
32
|
|
25
33
|
attr_accessor :path
|
@@ -11,25 +11,56 @@ module Coverband
|
|
11
11
|
# used to store data to redis. It is changed only when breaking changes to our
|
12
12
|
# redis format are required.
|
13
13
|
###
|
14
|
-
REDIS_STORAGE_FORMAT_VERSION = '
|
14
|
+
REDIS_STORAGE_FORMAT_VERSION = 'coverband_3_2'
|
15
15
|
|
16
16
|
def initialize(redis, opts = {})
|
17
17
|
super()
|
18
18
|
@redis = redis
|
19
19
|
@ttl = opts[:ttl]
|
20
20
|
@redis_namespace = opts[:redis_namespace]
|
21
|
+
@format_version = REDIS_STORAGE_FORMAT_VERSION
|
21
22
|
end
|
22
23
|
|
23
24
|
def clear!
|
24
25
|
@redis.del(base_key)
|
25
26
|
end
|
26
27
|
|
28
|
+
def size
|
29
|
+
@redis.get(base_key).bytesize
|
30
|
+
end
|
31
|
+
|
32
|
+
###
|
33
|
+
# Current implementation moves from coverband3_1 to coverband_3_2
|
34
|
+
# In the future this can be made more general and support a more specific
|
35
|
+
# version format.
|
36
|
+
###
|
37
|
+
def migrate!
|
38
|
+
reset_base_key
|
39
|
+
@format_version = 'coverband3_1'
|
40
|
+
previous_data = get_report
|
41
|
+
if previous_data.empty?
|
42
|
+
puts 'no previous data to migrate found'
|
43
|
+
exit 0
|
44
|
+
end
|
45
|
+
relative_path_report = previous_data.each_with_object({}) do |(key, vals), fixed_report|
|
46
|
+
fixed_report[full_path_to_relative(key)] = vals
|
47
|
+
end
|
48
|
+
clear!
|
49
|
+
reset_base_key
|
50
|
+
@format_version = REDIS_STORAGE_FORMAT_VERSION
|
51
|
+
save_coverage(merge_reports(get_report, relative_path_report, skip_expansion: true))
|
52
|
+
end
|
53
|
+
|
27
54
|
private
|
28
55
|
|
29
56
|
attr_reader :redis
|
30
57
|
|
58
|
+
def reset_base_key
|
59
|
+
@base_key = nil
|
60
|
+
end
|
61
|
+
|
31
62
|
def base_key
|
32
|
-
@base_key ||= [
|
63
|
+
@base_key ||= [@format_version, @redis_namespace].compact.join('.')
|
33
64
|
end
|
34
65
|
|
35
66
|
def save_coverage(data)
|
data/lib/coverband/at_exit.rb
CHANGED
@@ -11,7 +11,7 @@ module Coverband
|
|
11
11
|
@at_exit_registered = true
|
12
12
|
at_exit do
|
13
13
|
::Coverband::Background.stop
|
14
|
-
Coverband
|
14
|
+
Coverband.report_coverage(true)
|
15
15
|
Coverband.configuration.logger&.debug('Coverband: Reported coverage before exit')
|
16
16
|
end
|
17
17
|
end
|
@@ -87,7 +87,17 @@ module Coverband
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def array_diff(latest, original)
|
90
|
-
latest.map.with_index
|
90
|
+
latest.map.with_index do |v, i|
|
91
|
+
if (v && original[i])
|
92
|
+
if v >= original[i]
|
93
|
+
v - original[i]
|
94
|
+
else
|
95
|
+
0
|
96
|
+
end
|
97
|
+
else
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
end
|
91
101
|
end
|
92
102
|
|
93
103
|
def previous_results
|
@@ -20,7 +20,10 @@ module Coverband
|
|
20
20
|
def reset
|
21
21
|
@root = Dir.pwd
|
22
22
|
@root_paths = []
|
23
|
-
|
23
|
+
# Heroku when building assets runs code from a dynamic directory
|
24
|
+
# /tmp was added to avoid coverage from /tmp/build directories during
|
25
|
+
# heroku asset compilation
|
26
|
+
@ignore = %w[vendor .erb$ .slim$ /tmp]
|
24
27
|
@additional_files = []
|
25
28
|
@reporting_frequency = 0.0
|
26
29
|
@verbose = false
|
@@ -87,6 +90,8 @@ module Coverband
|
|
87
90
|
# by default we ignore vendor where many deployments put gems
|
88
91
|
# we will remove this default if track_gems is set
|
89
92
|
@ignore.delete('vendor')
|
93
|
+
# while we want to allow vendored gems we don't want to track vendored ruby STDLIB
|
94
|
+
@ignore << 'vendor/ruby-*'
|
90
95
|
add_group('App', root)
|
91
96
|
# TODO: rework support for multiple gem paths
|
92
97
|
# currently this supports GEM_HOME (which should be first path)
|
@@ -119,7 +124,18 @@ module Coverband
|
|
119
124
|
Gem::PathSupport.new(ENV).path.select { |path| File.exist?(path) }
|
120
125
|
end
|
121
126
|
|
122
|
-
|
127
|
+
def current_root
|
128
|
+
File.expand_path(Coverband.configuration.root)
|
129
|
+
end
|
130
|
+
|
131
|
+
def all_root_paths
|
132
|
+
roots = Coverband.configuration.root_paths.dup
|
133
|
+
roots += Coverband.configuration.gem_paths.dup if Coverband.configuration.track_gems
|
134
|
+
roots << "#{Coverband.configuration.current_root}/"
|
135
|
+
roots
|
136
|
+
end
|
137
|
+
|
138
|
+
SKIPPED_SETTINGS = %w(@s3_secret_access_key @store)
|
123
139
|
def to_h
|
124
140
|
instance_variables
|
125
141
|
.each_with_object('gem_paths': gem_paths) do |var, hash|
|
@@ -5,6 +5,7 @@ module Coverband
|
|
5
5
|
@semaphore = Mutex.new
|
6
6
|
|
7
7
|
def self.stop
|
8
|
+
return unless @thread
|
8
9
|
@semaphore.synchronize do
|
9
10
|
if @thread
|
10
11
|
@thread.exit
|
@@ -13,6 +14,10 @@ module Coverband
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
17
|
+
def self.running?
|
18
|
+
!!@thread
|
19
|
+
end
|
20
|
+
|
16
21
|
def self.start
|
17
22
|
return if @thread
|
18
23
|
|
@@ -23,7 +28,7 @@ module Coverband
|
|
23
28
|
sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds
|
24
29
|
@thread = Thread.new do
|
25
30
|
loop do
|
26
|
-
Coverband
|
31
|
+
Coverband.report_coverage(true)
|
27
32
|
logger&.debug("Coverband: Reported coverage via thread. Sleeping #{sleep_seconds}s") if Coverband.configuration.verbose
|
28
33
|
sleep(sleep_seconds)
|
29
34
|
end
|
@@ -4,15 +4,20 @@ Resque.after_fork do |job|
|
|
4
4
|
Coverband.start
|
5
5
|
end
|
6
6
|
|
7
|
+
Resque.before_first_fork do
|
8
|
+
Coverband.configuration.background_reporting_enabled = false
|
9
|
+
Coverband::Background.stop
|
10
|
+
Coverband::Collectors::Coverage.instance.report_coverage(true)
|
11
|
+
end
|
12
|
+
|
7
13
|
module Coverband
|
8
14
|
module ResqueWorker
|
9
15
|
def perform
|
10
16
|
super
|
11
17
|
ensure
|
12
|
-
Coverband
|
18
|
+
Coverband.report_coverage(true)
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
16
22
|
|
17
23
|
Resque::Job.prepend(Coverband::ResqueWorker)
|
18
|
-
|
@@ -8,8 +8,10 @@ module Coverband
|
|
8
8
|
###
|
9
9
|
class Base
|
10
10
|
class << self
|
11
|
+
include Coverband::Utils::FilePathHelper
|
11
12
|
def report(store, _options = {})
|
12
|
-
|
13
|
+
all_roots = Coverband.configuration.all_root_paths
|
14
|
+
scov_style_report = get_current_scov_data_imp(store, all_roots)
|
13
15
|
|
14
16
|
if Coverband.configuration.verbose
|
15
17
|
msg = "report:\n #{scov_style_report.inspect}"
|
@@ -20,17 +22,6 @@ module Coverband
|
|
20
22
|
|
21
23
|
protected
|
22
24
|
|
23
|
-
def root_paths
|
24
|
-
roots = Coverband.configuration.root_paths
|
25
|
-
roots += Coverband.configuration.gem_paths if Coverband.configuration.track_gems
|
26
|
-
roots << "#{current_root}/"
|
27
|
-
roots
|
28
|
-
end
|
29
|
-
|
30
|
-
def current_root
|
31
|
-
File.expand_path(Coverband.configuration.root)
|
32
|
-
end
|
33
|
-
|
34
25
|
def fix_file_names(report_hash, roots)
|
35
26
|
if Coverband.configuration.verbose
|
36
27
|
Coverband.configuration.logger.info "fixing root: #{roots.join(', ')}"
|
@@ -38,9 +29,11 @@ module Coverband
|
|
38
29
|
|
39
30
|
# normalize names across servers
|
40
31
|
report_hash.each_with_object({}) do |(key, vals), fixed_report|
|
41
|
-
filename =
|
42
|
-
fixed_report[filename] = if fixed_report.key?(filename)
|
43
|
-
merge_arrays(fixed_report[filename], vals)
|
32
|
+
filename = relative_path_to_full(key, roots)
|
33
|
+
fixed_report[filename] = if fixed_report.key?(filename) && fixed_report[filename]['data'] && vals['data']
|
34
|
+
merged_data = merge_arrays(fixed_report[filename]['data'], vals['data'])
|
35
|
+
vals['data'] = merged_data
|
36
|
+
vals
|
44
37
|
else
|
45
38
|
vals
|
46
39
|
end
|
@@ -62,33 +55,10 @@ module Coverband
|
|
62
55
|
merged
|
63
56
|
end
|
64
57
|
|
65
|
-
###
|
66
|
-
# This method is responsible for finding the CURRENT LOCAL
|
67
|
-
# filename regardless of the paths being different on
|
68
|
-
# various servers or deployments
|
69
|
-
###
|
70
|
-
def filename_from_key(key, roots)
|
71
|
-
relative_filename = key
|
72
|
-
local_filename = relative_filename
|
73
|
-
roots.each do |root|
|
74
|
-
relative_filename = relative_filename.gsub(/^#{root}/, './')
|
75
|
-
end
|
76
|
-
# the filename for our reports is expected to be a full path.
|
77
|
-
# roots.last should be roots << current_root}/
|
78
|
-
# a fully expanded path of config.root
|
79
|
-
# filename = filename.gsub('./', roots.last)
|
80
|
-
# above only works for app files
|
81
|
-
# we need to rethink some of this logic
|
82
|
-
# gems aren't at project root and can have multiple locations
|
83
|
-
local_root = roots.find { |root| File.exist?(relative_filename.gsub('./', root)) }
|
84
|
-
local_root ? relative_filename.gsub('./', local_root) : local_filename
|
85
|
-
end
|
86
|
-
|
87
58
|
###
|
88
59
|
# why do we need to merge covered files data?
|
89
60
|
# basically because paths on machines or deployed hosts could be different, so
|
90
61
|
# two different keys could point to the same filename or `line_key`
|
91
|
-
# this logic should be pushed to base report
|
92
62
|
# TODO: think we are filtering based on ignore while sending to the store
|
93
63
|
# and as we also pull it out here
|
94
64
|
###
|