simplecov 0.15.1 → 0.18.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +98 -1
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +12 -9
  5. data/ISSUE_TEMPLATE.md +23 -0
  6. data/{MIT-LICENSE → LICENSE} +0 -0
  7. data/README.md +300 -115
  8. data/doc/alternate-formatters.md +20 -0
  9. data/lib/simplecov.rb +298 -45
  10. data/lib/simplecov/combine.rb +30 -0
  11. data/lib/simplecov/combine/branches_combiner.rb +32 -0
  12. data/lib/simplecov/combine/files_combiner.rb +24 -0
  13. data/lib/simplecov/combine/lines_combiner.rb +43 -0
  14. data/lib/simplecov/combine/results_combiner.rb +60 -0
  15. data/lib/simplecov/command_guesser.rb +8 -3
  16. data/lib/simplecov/configuration.rb +95 -8
  17. data/lib/simplecov/defaults.rb +13 -80
  18. data/lib/simplecov/exit_codes.rb +2 -0
  19. data/lib/simplecov/file_list.rb +32 -3
  20. data/lib/simplecov/filter.rb +5 -2
  21. data/lib/simplecov/formatter.rb +2 -0
  22. data/lib/simplecov/formatter/multi_formatter.rb +4 -2
  23. data/lib/simplecov/formatter/simple_formatter.rb +6 -4
  24. data/lib/simplecov/last_run.rb +5 -1
  25. data/lib/simplecov/lines_classifier.rb +21 -5
  26. data/lib/simplecov/load_global_config.rb +2 -0
  27. data/lib/simplecov/no_defaults.rb +2 -0
  28. data/lib/simplecov/profiles.rb +11 -7
  29. data/lib/simplecov/profiles/bundler_filter.rb +5 -0
  30. data/lib/simplecov/profiles/hidden_filter.rb +5 -0
  31. data/lib/simplecov/profiles/rails.rb +18 -0
  32. data/lib/simplecov/profiles/root_filter.rb +10 -0
  33. data/lib/simplecov/profiles/test_frameworks.rb +8 -0
  34. data/lib/simplecov/result.rb +41 -6
  35. data/lib/simplecov/result_adapter.rb +30 -0
  36. data/lib/simplecov/result_merger.rb +20 -11
  37. data/lib/simplecov/simulate_coverage.rb +29 -0
  38. data/lib/simplecov/source_file.rb +190 -109
  39. data/lib/simplecov/source_file/branch.rb +84 -0
  40. data/lib/simplecov/source_file/line.rb +72 -0
  41. data/lib/simplecov/useless_results_remover.rb +16 -0
  42. data/lib/simplecov/version.rb +3 -1
  43. metadata +44 -162
  44. data/.gitignore +0 -31
  45. data/.rspec +0 -3
  46. data/.rubocop.yml +0 -88
  47. data/.travis.yml +0 -29
  48. data/.yardopts +0 -1
  49. data/Gemfile +0 -38
  50. data/Rakefile +0 -39
  51. data/cucumber.yml +0 -13
  52. data/features/config_autoload.feature +0 -46
  53. data/features/config_command_name.feature +0 -45
  54. data/features/config_coverage_dir.feature +0 -33
  55. data/features/config_deactivate_merging.feature +0 -42
  56. data/features/config_formatters.feature +0 -77
  57. data/features/config_merge_timeout.feature +0 -39
  58. data/features/config_nocov_token.feature +0 -79
  59. data/features/config_profiles.feature +0 -44
  60. data/features/config_project_name.feature +0 -27
  61. data/features/config_styles.feature +0 -121
  62. data/features/config_tracked_files.feature +0 -29
  63. data/features/config_tracked_files_relevant_lines.feature +0 -31
  64. data/features/cucumber_basic.feature +0 -29
  65. data/features/maximum_coverage_drop.feature +0 -89
  66. data/features/merging_test_unit_and_rspec.feature +0 -44
  67. data/features/minimum_coverage.feature +0 -59
  68. data/features/refuse_coverage_drop.feature +0 -95
  69. data/features/rspec_basic.feature +0 -32
  70. data/features/rspec_fails_on_initialization.feature +0 -14
  71. data/features/rspec_groups_and_filters_basic.feature +0 -29
  72. data/features/rspec_groups_and_filters_complex.feature +0 -37
  73. data/features/rspec_groups_using_filter_class.feature +0 -41
  74. data/features/rspec_without_simplecov.feature +0 -20
  75. data/features/skipping_code_blocks_manually.feature +0 -70
  76. data/features/step_definitions/html_steps.rb +0 -44
  77. data/features/step_definitions/simplecov_steps.rb +0 -68
  78. data/features/step_definitions/transformers.rb +0 -13
  79. data/features/step_definitions/web_steps.rb +0 -64
  80. data/features/support/aruba_freedom_patch.rb +0 -53
  81. data/features/support/env.rb +0 -50
  82. data/features/test_unit_basic.feature +0 -34
  83. data/features/test_unit_groups_and_filters_basic.feature +0 -29
  84. data/features/test_unit_groups_and_filters_complex.feature +0 -35
  85. data/features/test_unit_groups_using_filter_class.feature +0 -40
  86. data/features/test_unit_without_simplecov.feature +0 -20
  87. data/features/unicode_compatiblity.feature +0 -67
  88. data/lib/simplecov/jruby_fix.rb +0 -42
  89. data/lib/simplecov/railtie.rb +0 -7
  90. data/lib/simplecov/railties/tasks.rake +0 -11
  91. data/lib/simplecov/raw_coverage.rb +0 -39
  92. data/simplecov.gemspec +0 -27
  93. data/spec/1_8_fallbacks_spec.rb +0 -31
  94. data/spec/command_guesser_spec.rb +0 -48
  95. data/spec/config_loader_spec.rb +0 -14
  96. data/spec/configuration_spec.rb +0 -35
  97. data/spec/defaults_spec.rb +0 -41
  98. data/spec/deleted_source_spec.rb +0 -12
  99. data/spec/faked_project/Gemfile +0 -6
  100. data/spec/faked_project/Rakefile +0 -8
  101. data/spec/faked_project/cucumber.yml +0 -13
  102. data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
  103. data/spec/faked_project/features/support/env.rb +0 -12
  104. data/spec/faked_project/features/test_stuff.feature +0 -6
  105. data/spec/faked_project/lib/faked_project.rb +0 -11
  106. data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
  107. data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
  108. data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
  109. data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
  110. data/spec/faked_project/spec/faked_spec.rb +0 -11
  111. data/spec/faked_project/spec/forking_spec.rb +0 -8
  112. data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
  113. data/spec/faked_project/spec/some_class_spec.rb +0 -13
  114. data/spec/faked_project/spec/spec_helper.rb +0 -11
  115. data/spec/faked_project/test/faked_test.rb +0 -11
  116. data/spec/faked_project/test/meta_magic_test.rb +0 -13
  117. data/spec/faked_project/test/some_class_test.rb +0 -15
  118. data/spec/faked_project/test/test_helper.rb +0 -12
  119. data/spec/file_list_spec.rb +0 -50
  120. data/spec/filters_spec.rb +0 -202
  121. data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
  122. data/spec/fixtures/app/models/user.rb +0 -10
  123. data/spec/fixtures/deleted_source_sample.rb +0 -15
  124. data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
  125. data/spec/fixtures/frameworks/rspec_good.rb +0 -9
  126. data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
  127. data/spec/fixtures/frameworks/testunit_good.rb +0 -9
  128. data/spec/fixtures/iso-8859.rb +0 -3
  129. data/spec/fixtures/never.rb +0 -2
  130. data/spec/fixtures/resultset1.rb +0 -4
  131. data/spec/fixtures/resultset2.rb +0 -4
  132. data/spec/fixtures/sample.rb +0 -16
  133. data/spec/fixtures/skipped.rb +0 -4
  134. data/spec/fixtures/skipped_and_executed.rb +0 -8
  135. data/spec/fixtures/utf-8.rb +0 -3
  136. data/spec/helper.rb +0 -26
  137. data/spec/last_run_spec.rb +0 -48
  138. data/spec/lines_classifier_spec.rb +0 -103
  139. data/spec/multi_formatter_spec.rb +0 -20
  140. data/spec/raw_coverage_spec.rb +0 -92
  141. data/spec/result_merger_spec.rb +0 -171
  142. data/spec/result_spec.rb +0 -209
  143. data/spec/return_codes_spec.rb +0 -34
  144. data/spec/simplecov_spec.rb +0 -109
  145. data/spec/source_file_line_spec.rb +0 -155
  146. data/spec/source_file_spec.rb +0 -145
  147. data/spec/support/fail_rspec_on_ruby_warning.rb +0 -75
@@ -10,6 +10,11 @@ If you have built or found one that is missing here, please send a Pull Request
10
10
 
11
11
  A formatter that generates a coverage badge for use in your project's readme using ImageMagick.
12
12
 
13
+ #### [simplecov-small-badge](https://github.com/marcgrimme/simplecov-small-badge)
14
+ *by Marc Grimme*
15
+
16
+ A formatter that generates a small coverage badge for use in your project's readme using the SVG.
17
+
13
18
  #### [simplecov-cobertura](https://github.com/dashingrocket/simplecov-cobertura)
14
19
  *by Jesse Bowes*
15
20
 
@@ -20,11 +25,21 @@ A formatter that generates Cobertura XML.
20
25
 
21
26
  CSV formatter for SimpleCov
22
27
 
28
+ #### [simplecov-erb](https://github.com/kpaulisse/simplecov-erb)
29
+ *by [Kevin Paulisse](https://github.com/kpaulisse)*
30
+
31
+ Flexible formatter that generates the output from an ERB template.
32
+
23
33
  #### [simplecov-json](https://github.com/vicentllongo/simplecov-json)
24
34
  *by Vicent Llongo*
25
35
 
26
36
  JSON formatter for SimpleCov
27
37
 
38
+ #### [simplecov-lcov](https://github.com/fortissimo1997/simplecov-lcov)
39
+ *by fortissimo1997*
40
+
41
+ lcov formatter for SimpleCov
42
+
28
43
  #### [simplecov-rcov](https://github.com/fguillen/simplecov-rcov)
29
44
  *by Fernando Guillen*
30
45
 
@@ -39,3 +54,8 @@ A formatter that prints the coverage of the file under test when you run a singl
39
54
  *by [Yosuke Kabuto](https://github.com/ysksn)*
40
55
 
41
56
  t_wada AA formatter for SimpleCov
57
+
58
+ #### [simplecov-material(https://github.com/chiefpansancolt/simplecov-material)
59
+ *by [Chiefpansancolt](https://github.com/chiefpansancolt)*
60
+
61
+ A Material Designed HTML formatter with clean and easy search of files with a tabular left Navigation.
data/lib/simplecov.rb CHANGED
@@ -1,6 +1,7 @@
1
- #
2
- # Code coverage for ruby 1.9. Please check out README for a full introduction.
3
- #
1
+ # frozen_string_literal: true
2
+
3
+ require "English"
4
+
4
5
  # Coverage may be inaccurate under JRUBY.
5
6
  if defined?(JRUBY_VERSION) && defined?(JRuby)
6
7
 
@@ -16,10 +17,15 @@ if defined?(JRUBY_VERSION) && defined?(JRuby)
16
17
  ' or set the "debug.fullTrace=true" option in your .jrubyrc'
17
18
  end
18
19
  end
20
+
21
+ #
22
+ # Code coverage for ruby. Please check out README for a full introduction.
23
+ #
19
24
  module SimpleCov
20
25
  class << self
21
26
  attr_accessor :running
22
27
  attr_accessor :pid
28
+ attr_reader :exit_exception
23
29
 
24
30
  #
25
31
  # Sets up SimpleCov to run against your project.
@@ -39,35 +45,49 @@ module SimpleCov
39
45
  # Please check out the RDoc for SimpleCov::Configuration to find about available config options
40
46
  #
41
47
  def start(profile = nil, &block)
42
- if SimpleCov.usable?
43
- load_profile(profile) if profile
44
- configure(&block) if block_given?
45
- @result = nil
46
- self.running = true
47
- self.pid = Process.pid
48
- Coverage.start
49
- else
50
- warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9+ - no coverage analysis will happen"
51
- warn "Starting with SimpleCov 1.0.0, even no-op compatibility with Ruby <= 1.8 will be entirely dropped."
52
- false
53
- end
48
+ require "coverage"
49
+ initial_setup(profile, &block)
50
+ @result = nil
51
+ self.pid = Process.pid
52
+
53
+ start_coverage_measurement
54
54
  end
55
55
 
56
56
  #
57
- # Finds files that were to be tracked but were not loaded and initializes
58
- # the line-by-line coverage to zero (if relevant) or nil (comments / whitespace etc).
57
+ # Collate a series of SimpleCov result files into a single SimpleCov output.
58
+ # You can optionally specify configuration with a block:
59
+ # SimpleCov.collate Dir["simplecov-resultset-*/.resultset.json"]
60
+ # OR
61
+ # SimpleCov.collate Dir["simplecov-resultset-*/.resultset.json"], 'rails' # using rails profile
62
+ # OR
63
+ # SimpleCov.collate Dir["simplecov-resultset-*/.resultset.json"] do
64
+ # add_filter 'test'
65
+ # end
66
+ # OR
67
+ # SimpleCov.collate Dir["simplecov-resultset-*/.resultset.json"], 'rails' do
68
+ # add_filter 'test'
69
+ # end
59
70
  #
60
- def add_not_loaded_files(result)
61
- if tracked_files
62
- result = result.dup
63
- Dir[tracked_files].each do |file|
64
- absolute = File.expand_path(file)
71
+ # Please check out the RDoc for SimpleCov::Configuration to find about
72
+ # available config options, or checkout the README for more in-depth
73
+ # information about coverage collation
74
+ #
75
+ def collate(result_filenames, profile = nil, &block)
76
+ raise "There's no reports to be merged" if result_filenames.empty?
65
77
 
66
- result[absolute] ||= LinesClassifier.new.classify(File.foreach(absolute))
78
+ initial_setup(profile, &block)
79
+
80
+ results = result_filenames.flat_map do |filename|
81
+ # Re-create each included instance of SimpleCov::Result from the stored run data.
82
+ (JSON.parse(File.read(filename)) || {}).map do |command_name, coverage|
83
+ SimpleCov::Result.from_hash(command_name => coverage)
67
84
  end
68
85
  end
69
86
 
70
- result
87
+ # Use the ResultMerger to produce a single, merged result, ready to use.
88
+ @result = SimpleCov::ResultMerger.merge_and_store(*results)
89
+
90
+ run_exit_tasks!
71
91
  end
72
92
 
73
93
  #
@@ -78,13 +98,13 @@ module SimpleCov
78
98
  return @result if result?
79
99
 
80
100
  # Collect our coverage result
81
- if running
82
- @result = SimpleCov::Result.new add_not_loaded_files(Coverage.result)
83
- end
101
+
102
+ process_coverage_result if running
84
103
 
85
104
  # If we're using merging of results, store the current result
86
105
  # first (if there is one), then merge the results and return those
87
106
  if use_merging
107
+ wait_for_other_processes
88
108
  SimpleCov::ResultMerger.store_result(@result) if result?
89
109
  @result = SimpleCov::ResultMerger.merged_result
90
110
  end
@@ -142,35 +162,264 @@ module SimpleCov
142
162
  end
143
163
 
144
164
  #
145
- # Checks whether we're on a proper version of Ruby (likely 1.9+) which
146
- # provides coverage support
165
+ # Clear out the previously cached .result. Primarily useful in testing
147
166
  #
148
- def usable?
149
- return @usable if defined?(@usable) && !@usable.nil?
167
+ def clear_result
168
+ @result = nil
169
+ end
170
+
171
+ #
172
+ # Capture the current exception if it exists
173
+ # This will get called inside the at_exit block
174
+ #
175
+ def set_exit_exception
176
+ @exit_exception = $ERROR_INFO
177
+ end
178
+
179
+ #
180
+ # Returns the exit status from the exit exception
181
+ #
182
+ def exit_status_from_exception
183
+ return SimpleCov::ExitCodes::SUCCESS unless exit_exception
150
184
 
151
- @usable = begin
152
- require "coverage"
153
- require "simplecov/jruby_fix"
154
- true
155
- rescue LoadError
156
- false
185
+ if exit_exception.is_a?(SystemExit)
186
+ exit_exception.status
187
+ else
188
+ SimpleCov::ExitCodes::EXCEPTION
157
189
  end
158
190
  end
159
191
 
192
+ # @api private
160
193
  #
161
- # Clear out the previously cached .result. Primarily useful in testing
194
+ # Called from at_exit block
162
195
  #
163
- def clear_result
164
- @result = nil
196
+ def run_exit_tasks!
197
+ set_exit_exception
198
+
199
+ exit_status = SimpleCov.exit_status_from_exception
200
+
201
+ SimpleCov.at_exit.call
202
+
203
+ # Don't modify the exit status unless the result has already been
204
+ # computed
205
+ exit_status = SimpleCov.process_result(SimpleCov.result, exit_status) if SimpleCov.result?
206
+
207
+ # Force exit with stored status (see github issue #5)
208
+ # unless it's nil or 0 (see github issue #281)
209
+ if exit_status&.positive?
210
+ $stderr.printf("SimpleCov failed with exit %<exit_status>d\n", exit_status: exit_status) if print_error_status
211
+ Kernel.exit exit_status
212
+ end
213
+ end
214
+
215
+ # @api private
216
+ #
217
+ # Usage:
218
+ # exit_status = SimpleCov.process_result(SimpleCov.result, exit_status)
219
+ #
220
+ def process_result(result, exit_status)
221
+ return exit_status if exit_status != SimpleCov::ExitCodes::SUCCESS # Existing errors
222
+
223
+ covered_percent = result.covered_percent.floor(2)
224
+ result_exit_status = result_exit_status(result, covered_percent)
225
+ write_last_run(covered_percent) if result_exit_status == SimpleCov::ExitCodes::SUCCESS # No result errors
226
+ final_result_process? ? result_exit_status : SimpleCov::ExitCodes::SUCCESS
227
+ end
228
+
229
+ # @api private
230
+ #
231
+ # rubocop:disable Metrics/MethodLength
232
+ def result_exit_status(result, covered_percent)
233
+ covered_percentages = result.covered_percentages.map { |percentage| percentage.floor(2) }
234
+ if covered_percent < SimpleCov.minimum_coverage
235
+ $stderr.printf(
236
+ "Coverage (%<covered>.2f%%) is below the expected minimum coverage (%<minimum_coverage>.2f%%).\n",
237
+ covered: covered_percent,
238
+ minimum_coverage: SimpleCov.minimum_coverage
239
+ )
240
+ SimpleCov::ExitCodes::MINIMUM_COVERAGE
241
+ elsif covered_percentages.any? { |p| p < SimpleCov.minimum_coverage_by_file }
242
+ $stderr.printf(
243
+ "File (%<file>s) is only (%<least_covered_percentage>.2f%%) covered. This is below the expected minimum coverage per file of (%<min_coverage>.2f%%).\n",
244
+ file: result.least_covered_file,
245
+ least_covered_percentage: covered_percentages.min,
246
+ min_coverage: SimpleCov.minimum_coverage_by_file
247
+ )
248
+ SimpleCov::ExitCodes::MINIMUM_COVERAGE
249
+ elsif (last_run = SimpleCov::LastRun.read)
250
+ coverage_diff = last_run[:result][:covered_percent] - covered_percent
251
+ if coverage_diff > SimpleCov.maximum_coverage_drop
252
+ $stderr.printf(
253
+ "Coverage has dropped by %<drop_percent>.2f%% since the last time (maximum allowed: %<max_drop>.2f%%).\n",
254
+ drop_percent: coverage_diff,
255
+ max_drop: SimpleCov.maximum_coverage_drop
256
+ )
257
+ SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
258
+ else
259
+ SimpleCov::ExitCodes::SUCCESS
260
+ end
261
+ else
262
+ SimpleCov::ExitCodes::SUCCESS
263
+ end
264
+ end
265
+ # rubocop:enable Metrics/MethodLength
266
+
267
+ #
268
+ # @api private
269
+ #
270
+ def final_result_process?
271
+ # checking for ENV["TEST_ENV_NUMBER"] to determine if the tess are being run in parallel
272
+ !defined?(ParallelTests) || !ENV["TEST_ENV_NUMBER"] || ParallelTests.number_of_running_processes <= 1
273
+ end
274
+
275
+ #
276
+ # @api private
277
+ #
278
+ def wait_for_other_processes
279
+ return unless defined?(ParallelTests) && final_result_process?
280
+
281
+ ParallelTests.wait_for_other_processes_to_finish
282
+ end
283
+
284
+ #
285
+ # @api private
286
+ #
287
+ def write_last_run(covered_percent)
288
+ SimpleCov::LastRun.write(result: {covered_percent: covered_percent})
289
+ end
290
+
291
+ private
292
+
293
+ def initial_setup(profile, &block)
294
+ load_profile(profile) if profile
295
+ configure(&block) if block_given?
296
+ self.running = true
297
+ end
298
+
299
+ #
300
+ # Trigger Coverage.start depends on given config coverage_criterion
301
+ #
302
+ # With Positive branch it supports all coverage measurement types
303
+ # With Negative branch it supports only line coverage measurement type
304
+ #
305
+ def start_coverage_measurement
306
+ # This blog post gives a good run down of the coverage criterias introduced
307
+ # in Ruby 2.5: https://blog.bigbinary.com/2018/04/11/ruby-2-5-supports-measuring-branch-and-method-coverages.html
308
+ # There is also a nice writeup of the different coverage criteria made in this
309
+ # comment https://github.com/colszowka/simplecov/pull/692#discussion_r281836176 :
310
+ # Ruby < 2.5:
311
+ # https://github.com/ruby/ruby/blob/v1_9_3_374/ext/coverage/coverage.c
312
+ # traditional mode (Array)
313
+ #
314
+ # Ruby 2.5:
315
+ # https://bugs.ruby-lang.org/issues/13901
316
+ # https://github.com/ruby/ruby/blob/v2_5_3/ext/coverage/coverage.c
317
+ # default: traditional/compatible mode (Array)
318
+ # :lines - like traditional mode but using Hash
319
+ # :branches
320
+ # :methods
321
+ # :all - same as lines + branches + methods
322
+ #
323
+ # Ruby >= 2.6:
324
+ # https://bugs.ruby-lang.org/issues/15022
325
+ # https://github.com/ruby/ruby/blob/v2_6_3/ext/coverage/coverage.c
326
+ # default: traditional/compatible mode (Array)
327
+ # :lines - like traditional mode but using Hash
328
+ # :branches
329
+ # :methods
330
+ # :oneshot_lines - can not be combined with lines
331
+ # :all - same as lines + branches + methods
332
+ #
333
+ if coverage_start_arguments_supported?
334
+ start_coverage_with_criteria
335
+ else
336
+ Coverage.start
337
+ end
338
+ end
339
+
340
+ def start_coverage_with_criteria
341
+ start_arguments = coverage_criteria.map do |criterion|
342
+ [lookup_corresponding_ruby_coverage_name(criterion), true]
343
+ end.to_h
344
+
345
+ Coverage.start(start_arguments)
346
+ end
347
+
348
+ CRITERION_TO_RUBY_COVERAGE = {
349
+ branch: :branches,
350
+ line: :lines
351
+ }.freeze
352
+ def lookup_corresponding_ruby_coverage_name(criterion)
353
+ CRITERION_TO_RUBY_COVERAGE.fetch(criterion)
354
+ end
355
+
356
+ #
357
+ # Finds files that were to be tracked but were not loaded and initializes
358
+ # the line-by-line coverage to zero (if relevant) or nil (comments / whitespace etc).
359
+ #
360
+ def add_not_loaded_files(result)
361
+ if tracked_files
362
+ result = result.dup
363
+ Dir[tracked_files].each do |file|
364
+ absolute_path = File.expand_path(file)
365
+ result[absolute_path] ||= SimulateCoverage.call(absolute_path)
366
+ end
367
+ end
368
+
369
+ result
370
+ end
371
+
372
+ #
373
+ # Call steps that handle process coverage result
374
+ #
375
+ # @return [Hash]
376
+ #
377
+ def process_coverage_result
378
+ adapt_coverage_result
379
+ remove_useless_results
380
+ result_with_not_loaded_files
381
+ end
382
+
383
+ #
384
+ # Unite the result so it wouldn't matter what coverage type was called
385
+ #
386
+ # @return [Hash]
387
+ #
388
+ def adapt_coverage_result
389
+ @result = SimpleCov::ResultAdapter.call(Coverage.result)
390
+ end
391
+
392
+ #
393
+ # Filter coverage result
394
+ # The result before filter also has result of coverage for files
395
+ # are not related to the project like loaded gems coverage.
396
+ #
397
+ # @return [Hash]
398
+ #
399
+ def remove_useless_results
400
+ @result = SimpleCov::UselessResultsRemover.call(@result)
401
+ end
402
+
403
+ #
404
+ # Initialize result with files that are not included by coverage
405
+ # and added inside the config block
406
+ #
407
+ # @return [Hash]
408
+ #
409
+ def result_with_not_loaded_files
410
+ @result = SimpleCov::Result.new(add_not_loaded_files(@result))
165
411
  end
166
412
  end
167
413
  end
168
414
 
169
415
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
416
+ require "set"
170
417
  require "simplecov/configuration"
171
- SimpleCov.send :extend, SimpleCov::Configuration
418
+ SimpleCov.extend SimpleCov::Configuration
172
419
  require "simplecov/exit_codes"
173
420
  require "simplecov/profiles"
421
+ require "simplecov/source_file/line"
422
+ require "simplecov/source_file/branch"
174
423
  require "simplecov/source_file"
175
424
  require "simplecov/file_list"
176
425
  require "simplecov/result"
@@ -178,13 +427,17 @@ require "simplecov/filter"
178
427
  require "simplecov/formatter"
179
428
  require "simplecov/last_run"
180
429
  require "simplecov/lines_classifier"
181
- require "simplecov/raw_coverage"
182
430
  require "simplecov/result_merger"
183
431
  require "simplecov/command_guesser"
184
432
  require "simplecov/version"
433
+ require "simplecov/result_adapter"
434
+ require "simplecov/combine"
435
+ require "simplecov/combine/branches_combiner"
436
+ require "simplecov/combine/files_combiner"
437
+ require "simplecov/combine/lines_combiner"
438
+ require "simplecov/combine/results_combiner"
439
+ require "simplecov/useless_results_remover"
440
+ require "simplecov/simulate_coverage"
185
441
 
186
442
  # Load default config
187
443
  require "simplecov/defaults" unless ENV["SIMPLECOV_NO_DEFAULTS"]
188
-
189
- # Load Rails integration (only for Rails 3, see #113)
190
- require "simplecov/railtie" if defined? Rails::Railtie