simplecov 0.17.1 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +111 -427
- data/README.md +388 -94
- data/doc/alternate-formatters.md +16 -1
- data/doc/commercial-services.md +5 -0
- data/lib/minitest/simplecov_plugin.rb +15 -0
- data/lib/simplecov/combine/branches_combiner.rb +32 -0
- data/lib/simplecov/combine/files_combiner.rb +24 -0
- data/lib/simplecov/combine/lines_combiner.rb +43 -0
- data/lib/simplecov/combine/results_combiner.rb +60 -0
- data/lib/simplecov/combine.rb +30 -0
- data/lib/simplecov/command_guesser.rb +6 -3
- data/lib/simplecov/configuration.rb +210 -15
- data/lib/simplecov/coverage_statistics.rb +56 -0
- data/lib/simplecov/default_formatter.rb +20 -0
- data/lib/simplecov/defaults.rb +14 -13
- data/lib/simplecov/exit_codes/exit_code_handling.rb +29 -0
- data/lib/simplecov/exit_codes/maximum_coverage_drop_check.rb +83 -0
- data/lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb +54 -0
- data/lib/simplecov/exit_codes/minimum_overall_coverage_check.rb +53 -0
- data/lib/simplecov/exit_codes.rb +5 -0
- data/lib/simplecov/file_list.rb +72 -13
- data/lib/simplecov/filter.rb +9 -6
- data/lib/simplecov/formatter/multi_formatter.rb +5 -7
- data/lib/simplecov/formatter/simple_formatter.rb +4 -4
- data/lib/simplecov/formatter.rb +2 -2
- data/lib/simplecov/last_run.rb +3 -1
- data/lib/simplecov/lines_classifier.rb +5 -5
- data/lib/simplecov/no_defaults.rb +1 -1
- data/lib/simplecov/process.rb +19 -0
- data/lib/simplecov/profiles.rb +9 -7
- data/lib/simplecov/result.rb +18 -12
- data/lib/simplecov/result_adapter.rb +30 -0
- data/lib/simplecov/result_merger.rb +130 -59
- data/lib/simplecov/simulate_coverage.rb +29 -0
- data/lib/simplecov/source_file/branch.rb +84 -0
- data/lib/simplecov/source_file/line.rb +72 -0
- data/lib/simplecov/source_file.rb +279 -127
- data/lib/simplecov/useless_results_remover.rb +18 -0
- data/lib/simplecov/version.rb +1 -1
- data/lib/simplecov.rb +296 -128
- metadata +47 -161
- data/CONTRIBUTING.md +0 -51
- data/ISSUE_TEMPLATE.md +0 -23
- data/lib/simplecov/jruby_fix.rb +0 -44
- data/lib/simplecov/railtie.rb +0 -9
- data/lib/simplecov/railties/tasks.rake +0 -13
- data/lib/simplecov/raw_coverage.rb +0 -41
metadata
CHANGED
@@ -1,238 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Olszowka
|
8
|
-
|
8
|
+
- Tobias Pfeiffer
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
+
name: docile
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.8'
|
20
|
-
- - "<"
|
18
|
+
- - "~>"
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
20
|
+
version: '1.1'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
24
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.8'
|
30
|
-
- - "<"
|
25
|
+
- - "~>"
|
31
26
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
27
|
+
version: '1.1'
|
33
28
|
- !ruby/object:Gem::Dependency
|
34
29
|
name: simplecov-html
|
35
30
|
requirement: !ruby/object:Gem::Requirement
|
36
31
|
requirements:
|
37
32
|
- - "~>"
|
38
33
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
34
|
+
version: '0.11'
|
40
35
|
type: :runtime
|
41
36
|
prerelease: false
|
42
37
|
version_requirements: !ruby/object:Gem::Requirement
|
43
38
|
requirements:
|
44
39
|
- - "~>"
|
45
40
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
41
|
+
version: '0.11'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
43
|
+
name: simplecov_json_formatter
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
45
|
requirements:
|
51
46
|
- - "~>"
|
52
47
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
48
|
+
version: '0.1'
|
54
49
|
type: :runtime
|
55
50
|
prerelease: false
|
56
51
|
version_requirements: !ruby/object:Gem::Requirement
|
57
52
|
requirements:
|
58
53
|
- - "~>"
|
59
54
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
61
|
-
|
62
|
-
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: rake
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: rspec
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: test-unit
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - ">="
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - ">="
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '0'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: cucumber
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "<"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '3'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "<"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '3'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: aruba
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - ">="
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '0'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - ">="
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '0'
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: capybara
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "<"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '3'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "<"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '3'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: phantomjs
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
162
|
-
requirements:
|
163
|
-
- - ">="
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - ">="
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: '0'
|
173
|
-
- !ruby/object:Gem::Dependency
|
174
|
-
name: poltergeist
|
175
|
-
requirement: !ruby/object:Gem::Requirement
|
176
|
-
requirements:
|
177
|
-
- - ">="
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '0'
|
180
|
-
type: :development
|
181
|
-
prerelease: false
|
182
|
-
version_requirements: !ruby/object:Gem::Requirement
|
183
|
-
requirements:
|
184
|
-
- - ">="
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: '0'
|
187
|
-
description: Code coverage for Ruby 1.9+ with a powerful configuration library and
|
188
|
-
automatic merging of coverage across test suites
|
55
|
+
version: '0.1'
|
56
|
+
description: Code coverage for Ruby with a powerful configuration library and automatic
|
57
|
+
merging of coverage across test suites
|
189
58
|
email:
|
190
59
|
- christoph at olszowka de
|
60
|
+
- pragtob@gmail.com
|
191
61
|
executables: []
|
192
62
|
extensions: []
|
193
63
|
extra_rdoc_files: []
|
194
64
|
files:
|
195
65
|
- CHANGELOG.md
|
196
|
-
- CONTRIBUTING.md
|
197
|
-
- ISSUE_TEMPLATE.md
|
198
66
|
- LICENSE
|
199
67
|
- README.md
|
200
68
|
- doc/alternate-formatters.md
|
201
69
|
- doc/commercial-services.md
|
202
70
|
- doc/editor-integration.md
|
71
|
+
- lib/minitest/simplecov_plugin.rb
|
203
72
|
- lib/simplecov.rb
|
73
|
+
- lib/simplecov/combine.rb
|
74
|
+
- lib/simplecov/combine/branches_combiner.rb
|
75
|
+
- lib/simplecov/combine/files_combiner.rb
|
76
|
+
- lib/simplecov/combine/lines_combiner.rb
|
77
|
+
- lib/simplecov/combine/results_combiner.rb
|
204
78
|
- lib/simplecov/command_guesser.rb
|
205
79
|
- lib/simplecov/configuration.rb
|
80
|
+
- lib/simplecov/coverage_statistics.rb
|
81
|
+
- lib/simplecov/default_formatter.rb
|
206
82
|
- lib/simplecov/defaults.rb
|
207
83
|
- lib/simplecov/exit_codes.rb
|
84
|
+
- lib/simplecov/exit_codes/exit_code_handling.rb
|
85
|
+
- lib/simplecov/exit_codes/maximum_coverage_drop_check.rb
|
86
|
+
- lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb
|
87
|
+
- lib/simplecov/exit_codes/minimum_overall_coverage_check.rb
|
208
88
|
- lib/simplecov/file_list.rb
|
209
89
|
- lib/simplecov/filter.rb
|
210
90
|
- lib/simplecov/formatter.rb
|
211
91
|
- lib/simplecov/formatter/multi_formatter.rb
|
212
92
|
- lib/simplecov/formatter/simple_formatter.rb
|
213
|
-
- lib/simplecov/jruby_fix.rb
|
214
93
|
- lib/simplecov/last_run.rb
|
215
94
|
- lib/simplecov/lines_classifier.rb
|
216
95
|
- lib/simplecov/load_global_config.rb
|
217
96
|
- lib/simplecov/no_defaults.rb
|
97
|
+
- lib/simplecov/process.rb
|
218
98
|
- lib/simplecov/profiles.rb
|
219
99
|
- lib/simplecov/profiles/bundler_filter.rb
|
220
100
|
- lib/simplecov/profiles/hidden_filter.rb
|
221
101
|
- lib/simplecov/profiles/rails.rb
|
222
102
|
- lib/simplecov/profiles/root_filter.rb
|
223
103
|
- lib/simplecov/profiles/test_frameworks.rb
|
224
|
-
- lib/simplecov/railtie.rb
|
225
|
-
- lib/simplecov/railties/tasks.rake
|
226
|
-
- lib/simplecov/raw_coverage.rb
|
227
104
|
- lib/simplecov/result.rb
|
105
|
+
- lib/simplecov/result_adapter.rb
|
228
106
|
- lib/simplecov/result_merger.rb
|
107
|
+
- lib/simplecov/simulate_coverage.rb
|
229
108
|
- lib/simplecov/source_file.rb
|
109
|
+
- lib/simplecov/source_file/branch.rb
|
110
|
+
- lib/simplecov/source_file/line.rb
|
111
|
+
- lib/simplecov/useless_results_remover.rb
|
230
112
|
- lib/simplecov/version.rb
|
231
|
-
homepage:
|
113
|
+
homepage: https://github.com/simplecov-ruby/simplecov
|
232
114
|
licenses:
|
233
115
|
- MIT
|
234
|
-
metadata:
|
235
|
-
|
116
|
+
metadata:
|
117
|
+
bug_tracker_uri: https://github.com/simplecov-ruby/simplecov/issues
|
118
|
+
changelog_uri: https://github.com/simplecov-ruby/simplecov/blob/main/CHANGELOG.md
|
119
|
+
documentation_uri: https://www.rubydoc.info/gems/simplecov/0.22.0
|
120
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/simplecov
|
121
|
+
source_code_uri: https://github.com/simplecov-ruby/simplecov/tree/v0.22.0
|
122
|
+
post_install_message:
|
236
123
|
rdoc_options: []
|
237
124
|
require_paths:
|
238
125
|
- lib
|
@@ -240,16 +127,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
240
127
|
requirements:
|
241
128
|
- - ">="
|
242
129
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
130
|
+
version: 2.5.0
|
244
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
132
|
requirements:
|
246
133
|
- - ">="
|
247
134
|
- !ruby/object:Gem::Version
|
248
135
|
version: '0'
|
249
136
|
requirements: []
|
250
|
-
rubygems_version: 3.
|
251
|
-
signing_key:
|
137
|
+
rubygems_version: 3.3.7
|
138
|
+
signing_key:
|
252
139
|
specification_version: 4
|
253
|
-
summary: Code coverage for Ruby
|
254
|
-
merging of coverage across test suites
|
140
|
+
summary: Code coverage for Ruby
|
255
141
|
test_files: []
|
data/CONTRIBUTING.md
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
## Reporting Issues
|
2
|
-
|
3
|
-
You can report issues at https://github.com/colszowka/simplecov/issues
|
4
|
-
|
5
|
-
Before you go ahead please search existing issues for your problem, chances are someone else already reported it.
|
6
|
-
|
7
|
-
To make sure that we can help you quickly please include and check the following information:
|
8
|
-
|
9
|
-
* Include how you run your tests and which testing framework or frameworks you are running.
|
10
|
-
- please ensure you are requiring and starting SimpleCov before requiring any application code.
|
11
|
-
- If running via rake, please ensure you are requiring SimpleCov at the top of your Rakefile
|
12
|
-
For example, if running via RSpec, this would be at the top of your spec_helper.
|
13
|
-
- Have you tried using a [`.simplecov` file](https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config)?
|
14
|
-
* Include the SimpleCov version you are running in your report.
|
15
|
-
* If you are not running the latest version (please check), and you cannot update it,
|
16
|
-
please specify in your report why you can't update to the latest version.
|
17
|
-
* Include your `ruby -e "puts RUBY_DESCRIPTION"`.
|
18
|
-
* Please also specify the gem versions of Rails (if applicable).
|
19
|
-
* Include any other coverage gems you may be using and their versions.
|
20
|
-
|
21
|
-
Include as much sample code as you can to help us reproduce the issue. (Inline, repo link, or gist, are fine. A failing test would help the most.)
|
22
|
-
|
23
|
-
This is extremely important for narrowing down the cause of your problem.
|
24
|
-
|
25
|
-
Thanks!
|
26
|
-
|
27
|
-
## Making Contributions
|
28
|
-
|
29
|
-
To fetch & test the library for development, do:
|
30
|
-
|
31
|
-
$ git clone https://github.com/colszowka/simplecov.git
|
32
|
-
$ cd simplecov
|
33
|
-
$ bundle
|
34
|
-
$ bundle exec rake
|
35
|
-
|
36
|
-
If you want to contribute, please:
|
37
|
-
|
38
|
-
* Fork the project.
|
39
|
-
* Make your feature addition or bug fix.
|
40
|
-
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
41
|
-
* **Bonus Points** go out to anyone who also updates `CHANGELOG.md` :)
|
42
|
-
* Send me a pull request on GitHub.
|
43
|
-
|
44
|
-
## Running Individual Tests
|
45
|
-
|
46
|
-
This project uses RSpec and Cucumber. Individual tests can be run like this:
|
47
|
-
|
48
|
-
```bash
|
49
|
-
bundle exec rspec path/to/test.rb
|
50
|
-
bundle exec cucumber path/to/test.feature
|
51
|
-
```
|
data/ISSUE_TEMPLATE.md
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
Howdy! Thanks for reporting an issue <3
|
2
|
-
|
3
|
-
Before you go ahead please search existing issues for your problem, chances are someone else already reported it.
|
4
|
-
|
5
|
-
To make sure that we can help you quickly please include and check the following information:
|
6
|
-
|
7
|
-
* Include how you run your tests and which testing framework or frameworks you are running.
|
8
|
-
- please ensure you are requiring and starting SimpleCov before requiring any application code.
|
9
|
-
- If running via rake, please ensure you are requiring SimpleCov at the top of your Rakefile
|
10
|
-
For example, if running via RSpec, this would be at the top of your spec_helper.
|
11
|
-
- Have you tried using a [`.simplecov` file](https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config)?
|
12
|
-
* Include the SimpleCov version you are running in your report.
|
13
|
-
* If you are not running the latest version (please check), and you cannot update it,
|
14
|
-
please specify in your report why you can't update to the latest version.
|
15
|
-
* Include your `ruby -e "puts RUBY_DESCRIPTION"`.
|
16
|
-
* Please also specify the gem versions of Rails (if applicable).
|
17
|
-
* Include any other coverage gems you may be using and their versions.
|
18
|
-
|
19
|
-
Include as much sample code as you can to help us reproduce the issue. (Inline, repo link, or gist, are fine. A failing test would help the most.)
|
20
|
-
|
21
|
-
This is extremely important for narrowing down the cause of your problem.
|
22
|
-
|
23
|
-
Thanks!
|
data/lib/simplecov/jruby_fix.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if defined?(JRUBY_VERSION) && JRUBY_VERSION.to_f < 1.7
|
4
|
-
require "jruby"
|
5
|
-
java_import "org.jruby.ast.NodeType"
|
6
|
-
|
7
|
-
# Coverage for JRuby < 1.7.0 does not work correctly
|
8
|
-
#
|
9
|
-
# - does not distinguish lines that cannot be executed
|
10
|
-
# - does (partial) coverage for files loaded before `Coverage.start`.
|
11
|
-
# - does not expand a path like `lib/../spec` to `spec`.
|
12
|
-
#
|
13
|
-
# This monkey patches Coverage to address those issues
|
14
|
-
module Coverage
|
15
|
-
class << self
|
16
|
-
alias __broken_result__ result
|
17
|
-
|
18
|
-
def result # rubocop:disable Metrics/MethodLength
|
19
|
-
fixed = {}
|
20
|
-
__broken_result__.each do |path, executed_lines|
|
21
|
-
next unless File.file? path
|
22
|
-
|
23
|
-
covered_lines = executed_lines.dup
|
24
|
-
|
25
|
-
process = lambda do |node|
|
26
|
-
if node.node_type == NodeType::NEWLINENODE
|
27
|
-
pos = node.position
|
28
|
-
covered_lines[pos.line] ||= 0
|
29
|
-
end
|
30
|
-
node.child_nodes.each(&process)
|
31
|
-
end
|
32
|
-
|
33
|
-
process[JRuby.parse(File.read(path), path)]
|
34
|
-
|
35
|
-
if (first = covered_lines.detect { |x| x }) && first > 0
|
36
|
-
fixed[File.expand_path(path)] = covered_lines
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
fixed
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/simplecov/railtie.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rake/testtask"
|
4
|
-
Rake::TestTask.new do |t|
|
5
|
-
t.name = "simplecov"
|
6
|
-
t.loader = :direct # uses require() which skips PWD in Ruby 1.9
|
7
|
-
t.libs.push "test", "spec", Dir.pwd
|
8
|
-
t.test_files = FileList["{test,spec}/**/*_{test,spec}.rb"]
|
9
|
-
t.ruby_opts.push "-r", "simplecov", "-e", "SimpleCov.start(:rails)".inspect
|
10
|
-
end
|
11
|
-
|
12
|
-
require "rake/clean"
|
13
|
-
CLOBBER.include "coverage"
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SimpleCov
|
4
|
-
module RawCoverage
|
5
|
-
module_function
|
6
|
-
|
7
|
-
# Merges multiple Coverage.result hashes
|
8
|
-
def merge_results(*results)
|
9
|
-
results.reduce({}) do |result, merged|
|
10
|
-
merge_resultsets(result, merged)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Merges two Coverage.result hashes
|
15
|
-
def merge_resultsets(result1, result2)
|
16
|
-
(result1.keys | result2.keys).each_with_object({}) do |filename, merged|
|
17
|
-
file1 = result1[filename]
|
18
|
-
file2 = result2[filename]
|
19
|
-
merged[filename] = merge_file_coverage(file1, file2)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def merge_file_coverage(file1, file2)
|
24
|
-
return (file1 || file2).dup unless file1 && file2
|
25
|
-
|
26
|
-
file1.map.with_index do |count1, index|
|
27
|
-
count2 = file2[index]
|
28
|
-
merge_line_coverage(count1, count2)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def merge_line_coverage(count1, count2)
|
33
|
-
sum = count1.to_i + count2.to_i
|
34
|
-
if sum.zero? && (count1.nil? || count2.nil?)
|
35
|
-
nil
|
36
|
-
else
|
37
|
-
sum
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|