simplecov 0.15.1 → 0.18.0.beta2

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 +89 -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 +100 -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 +13 -4
  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
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCov
4
+ # Functionally for combining coverage results
5
+ #
6
+ module Combine
7
+ module_function
8
+
9
+ #
10
+ # Combine two coverage based on the given combiner_module.
11
+ #
12
+ # Combiners should always be called throught his interface,
13
+ # as it takes care of short circuting of one of the coverages is nil.
14
+ #
15
+ # @return [Hash]
16
+ def combine(combiner_module, coverage_a, coverage_b)
17
+ return existing_coverage(coverage_a, coverage_b) if empty_coverage?(coverage_a, coverage_b)
18
+
19
+ combiner_module.combine(coverage_a, coverage_b)
20
+ end
21
+
22
+ def empty_coverage?(coverage_a, coverage_b)
23
+ !(coverage_a && coverage_b)
24
+ end
25
+
26
+ def existing_coverage(coverage_a, coverage_b)
27
+ coverage_a || coverage_b
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCov
4
+ module Combine
5
+ #
6
+ # Combine different branch coverage results on single file.
7
+ #
8
+ # Should be called through `SimpleCov.combine`.
9
+ module BranchesCombiner
10
+ module_function
11
+
12
+ #
13
+ # Return merged branches or the existed branche if other is missing.
14
+ #
15
+ # Branches inside files are always same if they exists, the difference only in coverage count.
16
+ # Branch coverage report for any conditional case is built from hash, it's key is a condition and
17
+ # it's body is a hash << keys from condition and value is coverage rate >>.
18
+ # ex: branches =>{ [:if, 3, 8, 6, 8, 36] => {[:then, 4, 8, 6, 8, 12] => 1, [:else, 5, 8, 6, 8, 36]=>2}, other conditions...}
19
+ # We create copy of result and update it values depending on the combined branches coverage values.
20
+ #
21
+ # @return [Hash]
22
+ #
23
+ def combine(coverage_a, coverage_b)
24
+ coverage_a.merge(coverage_b) do |_condition, branches_inside_a, branches_inside_b|
25
+ branches_inside_a.merge(branches_inside_b) do |_branch, a_count, b_count|
26
+ a_count + b_count
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCov
4
+ module Combine
5
+ #
6
+ # Handle combining two coverage results for same file
7
+ #
8
+ # Should be called through `SimpleCov.combine`.
9
+ module FilesCombiner
10
+ module_function
11
+
12
+ #
13
+ # Combines the results for 2 coverages of a file.
14
+ #
15
+ # @return [Hash]
16
+ #
17
+ def combine(coverage_a, coverage_b)
18
+ combination = {"lines" => Combine.combine(LinesCombiner, coverage_a["lines"], coverage_b["lines"])}
19
+ combination["branches"] = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"]) if SimpleCov.branch_coverage?
20
+ combination
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCov
4
+ module Combine
5
+ #
6
+ # Combine two different lines coverage results on same file
7
+ #
8
+ # Should be called through `SimpleCov.combine`.
9
+ module LinesCombiner
10
+ module_function
11
+
12
+ def combine(coverage_a, coverage_b)
13
+ coverage_a
14
+ .zip(coverage_b)
15
+ .map do |coverage_a_val, coverage_b_val|
16
+ merge_line_coverage(coverage_a_val, coverage_b_val)
17
+ end
18
+ end
19
+
20
+ # Return depends on coverage in a specific line
21
+ #
22
+ # @param [Integer || nil] first_val
23
+ # @param [Integer || nil] second_val
24
+ #
25
+ # Logic:
26
+ #
27
+ # => nil + 0 = nil
28
+ # => nil + nil = nil
29
+ # => int + int = int
30
+ #
31
+ # @return [Integer || nil]
32
+ def merge_line_coverage(first_val, second_val)
33
+ sum = first_val.to_i + second_val.to_i
34
+
35
+ if sum.zero? && (first_val.nil? || second_val.nil?)
36
+ nil
37
+ else
38
+ sum
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCov
4
+ module Combine
5
+ # There might be reports from different kinds of tests,
6
+ # e.g. RSpec and Cucumber. We need to combine their results
7
+ # into unified one. This class does that.
8
+ # To unite the results on file basis, it leverages
9
+ # the combine of lines and branches inside each file within given results.
10
+ module ResultsCombiner
11
+ module_function
12
+
13
+ #
14
+ # Combine process explanation
15
+ # => ResultCombiner: define all present files between results and start combine on file level.
16
+ # ==> FileCombiner: collect result of next combine levels lines and branches.
17
+ # ===> LinesCombiner: combine lines results.
18
+ # ===> BranchesCombiner: combine branches results.
19
+ #
20
+ # @return [Hash]
21
+ #
22
+ def combine(*results)
23
+ results.reduce({}) do |combined_results, next_result|
24
+ combine_result_sets(combined_results, next_result)
25
+ end
26
+ end
27
+
28
+ #
29
+ # Manage combining results on files level
30
+ #
31
+ # @param [Hash] combined_results
32
+ # @param [Hash] result
33
+ #
34
+ # @return [Hash]
35
+ #
36
+ def combine_result_sets(combined_results, result)
37
+ unless correct_format?(result)
38
+ warn_wrong_format
39
+ return combined_results
40
+ end
41
+
42
+ results_files = combined_results.keys | result.keys
43
+
44
+ results_files.each_with_object({}) do |file_name, file_combination|
45
+ file_combination[file_name] = combine_file_coverage(
46
+ combined_results[file_name],
47
+ result[file_name]
48
+ )
49
+ end
50
+ end
51
+
52
+ # We might start a run of a new simplecov version with a new format stored while
53
+ # there is still a recent file like this lying around. If it's recent enough (
54
+ # see merge_timeout) it will end up here. In order not to crash against this
55
+ # we need to do some basic checking of the format of data we expect and
56
+ # otherwise ignore it. See #820
57
+ #
58
+ # Currently correct format is:
59
+ # { file_path_string => {coverage_criterion => coverage_date}}
60
+ #
61
+ # Internal use/reliance only.
62
+ def correct_format?(result)
63
+ result.empty? || matches_current_format?(result)
64
+ end
65
+
66
+ def matches_current_format?(result)
67
+ # I so wish I could already use pattern matching
68
+ key, data = result.first
69
+
70
+ key.is_a?(String) && second_level_choice_of_criterion?(data)
71
+ end
72
+
73
+ SECOND_LEVEL_KEYS = %w[lines branches].freeze
74
+ def second_level_choice_of_criterion?(data)
75
+ second_level_key, = data.first
76
+
77
+ SECOND_LEVEL_KEYS.member?(second_level_key)
78
+ end
79
+
80
+ def warn_wrong_format
81
+ warn "Merging results, encountered an incorrectly formatted value. "\
82
+ "This value was ignored.\nIf you just upgraded simplecov this is "\
83
+ "likely due to a changed file format. If this happens again please "\
84
+ "file a bug. https://github.com/colszowka/simplecov/issues"
85
+ end
86
+
87
+ #
88
+ # Combine two files coverage results
89
+ #
90
+ # @param [Hash] coverage_a
91
+ # @param [Hash] coverage_b
92
+ #
93
+ # @return [Hash]
94
+ #
95
+ def combine_file_coverage(coverage_a, coverage_b)
96
+ Combine.combine(Combine::FilesCombiner, coverage_a, coverage_b)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -1,7 +1,9 @@
1
- #
2
- # Helper that tries to find out what test suite is running (for SimpleCov.command_name)
3
- #
1
+ # frozen_string_literal: true
2
+
4
3
  module SimpleCov
4
+ #
5
+ # Helper that tries to find out what test suite is running (for SimpleCov.command_name)
6
+ #
5
7
  module CommandGuesser
6
8
  class << self
7
9
  # Storage for the original command line call that invoked the test suite.
@@ -20,6 +22,7 @@ module SimpleCov
20
22
  def from_env
21
23
  # If being run from inside parallel_tests set the command name according to the process number
22
24
  return unless ENV["PARALLEL_TEST_GROUPS"] && ENV["TEST_ENV_NUMBER"]
25
+
23
26
  number = ENV["TEST_ENV_NUMBER"]
24
27
  number = "1" if number.empty?
25
28
  "(#{number}/#{ENV['PARALLEL_TEST_GROUPS']})"
@@ -46,6 +49,8 @@ module SimpleCov
46
49
  "RSpec"
47
50
  elsif defined?(Test::Unit)
48
51
  "Unit Tests"
52
+ elsif defined?(Minitest)
53
+ "Minitest"
49
54
  elsif defined?(MiniTest)
50
55
  "MiniTest"
51
56
  else
@@ -1,14 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "fileutils"
2
4
  require "docile"
3
5
  require "simplecov/formatter/multi_formatter"
4
- #
5
- # Bundles the configuration options used for SimpleCov. All methods
6
- # defined here are usable from SimpleCov directly. Please check out
7
- # SimpleCov documentation for further info.
8
- #
6
+
9
7
  module SimpleCov
10
- module Configuration # rubocop:disable ModuleLength
11
- attr_writer :filters, :groups, :formatter
8
+ #
9
+ # Bundles the configuration options used for SimpleCov. All methods
10
+ # defined here are usable from SimpleCov directly. Please check out
11
+ # SimpleCov documentation for further info.
12
+ #
13
+ module Configuration # rubocop:disable Metrics/ModuleLength
14
+ attr_writer :filters, :groups, :formatter, :print_error_status
12
15
 
13
16
  #
14
17
  # The root for the project. This defaults to the
@@ -18,6 +21,7 @@ module SimpleCov
18
21
  #
19
22
  def root(root = nil)
20
23
  return @root if defined?(@root) && root.nil?
24
+
21
25
  @root = File.expand_path(root || Dir.getwd)
22
26
  end
23
27
 
@@ -28,6 +32,7 @@ module SimpleCov
28
32
  #
29
33
  def coverage_dir(dir = nil)
30
34
  return @coverage_dir if defined?(@coverage_dir) && dir.nil?
35
+
31
36
  @coverage_path = nil # invalidate cache
32
37
  @coverage_dir = (dir || "coverage")
33
38
  end
@@ -91,8 +96,10 @@ module SimpleCov
91
96
  #
92
97
  def formatter(formatter = nil)
93
98
  return @formatter if defined?(@formatter) && formatter.nil?
99
+
94
100
  @formatter = formatter
95
101
  raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
102
+
96
103
  @formatter
97
104
  end
98
105
 
@@ -114,6 +121,14 @@ module SimpleCov
114
121
  end
115
122
  end
116
123
 
124
+ #
125
+ # Whether we should print non-success status codes. This can be
126
+ # configured with the #print_error_status= method.
127
+ #
128
+ def print_error_status
129
+ defined?(@print_error_status) ? @print_error_status : true
130
+ end
131
+
117
132
  #
118
133
  # Certain code blocks (i.e. Ruby-implementation specific code) can be excluded from
119
134
  # the coverage metrics by wrapping it inside # :nocov: comment blocks. The nocov token
@@ -123,6 +138,7 @@ module SimpleCov
123
138
  #
124
139
  def nocov_token(nocov_token = nil)
125
140
  return @nocov_token if defined?(@nocov_token) && nocov_token.nil?
141
+
126
142
  @nocov_token = (nocov_token || "nocov")
127
143
  end
128
144
  alias skip_token nocov_token
@@ -158,7 +174,6 @@ module SimpleCov
158
174
  # options at once.
159
175
  #
160
176
  def configure(&block)
161
- return false unless SimpleCov.usable?
162
177
  Docile.dsl_eval(self, &block)
163
178
  end
164
179
 
@@ -176,6 +191,7 @@ module SimpleCov
176
191
  #
177
192
  def at_exit(&block)
178
193
  return proc {} unless running || block_given?
194
+
179
195
  @at_exit = block if block_given?
180
196
  @at_exit ||= proc { SimpleCov.result.format! }
181
197
  end
@@ -186,6 +202,7 @@ module SimpleCov
186
202
  #
187
203
  def project_name(new_name = nil)
188
204
  return @project_name if defined?(@project_name) && @project_name && new_name.nil?
205
+
189
206
  @project_name = new_name if new_name.is_a?(String)
190
207
  @project_name ||= File.basename(root.split("/").last).capitalize.tr("_", " ")
191
208
  end
@@ -223,6 +240,7 @@ module SimpleCov
223
240
  # Default is 0% (disabled)
224
241
  #
225
242
  def minimum_coverage(coverage = nil)
243
+ minimum_possible_coverage_exceeded("minimum_coverage") if coverage && coverage > 100
226
244
  @minimum_coverage ||= (coverage || 0).to_f.round(2)
227
245
  end
228
246
 
@@ -244,6 +262,7 @@ module SimpleCov
244
262
  # Default is 0% (disabled)
245
263
  #
246
264
  def minimum_coverage_by_file(coverage = nil)
265
+ minimum_possible_coverage_exceeded("minimum_coverage_by_file") if coverage && coverage > 100
247
266
  @minimum_coverage_by_file ||= (coverage || 0).to_f.round(2)
248
267
  end
249
268
 
@@ -285,8 +304,76 @@ module SimpleCov
285
304
  groups[group_name] = parse_filter(filter_argument, &filter_proc)
286
305
  end
287
306
 
307
+ SUPPORTED_COVERAGE_CRITERIA = %i[line branch].freeze
308
+ DEFAULT_COVERAGE_CRITERION = :line
309
+ #
310
+ # Define which coverage criterion should be evaluated.
311
+ #
312
+ # Possible coverage criteria:
313
+ # * :line - coverage based on lines aka has this line been executed?
314
+ # * :branch - coverage based on branches aka has this branch (think conditions) been executed?
315
+ #
316
+ # If not set the default is `:line`
317
+ #
318
+ # @param [Symbol] criterion
319
+ #
320
+ def coverage_criterion(criterion = nil)
321
+ return @coverage_criterion ||= DEFAULT_COVERAGE_CRITERION unless criterion
322
+
323
+ raise_if_criterion_unsupported(criterion)
324
+
325
+ @coverage_criterion = criterion
326
+ end
327
+
328
+ def enable_coverage(criterion)
329
+ raise_if_criterion_unsupported(criterion)
330
+
331
+ coverage_criteria << criterion
332
+ end
333
+
334
+ def coverage_criteria
335
+ @coverage_criteria ||= Set[DEFAULT_COVERAGE_CRITERION]
336
+ end
337
+
338
+ def coverage_criterion_enabled?(criterion)
339
+ coverage_criteria.member?(criterion)
340
+ end
341
+
342
+ def clear_coverage_criteria
343
+ @coverage_criteria = nil
344
+ end
345
+
346
+ def branch_coverage?
347
+ branch_coverage_supported? && coverage_criterion_enabled?(:branch)
348
+ end
349
+
350
+ def coverage_start_arguments_supported?
351
+ # safe to cache as within one process this value should never
352
+ # change
353
+ return @coverage_start_arguments_supported if defined?(@coverage_start_arguments_supported)
354
+
355
+ @coverage_start_arguments_supported = begin
356
+ require "coverage"
357
+ !Coverage.method(:start).arity.zero?
358
+ end
359
+ end
360
+
361
+ alias branch_coverage_supported? coverage_start_arguments_supported?
362
+
288
363
  private
289
364
 
365
+ def raise_if_criterion_unsupported(criterion)
366
+ raise_criterion_unsupported(criterion) unless SUPPORTED_COVERAGE_CRITERIA.member?(criterion)
367
+ end
368
+
369
+ def raise_criterion_unsupported(criterion)
370
+ raise "Unsupported coverage criterion #{criterion}, supported values are #{SUPPORTED_COVERAGE_CRITERIA}"
371
+ end
372
+
373
+ def minimum_possible_coverage_exceeded(coverage_option)
374
+ warn "The coverage you set for #{coverage_option} is greater than 100%"
375
+ end
376
+
290
377
  #
291
378
  # The actual filter processor. Not meant for direct use
292
379
  #