simplecov 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +148 -5
- data/exe/simplecov +0 -3
- data/lib/minitest/simplecov_plugin.rb +12 -9
- data/lib/simplecov/atomic_file.rb +16 -19
- data/lib/simplecov/autostart.rb +5 -7
- data/lib/simplecov/baseline/parser.rb +58 -0
- data/lib/simplecov/baseline.rb +170 -0
- data/lib/simplecov/cli/affected/changed_files.rb +57 -0
- data/lib/simplecov/cli/affected/selection.rb +117 -0
- data/lib/simplecov/cli/affected.rb +148 -0
- data/lib/simplecov/cli/annotations.rb +166 -0
- data/lib/simplecov/cli/badge/svg.rb +70 -0
- data/lib/simplecov/cli/badge.rb +62 -0
- data/lib/simplecov/cli/clean.rb +23 -24
- data/lib/simplecov/cli/command_helpers.rb +55 -19
- data/lib/simplecov/cli/completions/scripts.rb +114 -0
- data/lib/simplecov/cli/completions.rb +83 -0
- data/lib/simplecov/cli/coverage.rb +25 -28
- data/lib/simplecov/cli/coverage_file.rb +58 -14
- data/lib/simplecov/cli/dead_code/output.rb +100 -0
- data/lib/simplecov/cli/dead_code.rb +139 -0
- data/lib/simplecov/cli/diff/output.rb +45 -0
- data/lib/simplecov/cli/diff.rb +35 -67
- data/lib/simplecov/cli/dotfile.rb +83 -38
- data/lib/simplecov/cli/git.rb +41 -0
- data/lib/simplecov/cli/history/output.rb +135 -0
- data/lib/simplecov/cli/history.rb +67 -0
- data/lib/simplecov/cli/merge.rb +34 -39
- data/lib/simplecov/cli/open.rb +12 -15
- data/lib/simplecov/cli/patch/changed_lines.rb +149 -0
- data/lib/simplecov/cli/patch/output.rb +151 -0
- data/lib/simplecov/cli/patch.rb +175 -0
- data/lib/simplecov/cli/ratchet/output.rb +44 -0
- data/lib/simplecov/cli/ratchet.rb +83 -0
- data/lib/simplecov/cli/report.rb +18 -24
- data/lib/simplecov/cli/run.rb +8 -9
- data/lib/simplecov/cli/serve/report_preparer.rb +7 -6
- data/lib/simplecov/cli/serve/static_file_handler.rb +62 -56
- data/lib/simplecov/cli/serve.rb +27 -24
- data/lib/simplecov/cli/show/annotator.rb +87 -0
- data/lib/simplecov/cli/show/sweep.rb +36 -0
- data/lib/simplecov/cli/show.rb +133 -0
- data/lib/simplecov/cli/status/facts.rb +87 -0
- data/lib/simplecov/cli/status.rb +93 -0
- data/lib/simplecov/cli/tests/redundancy.rb +78 -0
- data/lib/simplecov/cli/tests.rb +148 -0
- data/lib/simplecov/cli/uncovered/misses.rb +33 -0
- data/lib/simplecov/cli/uncovered.rb +58 -34
- data/lib/simplecov/cli/usage.rb +153 -0
- data/lib/simplecov/cli/watch/live_report.rb +73 -0
- data/lib/simplecov/cli/watch/narrator.rb +55 -0
- data/lib/simplecov/cli/watch/poller.rb +45 -0
- data/lib/simplecov/cli/watch/session.rb +134 -0
- data/lib/simplecov/cli/watch/test_plan.rb +43 -0
- data/lib/simplecov/cli/watch.rb +85 -0
- data/lib/simplecov/cli.rb +43 -92
- data/lib/simplecov/color.rb +19 -37
- data/lib/simplecov/combine/branches_combiner.rb +7 -31
- data/lib/simplecov/combine/coverage_accumulator.rb +49 -142
- data/lib/simplecov/combine/identity_interner.rb +10 -13
- data/lib/simplecov/combine/interned_counts.rb +7 -9
- data/lib/simplecov/combine/lines_combiner.rb +20 -44
- data/lib/simplecov/combine/methods_combiner.rb +9 -35
- data/lib/simplecov/combine/results_combiner.rb +4 -21
- data/lib/simplecov/combine.rb +0 -6
- data/lib/simplecov/command_guesser.rb +20 -34
- data/lib/simplecov/configuration/baseline.rb +31 -0
- data/lib/simplecov/configuration/coverage.rb +91 -79
- data/lib/simplecov/configuration/coverage_criteria.rb +43 -54
- data/lib/simplecov/configuration/deprecations.rb +21 -0
- data/lib/simplecov/configuration/eval_coverage.rb +7 -11
- data/lib/simplecov/configuration/filters.rb +40 -73
- data/lib/simplecov/configuration/formatting.rb +74 -83
- data/lib/simplecov/configuration/groups.rb +19 -13
- data/lib/simplecov/configuration/history.rb +44 -0
- data/lib/simplecov/configuration/ignored_entries.rb +31 -22
- data/lib/simplecov/configuration/merging.rb +94 -62
- data/lib/simplecov/configuration/missed_caps.rb +51 -0
- data/lib/simplecov/configuration/production.rb +23 -0
- data/lib/simplecov/configuration/test_tracking.rb +48 -0
- data/lib/simplecov/configuration/thresholds.rb +33 -62
- data/lib/simplecov/configuration/view_coverage.rb +37 -0
- data/lib/simplecov/configuration.rb +70 -76
- data/lib/simplecov/configuration_error.rb +5 -0
- data/lib/simplecov/context_map/union.rb +81 -0
- data/lib/simplecov/context_map.rb +187 -0
- data/lib/simplecov/coverage_json.rb +2 -5
- data/lib/simplecov/coverage_statistics.rb +14 -24
- data/lib/simplecov/coverage_violations.rb +160 -65
- data/lib/simplecov/current_run.rb +61 -0
- data/lib/simplecov/defaults.rb +4 -23
- data/lib/simplecov/deprecation.rb +45 -27
- data/lib/simplecov/directive/erb.rb +44 -0
- data/lib/simplecov/directive/haml.rb +33 -0
- data/lib/simplecov/directive/indented_template.rb +37 -0
- data/lib/simplecov/directive/slim.rb +35 -0
- data/lib/simplecov/directive/template.rb +29 -0
- data/lib/simplecov/directive.rb +47 -62
- data/lib/simplecov/exit_codes/baseline_check.rb +46 -0
- data/lib/simplecov/exit_codes/check.rb +17 -11
- data/lib/simplecov/exit_codes/exit_code_handling.rb +21 -8
- data/lib/simplecov/exit_codes/maximum_coverage_drop_check.rb +7 -10
- data/lib/simplecov/exit_codes/maximum_missed_check.rb +26 -0
- data/lib/simplecov/exit_codes/maximum_missed_per_file_check.rb +34 -0
- data/lib/simplecov/exit_codes/maximum_overall_coverage_check.rb +7 -12
- data/lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb +11 -10
- data/lib/simplecov/exit_codes/minimum_coverage_by_group_check.rb +7 -9
- data/lib/simplecov/exit_codes/minimum_overall_coverage_check.rb +16 -17
- data/lib/simplecov/exit_codes.rb +16 -10
- data/lib/simplecov/exit_handling.rb +94 -59
- data/lib/simplecov/file_list.rb +20 -51
- data/lib/simplecov/filter.rb +43 -66
- data/lib/simplecov/formatter/base.rb +37 -55
- data/lib/simplecov/formatter/baseline_formatter.rb +98 -0
- data/lib/simplecov/formatter/coverage_json_writer.rb +29 -31
- data/lib/simplecov/formatter/html_formatter/public/index.html +15 -9
- data/lib/simplecov/formatter/html_formatter/viewer_data_validator.rb +74 -17
- data/lib/simplecov/formatter/html_formatter.rb +24 -41
- data/lib/simplecov/formatter/json_formatter/errors_formatter.rb +50 -16
- data/lib/simplecov/formatter/json_formatter/production_section_formatter.rb +48 -0
- data/lib/simplecov/formatter/json_formatter/result_hash_formatter.rb +43 -29
- data/lib/simplecov/formatter/json_formatter/source_file_formatter.rb +14 -10
- data/lib/simplecov/formatter/json_formatter.rb +7 -13
- data/lib/simplecov/formatter/multi_formatter.rb +5 -11
- data/lib/simplecov/formatter/simple_formatter.rb +2 -8
- data/lib/simplecov/formatter.rb +14 -10
- data/lib/simplecov/group_names.rb +13 -12
- data/lib/simplecov/history.rb +115 -0
- data/lib/simplecov/last_run.rb +6 -9
- data/lib/simplecov/lines_classifier.rb +31 -16
- data/lib/simplecov/load_global_config.rb +7 -7
- data/lib/simplecov/parallel_adapters/base.rb +13 -41
- data/lib/simplecov/parallel_adapters/generic.rb +7 -19
- data/lib/simplecov/parallel_adapters/parallel_tests.rb +21 -42
- data/lib/simplecov/parallel_adapters.rb +24 -55
- data/lib/simplecov/parallel_coordination.rb +39 -49
- data/lib/simplecov/parallel_result_merger/worker_payload.rb +33 -0
- data/lib/simplecov/parallel_result_merger.rb +67 -126
- data/lib/simplecov/process.rb +14 -32
- data/lib/simplecov/production/error.rb +11 -0
- data/lib/simplecov/production/file_sink.rb +130 -0
- data/lib/simplecov/production.rb +249 -0
- data/lib/simplecov/profiles/rails.rb +4 -15
- data/lib/simplecov/profiles/root_filter.rb +0 -4
- data/lib/simplecov/profiles/strict.rb +11 -21
- data/lib/simplecov/profiles.rb +11 -33
- data/lib/simplecov/report_deferral.rb +11 -15
- data/lib/simplecov/report_stamp.rb +6 -9
- data/lib/simplecov/result/filter_config.rb +19 -0
- data/lib/simplecov/result/missing_source_files_reporter.rb +8 -9
- data/lib/simplecov/result/serialization.rb +43 -0
- data/lib/simplecov/result/source_file_builder.rb +7 -12
- data/lib/simplecov/result.rb +74 -117
- data/lib/simplecov/result_adapter.rb +56 -68
- data/lib/simplecov/result_merger/contexts.rb +22 -0
- data/lib/simplecov/result_merger/legacy_format_adapter.rb +4 -8
- data/lib/simplecov/result_merger/resultset_file.rb +20 -27
- data/lib/simplecov/result_merger/resultset_run_identity.rb +23 -25
- data/lib/simplecov/result_merger/resultset_store.rb +23 -14
- data/lib/simplecov/result_merger/unloaded_files.rb +24 -32
- data/lib/simplecov/result_merger.rb +59 -58
- data/lib/simplecov/result_processing.rb +92 -122
- data/lib/simplecov/run_identity.rb +16 -18
- data/lib/simplecov/simulate_coverage.rb +34 -50
- data/lib/simplecov/source_file/branch.rb +8 -33
- data/lib/simplecov/source_file/branch_builder.rb +28 -47
- data/lib/simplecov/source_file/builder_context.rb +13 -13
- data/lib/simplecov/source_file/line.rb +13 -33
- data/lib/simplecov/source_file/line_builder.rb +9 -15
- data/lib/simplecov/source_file/method.rb +3 -7
- data/lib/simplecov/source_file/method_builder.rb +6 -15
- data/lib/simplecov/source_file/ruby_data_parser.rb +59 -66
- data/lib/simplecov/source_file/skip_chunks.rb +29 -29
- data/lib/simplecov/source_file/source_loader.rb +45 -35
- data/lib/simplecov/source_file/statistics.rb +20 -9
- data/lib/simplecov/source_file.rb +21 -51
- data/lib/simplecov/static_coverage_extractor/condition_folding.rb +55 -139
- data/lib/simplecov/static_coverage_extractor/location_conventions.rb +76 -121
- data/lib/simplecov/static_coverage_extractor/method_collector.rb +9 -26
- data/lib/simplecov/static_coverage_extractor/prism_compat.rb +15 -24
- data/lib/simplecov/static_coverage_extractor/value_position.rb +25 -38
- data/lib/simplecov/static_coverage_extractor/visitor.rb +45 -65
- data/lib/simplecov/static_coverage_extractor.rb +43 -75
- data/lib/simplecov/test_tracker/accessors.rb +34 -0
- data/lib/simplecov/test_tracker/constant_watch.rb +49 -0
- data/lib/simplecov/test_tracker/delta.rb +69 -0
- data/lib/simplecov/test_tracker/framework_hooks.rb +130 -0
- data/lib/simplecov/test_tracker.rb +162 -0
- data/lib/simplecov/unloaded_file_injector.rb +18 -31
- data/lib/simplecov/useless_results_remover.rb +7 -6
- data/lib/simplecov/version.rb +1 -1
- data/lib/simplecov/view_coverage/template_compiler.rb +83 -0
- data/lib/simplecov/view_coverage.rb +55 -0
- data/lib/simplecov-html.rb +1 -0
- data/lib/simplecov.rb +57 -113
- data/lib/simplecov_json_formatter.rb +1 -0
- data/man/simplecov.1 +354 -0
- data/sig/simplecov.rbs +528 -595
- metadata +79 -6
data/sig/simplecov.rbs
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
# Code coverage for Ruby. See the README for a full introduction.
|
|
2
1
|
module SimpleCov
|
|
3
|
-
# A coverage criterion that can be enabled, measured, and reported.
|
|
4
2
|
type criterion = :line | :branch | :method
|
|
5
3
|
type line_coverage_alternatives = Hash[criterion | :oneshot_line, :line | :oneshot_line]
|
|
6
4
|
|
|
7
|
-
# Anything accepted by `skip` / `group` (and the deprecated
|
|
8
|
-
# `add_filter` / `add_group`): a path-segment substring, a Regexp, a
|
|
9
|
-
# prebuilt Filter, a predicate on the SourceFile, or an Array of those.
|
|
10
5
|
type filter_arg = String | Regexp | Filter[untyped] | ^(SourceFile source_file) -> boolish | Array[filter_arg]
|
|
11
6
|
|
|
12
|
-
# Anything accepted by `cover`: a shell-glob String, Regexp, Proc,
|
|
13
|
-
# prebuilt Filter, or an Array of those.
|
|
14
7
|
type cover_arg = String | Regexp | ^(SourceFile source_file) -> boolish | Filter[untyped] | Array[cover_arg]
|
|
15
8
|
|
|
16
|
-
# Raised when a user's configuration is internally inconsistent — e.g.
|
|
17
|
-
# every coverage criterion has been disabled.
|
|
18
9
|
class ConfigurationError < StandardError
|
|
19
10
|
end
|
|
20
11
|
|
|
@@ -26,36 +17,40 @@ module SimpleCov
|
|
|
26
17
|
def self?.validate!: (Array[String] group_names) -> Array[String]
|
|
27
18
|
end
|
|
28
19
|
|
|
29
|
-
# Maps SimpleCov's criterion names to the keys `Coverage.start` expects.
|
|
30
20
|
CRITERION_TO_RUBY_COVERAGE: Hash[Symbol, Symbol]
|
|
31
21
|
|
|
32
22
|
extend Configuration
|
|
23
|
+
extend SingleForwardable
|
|
33
24
|
|
|
34
|
-
self.@
|
|
35
|
-
self.@forked_subprocess: bool?
|
|
25
|
+
self.@current_run: CurrentRun?
|
|
36
26
|
self.@autoloading_dot_simplecov: bool?
|
|
37
27
|
self.@dot_simplecov_start_warned: bool?
|
|
38
28
|
self.@at_exit_hook_installed: bool?
|
|
39
29
|
self.@run_id: String?
|
|
40
30
|
self.@worker_id: String?
|
|
41
31
|
|
|
32
|
+
def self.current_run: () -> CurrentRun
|
|
33
|
+
|
|
34
|
+
attr_writer self.current_run: CurrentRun?
|
|
35
|
+
|
|
42
36
|
attr_accessor self.pid: Integer?
|
|
43
37
|
|
|
44
|
-
# When this process started tracking coverage.
|
|
45
38
|
attr_accessor self.process_start_time: Time?
|
|
46
39
|
|
|
47
40
|
def self.run_id: () -> String
|
|
48
41
|
|
|
49
42
|
def self.worker_id: () -> String
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
def self.track_test: [T] (String test_id) { () -> T } -> T
|
|
45
|
+
|
|
46
|
+
def self.test_tracker: () -> TestTracker?
|
|
47
|
+
|
|
48
|
+
def self.start_test_tracking: () -> void
|
|
49
|
+
|
|
53
50
|
attr_accessor self.external_at_exit: bool?
|
|
54
51
|
|
|
55
52
|
def self.external_at_exit?: () -> bool
|
|
56
53
|
|
|
57
|
-
# A monotonically increasing serial assigned to each forked
|
|
58
|
-
# subprocess; the default `at_fork` builds worker command names from it.
|
|
59
54
|
def self.subprocess_serial: () -> Integer
|
|
60
55
|
|
|
61
56
|
def self.next_subprocess_serial!: () -> Integer
|
|
@@ -64,38 +59,20 @@ module SimpleCov
|
|
|
64
59
|
|
|
65
60
|
def self.mark_forked_subprocess!: () -> void
|
|
66
61
|
|
|
67
|
-
# `:oneshot_line` stats are folded into the `:line` bucket, so use
|
|
68
|
-
# the returned criterion to look up `coverage_statistics`.
|
|
69
62
|
def self.coverage_statistics_key: ((criterion | :oneshot_line) criterion) -> criterion
|
|
70
63
|
|
|
71
|
-
# Sets up SimpleCov to run against your project:
|
|
72
|
-
#
|
|
73
|
-
# SimpleCov.start
|
|
74
|
-
# SimpleCov.start 'rails' # using a profile
|
|
75
|
-
# SimpleCov.start { skip 'test' } # with a config block
|
|
76
|
-
#
|
|
77
64
|
def self.start: (?(String | Symbol)? profile) ?{ () [self: singleton(SimpleCov)] -> void } -> void
|
|
78
65
|
|
|
79
66
|
def self.with_dot_simplecov_autoload: [T] () { () -> T } -> T
|
|
80
67
|
|
|
81
68
|
def self.warn_about_start_in_dot_simplecov: () -> void
|
|
82
69
|
|
|
83
|
-
# Install the at_exit hook that formats results and runs exit-code
|
|
84
|
-
# checks. Idempotent; `SimpleCov.start` calls this automatically.
|
|
85
70
|
def self.install_at_exit_hook: () -> void
|
|
86
71
|
|
|
87
|
-
# Reset at_exit state a forked child inherits from its parent (a
|
|
88
|
-
# possibly consumed hook and a Minitest deferral pid-pinned to the
|
|
89
|
-
# parent), so the child re-arms a hook that fires at its own exit.
|
|
90
|
-
# Called by the fork hook; see issue #1227.
|
|
91
72
|
def self.reset_inherited_at_exit_state!: () -> void
|
|
92
73
|
|
|
93
|
-
# Begin coverage tracking without applying configuration. Pairs with
|
|
94
|
-
# `SimpleCov.configure { ... }`.
|
|
95
74
|
def self.start_tracking: () -> void
|
|
96
75
|
|
|
97
|
-
# Implementation details of `start` / `start_tracking` (private in Ruby;
|
|
98
|
-
# RBS cannot mark singleton methods private).
|
|
99
76
|
def self.start_coverage_measurement: () -> void
|
|
100
77
|
|
|
101
78
|
def self.minitest_autorun_pending?: () -> bool
|
|
@@ -105,90 +82,61 @@ module SimpleCov
|
|
|
105
82
|
def self.warn_if_jruby_full_trace_disabled: () -> void
|
|
106
83
|
end
|
|
107
84
|
|
|
108
|
-
# ----- version -----
|
|
109
85
|
|
|
110
86
|
module SimpleCov
|
|
111
87
|
VERSION: String
|
|
112
88
|
end
|
|
113
89
|
|
|
114
|
-
# ----- result_processing -----
|
|
115
90
|
|
|
116
|
-
# Result-building façade: turns the raw `Coverage.result` hash into a
|
|
117
|
-
# `SimpleCov::Result`, applies filters and groups, drives merging, and
|
|
118
|
-
# exposes the `collate` entry point.
|
|
119
91
|
module SimpleCov
|
|
120
92
|
self.@result: Result?
|
|
121
|
-
self.@collating_result: bool?
|
|
122
93
|
|
|
123
|
-
# Collate a series of resultset files into a single merged report. By
|
|
124
|
-
# default ignores `merge_timeout` so every listed resultset merges;
|
|
125
|
-
# pass `ignore_timeout: false` to honor it. `processes:` above 1 fans the
|
|
126
|
-
# merge out across that many forked workers, for an identical report;
|
|
127
|
-
# anything below 1 is taken as 1.
|
|
128
94
|
def self.collate: (Array[String] result_filenames, ?(String | Symbol)? profile, ?processes: Integer, ?ignore_timeout: bool) ?{ () [self: singleton(SimpleCov)] -> void } -> void
|
|
129
95
|
|
|
130
|
-
# The result for the current coverage run, merged across test suites
|
|
131
|
-
# when merging is active. nil when no coverage was tracked.
|
|
132
96
|
def self.result: () -> Result?
|
|
133
97
|
|
|
134
|
-
|
|
98
|
+
def self.merge_own_slice: () -> untyped
|
|
99
|
+
|
|
100
|
+
def self.build_result: (untyped raw, untyped coverage, not_loaded: untyped, tracked: untyped, report: untyped) -> Result
|
|
101
|
+
|
|
135
102
|
def self.result?: () -> (Result | false | nil)
|
|
136
103
|
|
|
137
104
|
def self.collating_result?: () -> boolish
|
|
138
105
|
|
|
139
|
-
# Applies the configured filters to the given source files.
|
|
140
106
|
def self.filtered: ((Array[SourceFile] | FileList) files) -> FileList
|
|
141
107
|
|
|
142
|
-
# Bin the given source files by group filter. Files matched by no
|
|
143
|
-
# group fall into the implicit "Ungrouped" bucket.
|
|
144
108
|
def self.grouped: ((Array[SourceFile] | FileList) files, ?groups: Hash[String, Filter[untyped]]) -> Hash[String, FileList]
|
|
145
109
|
|
|
146
|
-
# Applies the profile of the given name to the configuration.
|
|
147
110
|
def self.load_profile: ((String | Symbol) name) -> void
|
|
148
111
|
|
|
149
|
-
# Clear the cached result. Primarily useful in testing.
|
|
150
112
|
def self.clear_result: () -> void
|
|
151
113
|
|
|
152
114
|
def self.write_last_run: (Result result) -> void
|
|
153
115
|
|
|
154
|
-
# Round coverage down to two decimals.
|
|
155
116
|
def self.round_coverage: (Numeric coverage) -> Numeric
|
|
156
117
|
|
|
157
|
-
# Implementation details of `collate` / `result` (private in Ruby;
|
|
158
|
-
# RBS cannot mark singleton methods private).
|
|
159
118
|
def self.initial_setup: ((String | Symbol)? profile) ?{ () [self: singleton(SimpleCov)] -> void } -> void
|
|
160
119
|
|
|
161
120
|
def self.grouped_file_set: (Hash[String, FileList] grouped) -> Set[SourceFile]
|
|
162
121
|
|
|
163
122
|
def self.unloaded_file_discovery_globs: () -> Array[String]
|
|
164
123
|
|
|
165
|
-
# Every path this process was told to track, whether or not it loaded them.
|
|
166
|
-
# Recorded on the result (and from there into the resultset) so that a merge
|
|
167
|
-
# in another process can inject the ones nobody loaded without needing this
|
|
168
|
-
# process's `cover` / `track_files` configuration.
|
|
169
124
|
def self.tracked_file_paths: () -> Array[String]
|
|
170
125
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
#
|
|
174
|
-
# @api private — the seam `SimpleCov::ResultMerger` injects through.
|
|
126
|
+
def self.warn_templates_tracked: (Array[String] templates) -> void
|
|
127
|
+
|
|
175
128
|
def self.inject_unloaded_files: (Hash[String, untyped] result, Array[String] candidate_paths, ?synthesize: bool?, ?lines: bool?) -> [Hash[String, untyped], Set[String]]
|
|
176
129
|
|
|
177
|
-
# Build this process's slice of the coverage result. `standalone` is true
|
|
178
|
-
# when no merge step follows, which makes this the final result: it is the
|
|
179
|
-
# one that reports dropped source files, and the one that injects unloaded
|
|
180
|
-
# files. When a merge does follow, both jobs belong to the merged result.
|
|
181
130
|
def self.collect_own_coverage: (standalone: bool) -> void
|
|
182
131
|
|
|
183
132
|
def self.process_coverage_result: (report: bool, ?inject_unloaded: bool) -> void
|
|
184
133
|
end
|
|
185
134
|
|
|
186
|
-
# ----- configuration -----
|
|
187
135
|
|
|
188
|
-
# Bundles the configuration options used for SimpleCov. All methods
|
|
189
|
-
# defined here are usable from SimpleCov directly.
|
|
190
136
|
module SimpleCov
|
|
191
137
|
module Configuration
|
|
138
|
+
def __send__: (Symbol name, *untyped args) -> untyped
|
|
139
|
+
|
|
192
140
|
@root: String
|
|
193
141
|
@coverage_dir: String
|
|
194
142
|
@coverage_dir_explicit: bool?
|
|
@@ -200,66 +148,43 @@ module SimpleCov
|
|
|
200
148
|
@at_fork: Proc?
|
|
201
149
|
@project_name: String?
|
|
202
150
|
|
|
203
|
-
# The root for the project, defaulting to the current working
|
|
204
|
-
# directory. Get, or set with `SimpleCov.root('/my/project/path')`.
|
|
205
151
|
def root: (?String? root) -> String
|
|
206
152
|
|
|
207
|
-
|
|
153
|
+
def root=: (String? root) -> String
|
|
154
|
+
|
|
208
155
|
def coverage_dir: (?String? dir) -> String
|
|
209
156
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
# regardless of later `root` / `coverage_dir` changes (see #716).
|
|
157
|
+
def coverage_dir=: (String? dir) -> String
|
|
158
|
+
|
|
213
159
|
def coverage_path: (?String? path) -> String
|
|
214
160
|
|
|
215
|
-
|
|
216
|
-
|
|
161
|
+
def coverage_path=: (String path) -> untyped
|
|
162
|
+
|
|
217
163
|
def command_name: (?String? name) -> String
|
|
218
164
|
|
|
219
|
-
|
|
165
|
+
def command_name=: (String name) -> String
|
|
166
|
+
|
|
220
167
|
def profiles: () -> Profiles
|
|
221
168
|
|
|
222
|
-
# Configure SimpleCov in a block. A zero-argument block runs with the
|
|
223
|
-
# configuration target as `self`; a parameterized block keeps its lexical
|
|
224
|
-
# `self` and receives the target explicitly:
|
|
225
|
-
#
|
|
226
|
-
# SimpleCov.configure { skip "test" }
|
|
227
|
-
# SimpleCov.configure { |config| config.skip caller_filter }
|
|
228
|
-
#
|
|
229
169
|
def configure: () { () [self: self] -> untyped } -> self
|
|
230
170
|
| () { (self config) -> untyped } -> self
|
|
231
171
|
|
|
232
|
-
# Gets or sets the behavior that processes coverage results at
|
|
233
|
-
# process exit. The default stores/merges the current result and
|
|
234
|
-
# formats only from the final reporting process.
|
|
235
172
|
def at_exit: () ?{ () -> void } -> Proc
|
|
236
173
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
def
|
|
174
|
+
def active_session?: () -> bool
|
|
175
|
+
|
|
176
|
+
def coverage_running?: () -> bool
|
|
240
177
|
|
|
241
|
-
# Gets or sets the behavior run in a newly forked process. The
|
|
242
|
-
# block receives the child pid. The default renames the command
|
|
243
|
-
# from the fork serial, silences errors, and restarts SimpleCov.
|
|
244
178
|
def at_fork: () ?{ (Integer pid) -> void } -> Proc
|
|
245
179
|
|
|
246
|
-
# The project name — defaults to the last dirname in `root`,
|
|
247
|
-
# capitalized, with underscores replaced by spaces.
|
|
248
180
|
def project_name: (?String? new_name) -> String
|
|
249
181
|
|
|
250
182
|
end
|
|
251
183
|
end
|
|
252
184
|
|
|
253
|
-
# ----- configuration/coverage_criteria -----
|
|
254
185
|
|
|
255
|
-
# Selection and validation of the coverage criteria Ruby's `Coverage`
|
|
256
|
-
# library should track: `:line` (default), `:branch`, `:method`, and
|
|
257
|
-
# `:oneshot_line`. The standalone `:eval` toggle lives in
|
|
258
|
-
# `configuration/eval_coverage.rb`.
|
|
259
186
|
module SimpleCov
|
|
260
187
|
module Configuration
|
|
261
|
-
# Members are line, branch, method, and oneshot_line (%i[] literals
|
|
262
|
-
# infer as Array[Symbol]).
|
|
263
188
|
SUPPORTED_COVERAGE_CRITERIA: Array[Symbol]
|
|
264
189
|
|
|
265
190
|
DEFAULT_COVERAGE_CRITERION: :line
|
|
@@ -272,38 +197,22 @@ module SimpleCov
|
|
|
272
197
|
@coverage_criteria: Set[criterion | :oneshot_line]?
|
|
273
198
|
@coverage_for_eval_enabled: bool?
|
|
274
199
|
|
|
275
|
-
# Enable one or more coverage criteria. `:eval` is accepted as a
|
|
276
|
-
# shorthand for the standalone eval-coverage toggle. `:line` and
|
|
277
|
-
# `:oneshot_line` replace each other; the last enabled mode wins.
|
|
278
200
|
def enable_coverage: (*(criterion | :oneshot_line | :eval) criteria) -> void
|
|
279
201
|
|
|
280
|
-
# Remove `criterion` from the set of enabled coverage criteria.
|
|
281
|
-
# `:eval` turns the standalone eval-coverage toggle back off.
|
|
282
|
-
# Disabling every criterion raises at `start_tracking`, not here.
|
|
283
202
|
def disable_coverage: ((criterion | :oneshot_line | :eval) criterion) -> void
|
|
284
203
|
|
|
285
|
-
# Gets the report's leading criterion, or sets it. The setter
|
|
286
|
-
# validates at runtime that the criterion is enabled; the parameter
|
|
287
|
-
# type also rejects unknown criteria statically.
|
|
288
204
|
def primary_coverage: (?(criterion | :oneshot_line)? criterion) -> (criterion | :oneshot_line)
|
|
289
205
|
|
|
290
|
-
|
|
206
|
+
def primary_coverage=: ((criterion | :oneshot_line) criterion) -> (criterion | :oneshot_line)
|
|
207
|
+
|
|
291
208
|
def coverage_criteria: () -> Set[criterion | :oneshot_line]
|
|
292
209
|
|
|
293
|
-
# Any Symbol is accepted: asking whether an unknown criterion is
|
|
294
|
-
# enabled is a legitimate question (the answer is false), and the
|
|
295
|
-
# private validators rely on it.
|
|
296
210
|
def coverage_criterion_enabled?: (Symbol criterion) -> bool
|
|
297
211
|
|
|
298
|
-
# Reset the criteria back to the lazy default (`Set[:line]`).
|
|
299
212
|
def clear_coverage_criteria: () -> void
|
|
300
213
|
|
|
301
214
|
def validate_coverage_criteria!: () -> void
|
|
302
215
|
|
|
303
|
-
# Whether this run produces line data at all. The oneshot variant counts:
|
|
304
|
-
# `ResultAdapter` turns its executed-line list back into a line array. A
|
|
305
|
-
# branch-only or method-only run produces none, and `Coverage.result`
|
|
306
|
-
# entries for the files it loaded carry no `"lines"` key.
|
|
307
216
|
def line_coverage?: () -> bool
|
|
308
217
|
|
|
309
218
|
def branch_coverage?: () -> bool
|
|
@@ -314,37 +223,29 @@ module SimpleCov
|
|
|
314
223
|
|
|
315
224
|
def method_coverage_supported?: () -> bool
|
|
316
225
|
|
|
317
|
-
# Whether the running Ruby's Coverage library supports the given
|
|
318
|
-
# criterion, named in Coverage's own plural vocabulary
|
|
319
|
-
# (`:lines`, `:branches`, `:methods`, `:oneshot_lines`, `:eval`).
|
|
320
226
|
def coverage_criterion_supported?: (Symbol criterion) -> bool
|
|
321
227
|
|
|
228
|
+
def load_coverage: () -> untyped
|
|
229
|
+
|
|
322
230
|
private
|
|
323
231
|
|
|
324
232
|
def add_coverage_criterion: ((criterion | :oneshot_line) criterion) -> void
|
|
325
233
|
|
|
326
234
|
def default_primary_coverage: () -> (criterion | :oneshot_line)
|
|
327
235
|
|
|
328
|
-
# Validators: any Symbol is accepted at the type level; the whole
|
|
329
|
-
# point of these is raising ConfigurationError on bad input.
|
|
330
236
|
def raise_if_criterion_disabled: (Symbol criterion) -> void
|
|
331
237
|
|
|
332
238
|
def raise_if_criterion_unsupported: (Symbol criterion) -> void
|
|
333
239
|
end
|
|
334
240
|
end
|
|
335
241
|
|
|
336
|
-
# ----- configuration/eval_coverage -----
|
|
337
242
|
|
|
338
|
-
# The standalone eval-coverage toggle (`enable_coverage :eval`),
|
|
339
|
-
# instrumenting `eval`'d code on Rubies that support it. A boolean
|
|
340
|
-
# toggle, never a member of the enabled-criteria set.
|
|
341
243
|
module SimpleCov
|
|
342
244
|
module Configuration
|
|
343
245
|
def coverage_for_eval_supported?: () -> bool
|
|
344
246
|
|
|
345
247
|
def coverage_for_eval_enabled?: () -> bool
|
|
346
248
|
|
|
347
|
-
# DEPRECATED: use `enable_coverage :eval` instead.
|
|
348
249
|
def enable_coverage_for_eval: () -> void
|
|
349
250
|
|
|
350
251
|
private
|
|
@@ -355,97 +256,92 @@ module SimpleCov
|
|
|
355
256
|
end
|
|
356
257
|
end
|
|
357
258
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
259
|
+
|
|
260
|
+
module SimpleCov
|
|
261
|
+
module Configuration
|
|
262
|
+
DEFAULT_VIEW_GLOBS: Array[String]
|
|
263
|
+
|
|
264
|
+
@view_globs: Array[String]?
|
|
265
|
+
|
|
266
|
+
def cover_views: (*(String | Array[String?] | nil) globs) -> Array[String]
|
|
267
|
+
|
|
268
|
+
def view_globs: () -> Array[String]?
|
|
269
|
+
|
|
270
|
+
def view_coverage?: () -> bool
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
|
|
374
275
|
module SimpleCov
|
|
375
276
|
module Configuration
|
|
376
|
-
# Members are minimum, maximum, exact, maximum_drop, and
|
|
377
|
-
# minimum_per_file (%i[] literals infer as Array[Symbol]).
|
|
378
277
|
COVERAGE_THRESHOLD_OPTIONS: Array[Symbol]
|
|
379
278
|
|
|
380
|
-
|
|
381
|
-
# criterion. `primary: true` makes it the report's leading
|
|
382
|
-
# criterion; `oneshot: true` (only for `:line`) selects
|
|
383
|
-
# oneshot-lines mode. Threshold keywords mirror the block verbs
|
|
384
|
-
# for one-liner use. Returns the criterion symbol the thresholds
|
|
385
|
-
# were stored under.
|
|
386
|
-
# The threshold keywords (minimum:, maximum:, exact:, maximum_drop:,
|
|
387
|
-
# minimum_per_file:) arrive via **thresholds in the implementation, so
|
|
388
|
-
# they are typed as a Numeric kwarg splat. The block runs under
|
|
389
|
-
# instance_eval, which also yields the receiver as an optional argument.
|
|
390
|
-
def coverage: ((criterion | :eval) criterion, ?primary: bool, ?enabled: bool, ?oneshot: bool, **Numeric thresholds) ?{ (?CoverageCriterion) [self: CoverageCriterion] -> void } -> (criterion | :oneshot_line | :eval)
|
|
279
|
+
def coverage: ((criterion | :eval) criterion, ?primary: bool, ?enabled: bool, ?oneshot: bool, **untyped thresholds) ?{ (?CoverageCriterion) [self: CoverageCriterion] -> void } -> (criterion | :oneshot_line | :eval)
|
|
391
280
|
|
|
392
281
|
private
|
|
393
282
|
|
|
394
|
-
def apply_threshold_options: (CoverageCriterion configurator, Hash[Symbol,
|
|
283
|
+
def apply_threshold_options: (CoverageCriterion configurator, Hash[Symbol, untyped] options) -> void
|
|
395
284
|
|
|
396
285
|
def enable_coverage_criterion: ((criterion | :eval) criterion, enabled: bool, oneshot: bool) -> (criterion | :oneshot_line | :eval)
|
|
397
286
|
|
|
398
287
|
def resolve_criterion_variant: ((criterion | :eval) criterion, bool oneshot) -> (criterion | :oneshot_line | :eval)
|
|
399
288
|
|
|
400
|
-
# Threshold-store writers used by CoverageCriterion via `send`.
|
|
401
|
-
# They accept any criterion Symbol; `raise_on_invalid_coverage`
|
|
402
|
-
# rejects invalid ones (including `:eval`) at runtime.
|
|
403
289
|
def store_overall_threshold: (Symbol setting, Symbol criterion, Numeric percent) -> void
|
|
404
290
|
|
|
405
291
|
def store_minimum_per_file: (Symbol criterion, Numeric percent, (String | Regexp)? target) -> void
|
|
406
292
|
|
|
407
293
|
def store_minimum_per_group: (Symbol criterion, Numeric percent, String group_name) -> void
|
|
408
294
|
|
|
295
|
+
def store_missed_cap: (Symbol setting, Symbol criterion, Integer count) -> void
|
|
296
|
+
|
|
297
|
+
def store_maximum_missed_per_file: (Symbol criterion, Integer count, (String | Regexp)? target) -> void
|
|
298
|
+
|
|
409
299
|
public
|
|
410
300
|
|
|
411
|
-
# Receiver for a `coverage <criterion> do ... end` block. Each verb
|
|
412
|
-
# writes a threshold for the single criterion the block configures,
|
|
413
|
-
# so values are always plain percentages.
|
|
414
301
|
class CoverageCriterion
|
|
302
|
+
type per_target = nil | :file | String | Regexp | GroupTarget
|
|
303
|
+
|
|
304
|
+
class GroupTarget
|
|
305
|
+
attr_reader name: String | Symbol
|
|
306
|
+
|
|
307
|
+
def initialize: (name: String | Symbol) -> void
|
|
308
|
+
end
|
|
309
|
+
|
|
415
310
|
@config: Configuration
|
|
416
311
|
@criterion: Symbol
|
|
417
312
|
|
|
418
313
|
def initialize: (Configuration config, Symbol criterion) -> void
|
|
419
314
|
|
|
420
|
-
|
|
421
|
-
def minimum: (Numeric percent) -> void
|
|
315
|
+
def minimum: (Numeric percent, ?per: per_target) -> void
|
|
422
316
|
|
|
423
|
-
# Overall maximum: fails the build if coverage rises above it.
|
|
424
317
|
def maximum: (Numeric percent) -> void
|
|
425
318
|
|
|
426
|
-
# Pin coverage to an exact figure (sets both minimum and maximum).
|
|
427
319
|
def exact: (Numeric percent) -> void
|
|
428
320
|
|
|
429
|
-
# Maximum allowed drop between runs (0 refuses any drop).
|
|
430
321
|
def maximum_drop: (Numeric percent) -> void
|
|
431
322
|
|
|
432
|
-
|
|
433
|
-
|
|
323
|
+
def maximum_missed: (Integer count, ?per: per_target) -> void
|
|
324
|
+
|
|
325
|
+
def group: (String | Symbol name) -> GroupTarget
|
|
326
|
+
|
|
327
|
+
def ignore: (*(Symbol | Array[Symbol]) types) -> Array[Symbol]
|
|
328
|
+
|
|
434
329
|
def minimum_per_file: (Numeric percent, ?only: (String | Regexp)?) -> void
|
|
435
330
|
|
|
436
|
-
# Per-group minimum for the named group (defined via `group`).
|
|
437
331
|
def minimum_per_group: (Numeric percent, only: String) -> void
|
|
438
332
|
|
|
439
|
-
|
|
333
|
+
def maximum_missed_per_file: (Integer count, ?only: (String | Regexp)?) -> void
|
|
334
|
+
|
|
440
335
|
def primary: () -> void
|
|
336
|
+
|
|
337
|
+
private
|
|
338
|
+
|
|
339
|
+
def raise_invalid_per: (untyped per) -> bot
|
|
441
340
|
end
|
|
442
341
|
end
|
|
443
342
|
end
|
|
444
343
|
|
|
445
|
-
# ----- configuration/filters -----
|
|
446
344
|
|
|
447
|
-
# Inclusion / exclusion / grouping methods: `cover`, `skip`, `group`,
|
|
448
|
-
# plus the deprecated `track_files` / `add_filter` / `add_group` aliases.
|
|
449
345
|
module SimpleCov
|
|
450
346
|
module Configuration
|
|
451
347
|
attr_writer filters: Array[Filter[untyped]]
|
|
@@ -455,56 +351,36 @@ module SimpleCov
|
|
|
455
351
|
@cover_filters: Array[Filter[untyped]]?
|
|
456
352
|
@tracked_files: String?
|
|
457
353
|
|
|
458
|
-
# Restrict the report to files matching one or more shell globs,
|
|
459
|
-
# regexps, or block predicates. Multiple calls union. String globs
|
|
460
|
-
# are also expanded on disk so unloaded files appear at 0% coverage.
|
|
461
354
|
def cover: (*cover_arg args) ?{ (SourceFile source_file) -> boolish } -> Array[Filter[untyped]]
|
|
462
355
|
|
|
463
|
-
# The configured inclusion filters added via `cover`.
|
|
464
356
|
def cover_filters: () -> Array[Filter[untyped]]
|
|
465
357
|
|
|
466
|
-
# The string globs passed to `cover`, driving unloaded-file discovery.
|
|
467
358
|
def cover_globs: () -> Array[String]
|
|
468
359
|
|
|
469
|
-
# DEPRECATED: use `cover` instead.
|
|
470
360
|
def track_files: (String? glob) -> String?
|
|
471
361
|
|
|
472
362
|
def track_files_replacement_hint: (String? glob) -> String
|
|
473
363
|
|
|
474
|
-
# The glob used to include files that were not explicitly required.
|
|
475
364
|
def tracked_files: () -> String?
|
|
476
365
|
|
|
477
|
-
# The configured exclusion filters added via `skip` (or the
|
|
478
|
-
# deprecated `add_filter`).
|
|
479
366
|
def filters: () -> Array[Filter[untyped]]
|
|
480
367
|
|
|
481
|
-
# Drop matching files from the coverage report. The inverse of
|
|
482
|
-
# `cover`. Strings match at path-segment boundaries.
|
|
483
368
|
def skip: (?filter_arg? filter_argument) ?{ (SourceFile source_file) -> boolish } -> Array[Filter[untyped]]
|
|
484
369
|
|
|
485
|
-
# DEPRECATED: use `skip` instead (same arguments, same behavior).
|
|
486
370
|
def add_filter: (?filter_arg? filter_argument) ?{ (SourceFile source_file) -> boolish } -> Array[Filter[untyped]]
|
|
487
371
|
|
|
488
|
-
# Remove any filters whose `filter_argument` equals the given
|
|
489
|
-
# value. Returns true when at least one filter was removed.
|
|
490
372
|
def remove_filter: (untyped filter_argument) -> bool
|
|
491
373
|
|
|
492
|
-
# Remove every filter from the chain, including the defaults
|
|
493
|
-
# installed by `SimpleCov.start`.
|
|
494
374
|
def clear_filters: () -> Array[Filter[untyped]]
|
|
495
375
|
|
|
496
|
-
# The configured groups. Add groups using `group`.
|
|
497
376
|
def groups: () -> Hash[String, Filter[untyped]]
|
|
498
377
|
|
|
499
|
-
|
|
500
|
-
|
|
378
|
+
def default_groups: () -> Hash[String, Filter[untyped]]
|
|
379
|
+
|
|
501
380
|
def group: (String group_name, ?filter_arg? filter_argument) ?{ (SourceFile source_file) -> boolish } -> Filter[untyped]
|
|
502
381
|
|
|
503
|
-
# DEPRECATED: use `group` instead (same arguments, same behavior).
|
|
504
382
|
def add_group: (String group_name, ?filter_arg? filter_argument) ?{ (SourceFile source_file) -> boolish } -> Filter[untyped]
|
|
505
383
|
|
|
506
|
-
# Drop every previously installed filter (defaults included) so
|
|
507
|
-
# subsequent `skip` calls start from a clean slate.
|
|
508
384
|
def no_default_skips: () -> Array[Filter[untyped]]
|
|
509
385
|
|
|
510
386
|
private
|
|
@@ -517,15 +393,9 @@ module SimpleCov
|
|
|
517
393
|
end
|
|
518
394
|
end
|
|
519
395
|
|
|
520
|
-
# ----- configuration/formatting -----
|
|
521
396
|
|
|
522
|
-
# Formatter selection (`formatter` / `formatters`), reporting toggles
|
|
523
|
-
# (`print_errors`, `color`, `source_in_json`), and the deprecated
|
|
524
|
-
# `# :nocov:` token hook.
|
|
525
397
|
module SimpleCov
|
|
526
398
|
module Configuration
|
|
527
|
-
# A formatter is a Class whose instances respond to `format(result)`
|
|
528
|
-
# (including the anonymous Class built by `MultiFormatter.new`).
|
|
529
399
|
attr_writer formatter: Class?
|
|
530
400
|
|
|
531
401
|
attr_writer print_error_status: bool
|
|
@@ -534,71 +404,64 @@ module SimpleCov
|
|
|
534
404
|
@source_in_json: bool
|
|
535
405
|
@nocov_token: String
|
|
536
406
|
|
|
537
|
-
|
|
538
|
-
|
|
407
|
+
BUILT_IN_FORMATS: Hash[Symbol, Symbol]
|
|
408
|
+
|
|
409
|
+
LAZY_FORMAT_REQUIRES: Hash[Symbol, String]
|
|
410
|
+
|
|
411
|
+
def formats: (*untyped names) -> (Array[Class] | Class | nil)
|
|
412
|
+
|
|
539
413
|
def formatter: (?(Class | false | :__no_arg__)? formatter) -> Class?
|
|
540
414
|
|
|
541
|
-
# Gets the formatter chain, or sets it. Accepts an Array, a single
|
|
542
|
-
# formatter, or nil / `[]` to opt out of formatting entirely.
|
|
543
|
-
# Returns the passed value when setting.
|
|
544
415
|
def formatters: (?(Array[Class] | Class | :__no_arg__)? formatters) -> (Array[Class] | Class | nil)
|
|
545
416
|
|
|
546
|
-
# Sets the configured formatters (single formatters are wrapped;
|
|
547
|
-
# nil / `[]` opts out of formatting entirely).
|
|
548
417
|
def formatters=: ((Array[Class] | Class)? formatters) -> void
|
|
549
418
|
|
|
550
|
-
# Whether stderr diagnostics are colorized: `true`, `false`, or
|
|
551
|
-
# `:auto` (default — respects TTY, NO_COLOR, and FORCE_COLOR).
|
|
552
419
|
def color: (?(bool | :auto | :__no_arg__) value) -> (bool | :auto)
|
|
553
420
|
|
|
554
|
-
|
|
555
|
-
|
|
421
|
+
def color=: (untyped value) -> untyped
|
|
422
|
+
|
|
556
423
|
def print_errors: (?(bool | :__no_arg__) value) -> bool
|
|
557
424
|
|
|
558
|
-
|
|
559
|
-
|
|
425
|
+
def print_errors=: (bool value) -> bool
|
|
426
|
+
|
|
560
427
|
def source_in_json: (?(bool | :__no_arg__) value) -> bool
|
|
561
428
|
|
|
562
|
-
|
|
429
|
+
def source_in_json=: (bool value) -> bool
|
|
430
|
+
|
|
563
431
|
def print_error_status: () -> bool
|
|
564
432
|
|
|
565
|
-
# DEPRECATED: use `# simplecov:disable` / `# simplecov:enable`
|
|
566
|
-
# directive comments instead of `# :nocov:` toggles.
|
|
567
433
|
def nocov_token: (?String? nocov_token) -> String
|
|
568
434
|
|
|
569
|
-
# DEPRECATED: alias for `nocov_token`.
|
|
570
435
|
alias skip_token nocov_token
|
|
571
436
|
|
|
572
437
|
def current_nocov_token: (?String? value) -> String
|
|
438
|
+
|
|
439
|
+
private
|
|
440
|
+
|
|
441
|
+
def combined_formatter: (Array[untyped] formatters) -> untyped
|
|
442
|
+
|
|
443
|
+
def resolve_format: (untyped name) -> untyped
|
|
444
|
+
|
|
445
|
+
def require_html_formatter: (untyped name) -> void
|
|
573
446
|
end
|
|
574
447
|
end
|
|
575
448
|
|
|
576
|
-
# ----- configuration/ignored_entries -----
|
|
577
449
|
|
|
578
|
-
# Coverage-entry filters scoped to branch / method criteria. See
|
|
579
|
-
# `ignore_branches` / `ignore_methods` and #1033 / #1046.
|
|
580
450
|
module SimpleCov
|
|
581
451
|
module Configuration
|
|
582
|
-
# Branch types accepted by `ignore_branches`: implicit_else and
|
|
583
|
-
# eval_generated (%i[] literals infer as Array[Symbol]).
|
|
584
452
|
IGNORABLE_BRANCH_TYPES: Array[Symbol]
|
|
585
453
|
|
|
586
|
-
# Method types accepted by `ignore_methods`: eval_generated (%i[]
|
|
587
|
-
# literals infer as Array[Symbol]).
|
|
588
454
|
IGNORABLE_METHOD_TYPES: Array[Symbol]
|
|
589
455
|
|
|
590
456
|
@ignored_branches: Array[Symbol]?
|
|
591
457
|
@ignored_methods: Array[Symbol]?
|
|
592
458
|
|
|
593
|
-
# Opt out of synthetic branch entries. Variadic; multiple calls
|
|
594
|
-
# union. Recorded even when branch coverage is not (yet) enabled.
|
|
595
459
|
def ignore_branches: (*(:implicit_else | :eval_generated) types) -> Array[Symbol]
|
|
596
460
|
|
|
597
461
|
def ignored_branches: () -> Array[Symbol]
|
|
598
462
|
|
|
599
463
|
def ignored_branch?: (Symbol type) -> bool
|
|
600
464
|
|
|
601
|
-
# Opt out of synthetic method entries (currently `:eval_generated` only).
|
|
602
465
|
def ignore_methods: (*:eval_generated types) -> Array[Symbol]
|
|
603
466
|
|
|
604
467
|
def ignored_methods: () -> Array[Symbol]
|
|
@@ -607,22 +470,37 @@ module SimpleCov
|
|
|
607
470
|
|
|
608
471
|
private
|
|
609
472
|
|
|
473
|
+
def store_ignored_branches: (Array[Symbol] types) -> Array[Symbol]
|
|
474
|
+
|
|
475
|
+
def store_ignored_methods: (Array[Symbol] types) -> Array[Symbol]
|
|
476
|
+
|
|
610
477
|
def raise_if_branch_type_unsupported: (Symbol type) -> void
|
|
611
478
|
|
|
612
479
|
def raise_if_method_type_unsupported: (Symbol type) -> void
|
|
613
480
|
end
|
|
614
481
|
end
|
|
615
482
|
|
|
616
|
-
# ----- configuration/merging -----
|
|
617
483
|
|
|
618
|
-
# Result merging and subprocess / parallel-test coordination:
|
|
619
|
-
# `merging`, `merge_subprocesses`, `merge_timeout`, `finalize_merge`,
|
|
620
|
-
# `parallel_tests`, `parallel_wait_timeout`.
|
|
621
484
|
module SimpleCov
|
|
622
485
|
module Configuration
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
486
|
+
@track_tests: bool
|
|
487
|
+
@track_tests_granularity: Symbol?
|
|
488
|
+
|
|
489
|
+
TRACK_TESTS_GRANULARITIES: Array[Symbol]
|
|
490
|
+
|
|
491
|
+
def track_tests: (?bool? enabled, ?granularity: Symbol?) -> bool
|
|
492
|
+
|
|
493
|
+
def track_tests_granularity: () -> Symbol
|
|
494
|
+
|
|
495
|
+
def track_tests?: () -> bool
|
|
496
|
+
|
|
497
|
+
def validate_test_tracking!: () -> void
|
|
498
|
+
end
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
module SimpleCov
|
|
503
|
+
module Configuration
|
|
626
504
|
@enable_for_subprocesses: bool
|
|
627
505
|
@parallel_tests: bool?
|
|
628
506
|
@use_merging: bool
|
|
@@ -632,50 +510,42 @@ module SimpleCov
|
|
|
632
510
|
@merge_timeout: Integer?
|
|
633
511
|
@parallel_wait_timeout: Integer?
|
|
634
512
|
|
|
635
|
-
# Get or set whether SimpleCov hooks `Process._fork` to attach
|
|
636
|
-
# itself to subprocesses (e.g. Rails' `parallelize(workers:)`).
|
|
637
|
-
# Defaults to false.
|
|
638
513
|
def merge_subprocesses: (?bool? value) -> bool
|
|
639
514
|
|
|
515
|
+
def merge_subprocesses=: (bool? value) -> untyped
|
|
516
|
+
|
|
640
517
|
def enabled_for_subprocesses?: () -> bool
|
|
641
518
|
|
|
642
|
-
# Get or set whether SimpleCov auto-requires the `parallel_tests`
|
|
643
|
-
# gem when it sees its environment variables. nil (the default)
|
|
644
|
-
# means auto-detect. See #1018.
|
|
645
519
|
def parallel_tests: (?(:__no_arg__ | bool)? value) -> bool?
|
|
646
520
|
|
|
647
|
-
|
|
521
|
+
def parallel_tests=: (untyped value) -> untyped
|
|
522
|
+
|
|
648
523
|
def enable_for_subprocesses: (?bool? value) -> bool
|
|
649
524
|
|
|
650
|
-
# Get or set whether to merge results from multiple test suites
|
|
651
|
-
# into a single coverage report. Defaults to true.
|
|
652
525
|
def merging: (?bool? use) -> bool
|
|
653
526
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
# `SimpleCov.collate` step). See #1215.
|
|
660
|
-
def finalize_merge: (?(:__no_arg__ | bool) value) -> bool
|
|
527
|
+
def merging=: (bool use) -> bool
|
|
528
|
+
|
|
529
|
+
def finalize_merge: (*bool value) -> bool
|
|
530
|
+
|
|
531
|
+
def finalize_merge=: (bool value) -> bool
|
|
661
532
|
|
|
662
533
|
def finalize_merge?: () -> bool
|
|
663
534
|
|
|
664
535
|
def merge_finalization_owner?: () -> boolish
|
|
665
536
|
|
|
666
|
-
# DEPRECATED: use `merging` instead (same value, same behavior).
|
|
667
|
-
# Returns nil when merging had already been disabled.
|
|
668
537
|
def use_merging: (?bool? use) -> bool
|
|
669
538
|
|
|
670
|
-
# The maximum age (in seconds) of a resultset to still be included
|
|
671
|
-
# in merged results. Defaults to 600.
|
|
672
539
|
def merge_timeout: (?Integer? seconds) -> Integer
|
|
673
540
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
541
|
+
def merge_timeout=: (untyped seconds) -> untyped
|
|
542
|
+
|
|
543
|
+
def env_merge_timeout: () -> Integer?
|
|
544
|
+
|
|
677
545
|
def parallel_wait_timeout: (?Integer? seconds) -> Integer
|
|
678
546
|
|
|
547
|
+
def parallel_wait_timeout=: (untyped seconds) -> untyped
|
|
548
|
+
|
|
679
549
|
private
|
|
680
550
|
|
|
681
551
|
def inferred_finalize_merge?: () -> bool
|
|
@@ -690,83 +560,70 @@ module SimpleCov
|
|
|
690
560
|
|
|
691
561
|
def inferred_finalize_merge_warning: () -> String
|
|
692
562
|
|
|
693
|
-
# Host contract: defined on SimpleCov itself (result_processing.rb).
|
|
694
|
-
# This module is only ever extended onto SimpleCov, where both methods
|
|
695
|
-
# are available to `merge_finalization_owner?`.
|
|
696
563
|
def collating_result?: () -> boolish
|
|
697
564
|
|
|
698
565
|
def final_result_process?: () -> boolish
|
|
699
566
|
end
|
|
700
567
|
end
|
|
701
568
|
|
|
702
|
-
# ----- configuration/thresholds -----
|
|
703
569
|
|
|
704
|
-
# Coverage threshold configuration: `minimum_coverage`,
|
|
705
|
-
# `maximum_coverage`, `expected_coverage`, `maximum_coverage_drop`,
|
|
706
|
-
# `refuse_coverage_drop`, and the deprecated by-file / by-group forms.
|
|
707
570
|
module SimpleCov
|
|
708
571
|
module Configuration
|
|
709
|
-
# Thresholds are stored per criterion; a bare Numeric argument is
|
|
710
|
-
# normalized to `{primary_coverage => value}`. Keys are criterion
|
|
711
|
-
# symbols — Symbol rather than the `criterion` alias because the
|
|
712
|
-
# stores also carry `:oneshot_line`, and the validating setters are
|
|
713
|
-
# the layer that rejects unknown symbols (with ConfigurationError).
|
|
714
572
|
type coverage_thresholds = Hash[Symbol, Numeric]
|
|
715
573
|
|
|
574
|
+
type missed_caps = Hash[Symbol, Integer]
|
|
575
|
+
|
|
716
576
|
@minimum_coverage: coverage_thresholds?
|
|
717
577
|
@maximum_coverage: coverage_thresholds?
|
|
718
578
|
@maximum_coverage_drop: coverage_thresholds?
|
|
579
|
+
@maximum_missed: missed_caps?
|
|
580
|
+
@maximum_missed_per_file: missed_caps?
|
|
581
|
+
@maximum_missed_per_file_overrides: Hash[String | Regexp, missed_caps]?
|
|
719
582
|
@minimum_coverage_by_file: coverage_thresholds?
|
|
720
583
|
@minimum_coverage_by_file_overrides: Hash[String | Regexp, coverage_thresholds]?
|
|
721
584
|
@minimum_coverage_by_group: Hash[String, coverage_thresholds]?
|
|
722
585
|
|
|
723
|
-
# The minimum overall coverage required for the suite to pass.
|
|
724
|
-
# Default: none (0%, disabled).
|
|
725
586
|
def minimum_coverage: (?(Numeric | coverage_thresholds)? coverage) -> coverage_thresholds
|
|
726
587
|
|
|
727
|
-
def raise_on_invalid_coverage: (coverage_thresholds coverage, String coverage_setting) -> void
|
|
588
|
+
def raise_on_invalid_coverage: (coverage_thresholds coverage, (String | Symbol) coverage_setting) -> void
|
|
728
589
|
|
|
729
|
-
# The maximum overall coverage allowed — an unexpected jump above
|
|
730
|
-
# it fails the build. Pair with `minimum_coverage` (or use
|
|
731
|
-
# `expected_coverage`) to pin coverage. See #187.
|
|
732
590
|
def maximum_coverage: (?(Numeric | coverage_thresholds)? coverage) -> coverage_thresholds
|
|
733
591
|
|
|
734
|
-
# Pin the suite to an exact figure: sets both `minimum_coverage`
|
|
735
|
-
# and `maximum_coverage`. See #187.
|
|
736
592
|
def expected_coverage: (?(Numeric | coverage_thresholds)? coverage) -> coverage_thresholds
|
|
737
593
|
|
|
738
|
-
# The maximum coverage drop between runs allowed for the suite to
|
|
739
|
-
# pass. Default: none (100%, disabled).
|
|
740
594
|
def maximum_coverage_drop: (?(Numeric | coverage_thresholds)? coverage_drop) -> coverage_thresholds
|
|
741
595
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
596
|
+
def maximum_missed: (?(Numeric | missed_caps)? counts) -> missed_caps
|
|
597
|
+
|
|
598
|
+
def maximum_missed_per_file: (?(Numeric | missed_caps)? counts) -> missed_caps
|
|
599
|
+
|
|
600
|
+
def maximum_missed_per_file_overrides: () -> Hash[String | Regexp, missed_caps]
|
|
601
|
+
|
|
745
602
|
def minimum_coverage_by_file: () -> coverage_thresholds
|
|
746
603
|
| ((Numeric | Hash[Symbol | String | Regexp, Numeric | coverage_thresholds]) coverage) -> Hash[String | Regexp, coverage_thresholds]
|
|
747
604
|
|
|
748
|
-
# The per-path overrides set via `minimum_coverage_by_file` (or
|
|
749
|
-
# `coverage(criterion) { minimum_per_file N, only: ... }`).
|
|
750
605
|
def minimum_coverage_by_file_overrides: () -> Hash[String | Regexp, coverage_thresholds]
|
|
751
606
|
|
|
752
|
-
# DEPRECATED: use `coverage(criterion) { minimum_per_group ... }`.
|
|
753
607
|
def minimum_coverage_by_group: () -> Hash[String, coverage_thresholds]
|
|
754
608
|
| (Hash[String, Numeric | coverage_thresholds] coverage) -> Hash[String, coverage_thresholds]
|
|
755
609
|
|
|
756
|
-
# Refuse any coverage drop for the given criteria (all enabled
|
|
757
|
-
# criteria when none are given). Coverage may only increase.
|
|
758
610
|
def refuse_coverage_drop: (*(criterion | :oneshot_line) criteria) -> coverage_thresholds
|
|
759
611
|
|
|
760
612
|
private
|
|
761
613
|
|
|
762
|
-
# Shared normalize-and-validate step behind every threshold setter.
|
|
763
614
|
def normalized_threshold: ((Numeric | coverage_thresholds) coverage, String setting) -> coverage_thresholds
|
|
764
615
|
|
|
616
|
+
def normalized_missed_caps: ((Numeric | missed_caps) counts, String setting) -> missed_caps
|
|
617
|
+
|
|
618
|
+
def raise_on_invalid_missed_cap: (untyped cap, (String | Symbol) setting) -> void
|
|
619
|
+
|
|
620
|
+
def missed_per_file_replacement: ((Numeric | missed_caps) counts) -> String
|
|
621
|
+
|
|
765
622
|
def partition_per_file_thresholds: (Hash[Symbol | String | Regexp, Numeric | coverage_thresholds] coverage) -> [coverage_thresholds, Hash[String | Regexp, coverage_thresholds]]
|
|
766
623
|
|
|
767
624
|
def validate_per_file_key: ((Symbol | String | Regexp) key) -> void
|
|
768
625
|
|
|
769
|
-
def minimum_possible_coverage_exceeded: (String coverage_option) -> void
|
|
626
|
+
def minimum_possible_coverage_exceeded: ((String | Symbol) coverage_option) -> void
|
|
770
627
|
|
|
771
628
|
def per_file_coverage_replacement: (coverage_thresholds defaults, Hash[String | Regexp, coverage_thresholds] overrides) -> String
|
|
772
629
|
|
|
@@ -776,35 +633,30 @@ module SimpleCov
|
|
|
776
633
|
end
|
|
777
634
|
end
|
|
778
635
|
|
|
779
|
-
# ----- result -----
|
|
780
636
|
|
|
781
637
|
module SimpleCov
|
|
782
|
-
# A coverage result built from the Hash Ruby's Coverage library
|
|
783
|
-
# produces: filename => per-criterion coverage data.
|
|
784
638
|
class Result
|
|
785
639
|
extend Forwardable
|
|
640
|
+
include Serialization
|
|
786
641
|
|
|
787
642
|
attr_reader original_result: Hash[String, untyped]
|
|
788
643
|
|
|
789
|
-
# Every path the producing process was told to track, loaded or not.
|
|
790
644
|
attr_reader tracked_files: Array[String]
|
|
791
645
|
attr_reader run_id: String?
|
|
792
646
|
attr_reader worker_id: String?
|
|
793
647
|
attr_reader files: FileList
|
|
794
648
|
alias source_files files
|
|
795
|
-
|
|
796
|
-
# both default to nil and are lazily backfilled by the readers.
|
|
649
|
+
attr_reader contexts: ContextMap?
|
|
797
650
|
attr_writer created_at (): Time
|
|
798
651
|
attr_writer command_name (): String
|
|
652
|
+
attr_writer command_names (): Array[String]
|
|
799
653
|
|
|
800
654
|
@created_at: Time?
|
|
801
655
|
@command_name: String?
|
|
656
|
+
@command_names: Array[String]?
|
|
802
657
|
@groups_config: Hash[String, Filter[untyped]]
|
|
803
658
|
@groups: Hash[String, FileList]?
|
|
804
659
|
|
|
805
|
-
# Bundles filter and grouping configuration. Every field defaults to
|
|
806
|
-
# the SimpleCov singleton's configuration; tests pass a custom
|
|
807
|
-
# instance (e.g. `filters: []`) to opt out.
|
|
808
660
|
class FilterConfig
|
|
809
661
|
attr_reader filters: Array[Filter[untyped]]
|
|
810
662
|
attr_reader cover_filters: Array[Filter[untyped]]
|
|
@@ -813,22 +665,19 @@ module SimpleCov
|
|
|
813
665
|
def initialize: (?filters: Array[Filter[untyped]], ?cover_filters: Array[Filter[untyped]], ?groups: Hash[String, Filter[untyped]]) -> void
|
|
814
666
|
end
|
|
815
667
|
|
|
816
|
-
def initialize: (Hash[String, untyped] original_result, ?command_name: String?, ?created_at: Time?, ?not_loaded_files: Set[String], ?tracked_files: _ToA[String]
|
|
668
|
+
def initialize: (Hash[String, untyped] original_result, ?command_name: String?, ?created_at: Time?, ?not_loaded_files: Set[String], ?tracked_files: _ToA[String]?, ?run_id: String?, ?worker_id: String?, ?contexts: ContextMap?, ?report: bool, ?filter_config: FilterConfig) -> void
|
|
817
669
|
|
|
818
670
|
def filenames: () -> Array[String]
|
|
819
|
-
# Accepts an absolute or project-relative path (resolved against SimpleCov.root).
|
|
820
671
|
def source_file_for: (String path) -> SourceFile?
|
|
821
672
|
def coverage_for: (String path) -> Hash[criterion, CoverageStatistics]?
|
|
822
673
|
def groups: () -> Hash[String, FileList]
|
|
823
|
-
|
|
824
|
-
# `formatters []`); otherwise whatever the configured formatter returns.
|
|
674
|
+
def configured_group?: (String group_name) -> bool
|
|
825
675
|
def format!: () -> untyped
|
|
826
676
|
def created_at: () -> Time
|
|
827
677
|
def command_name: () -> String
|
|
828
|
-
def
|
|
678
|
+
def command_names: () -> Array[String]
|
|
829
679
|
def self.from_hash: (Hash[String, untyped] hash) -> Array[Result]
|
|
830
680
|
|
|
831
|
-
# Delegated to #files (see FileList).
|
|
832
681
|
def covered_percent: (?criterion) -> Float?
|
|
833
682
|
def covered_percentages: () -> Array[Float?]
|
|
834
683
|
def least_covered_file: () -> String?
|
|
@@ -848,20 +697,47 @@ module SimpleCov
|
|
|
848
697
|
|
|
849
698
|
private
|
|
850
699
|
|
|
851
|
-
def
|
|
852
|
-
def warn_about_missing_source_files: (Array[String] missing
|
|
853
|
-
def coverage: () -> Hash[String, untyped]
|
|
700
|
+
def initialize_resultset_metadata: (_ToA[String]? tracked_files, String? run_id, String? worker_id, ContextMap? contexts) -> void
|
|
701
|
+
def warn_about_missing_source_files: (Array[String] missing) -> void
|
|
854
702
|
def apply_filters!: (Array[Filter[untyped]] filters) -> void
|
|
855
703
|
def apply_cover_filters!: (Array[Filter[untyped]] cover_filters) -> void
|
|
856
704
|
end
|
|
705
|
+
|
|
706
|
+
class Result
|
|
707
|
+
interface _SerializableResult
|
|
708
|
+
def original_result: () -> Hash[String, untyped]
|
|
709
|
+
|
|
710
|
+
def created_at: () -> Time
|
|
711
|
+
|
|
712
|
+
def command_name: () -> String
|
|
713
|
+
|
|
714
|
+
def run_id: () -> String?
|
|
715
|
+
|
|
716
|
+
def worker_id: () -> String?
|
|
717
|
+
|
|
718
|
+
def tracked_files: () -> Array[String]
|
|
719
|
+
|
|
720
|
+
def contexts: () -> ContextMap?
|
|
721
|
+
|
|
722
|
+
def filenames: () -> Array[String]
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
module Serialization : _SerializableResult
|
|
726
|
+
def to_hash: () -> Hash[String, Hash[String, untyped]]
|
|
727
|
+
|
|
728
|
+
private
|
|
729
|
+
|
|
730
|
+
def append_contexts: (Hash[String, untyped] data) -> void
|
|
731
|
+
|
|
732
|
+
def context_filenames: () -> Set[String]
|
|
733
|
+
|
|
734
|
+
def coverage: () -> Hash[String, untyped]
|
|
735
|
+
end
|
|
736
|
+
end
|
|
857
737
|
end
|
|
858
738
|
|
|
859
|
-
# ----- file_list -----
|
|
860
739
|
|
|
861
740
|
module SimpleCov
|
|
862
|
-
# An Enumerable of SourceFile instances with aggregate coverage
|
|
863
|
-
# helpers. Aggregate readers return nil when the corresponding
|
|
864
|
-
# criterion was not enabled for the run.
|
|
865
741
|
class FileList
|
|
866
742
|
include Enumerable[SimpleCov::SourceFile]
|
|
867
743
|
extend Forwardable
|
|
@@ -872,7 +748,6 @@ module SimpleCov
|
|
|
872
748
|
@coverage_statistics: Hash[criterion, CoverageStatistics]?
|
|
873
749
|
@coverage_statistics_by_file: Hash[criterion, Array[CoverageStatistics]]?
|
|
874
750
|
|
|
875
|
-
# Delegated to the underlying Array.
|
|
876
751
|
def each: () { (SourceFile) -> void } -> void
|
|
877
752
|
| () -> Enumerator[SourceFile, untyped]
|
|
878
753
|
def size: () -> Integer
|
|
@@ -917,23 +792,16 @@ module SimpleCov
|
|
|
917
792
|
end
|
|
918
793
|
end
|
|
919
794
|
|
|
920
|
-
# ----- source_file -----
|
|
921
795
|
|
|
922
796
|
module SimpleCov
|
|
923
|
-
# A source file with its coverage data, source lines, and helpers to
|
|
924
|
-
# interpret that data.
|
|
925
797
|
class SourceFile
|
|
926
798
|
include BuilderContext
|
|
927
799
|
|
|
928
|
-
# Full absolute path to the file.
|
|
929
800
|
attr_reader filename: String
|
|
930
|
-
# Coverage.result-shaped data for this file, e.g.
|
|
931
|
-
# {"lines" => [...], "branches" => {...}, "methods" => {...}}.
|
|
932
801
|
attr_reader coverage_data: Hash[String, untyped]
|
|
933
802
|
|
|
934
803
|
def initialize: (String filename, Hash[String, untyped] coverage_data, ?loaded: bool) -> void
|
|
935
804
|
|
|
936
|
-
# Memoization backing for the lazy readers below.
|
|
937
805
|
@loaded: bool
|
|
938
806
|
@src: Array[String]?
|
|
939
807
|
@coverage_statistics: Hash[criterion, CoverageStatistics]?
|
|
@@ -951,15 +819,10 @@ module SimpleCov
|
|
|
951
819
|
@covered_methods: Array[Method]?
|
|
952
820
|
@missed_methods: Array[Method]?
|
|
953
821
|
|
|
954
|
-
# Project-relative path with no leading separator (e.g. "lib/foo.rb").
|
|
955
822
|
def project_filename: () -> String
|
|
956
|
-
# Source lines, read lazily.
|
|
957
823
|
def src: () -> Array[String]
|
|
958
824
|
alias source src
|
|
959
825
|
|
|
960
|
-
# With no argument returns a Hash keyed by every supported criterion
|
|
961
|
-
# (disabled criteria collapse to 0/0/0); pass a criterion to get that
|
|
962
|
-
# one CoverageStatistics.
|
|
963
826
|
def coverage_statistics: () -> Hash[criterion, CoverageStatistics]
|
|
964
827
|
| (criterion) -> CoverageStatistics?
|
|
965
828
|
|
|
@@ -970,7 +833,6 @@ module SimpleCov
|
|
|
970
833
|
def never_lines: () -> Array[Line]
|
|
971
834
|
def skipped_lines: () -> Array[Line]
|
|
972
835
|
def lines_of_code: () -> Integer
|
|
973
|
-
# 1-based line lookup.
|
|
974
836
|
def line: (Integer number) -> Line?
|
|
975
837
|
def covered_percent: (?criterion) -> Float?
|
|
976
838
|
def covered_strength: (?criterion) -> Float?
|
|
@@ -979,11 +841,8 @@ module SimpleCov
|
|
|
979
841
|
|
|
980
842
|
def branches: () -> Array[Branch]
|
|
981
843
|
def no_branches?: () -> bool
|
|
982
|
-
# DEPRECATED: use `covered_percent(:branch)`.
|
|
983
844
|
def branches_coverage_percent: () -> Float?
|
|
984
|
-
# All relevant (covered + missed) branches, not a count.
|
|
985
845
|
def total_branches: () -> Array[Branch]
|
|
986
|
-
# line number => Array of [branch type, hit count] pairs.
|
|
987
846
|
def branches_report: () -> Hash[Integer, Array[[ Symbol, Integer ]]]
|
|
988
847
|
def covered_branches: () -> Array[Branch]
|
|
989
848
|
def missed_branches: () -> Array[Branch]
|
|
@@ -993,21 +852,15 @@ module SimpleCov
|
|
|
993
852
|
def methods: () -> Array[Method]
|
|
994
853
|
def covered_methods: () -> Array[Method]
|
|
995
854
|
def missed_methods: () -> Array[Method]
|
|
996
|
-
# DEPRECATED: use `covered_percent(:method)`.
|
|
997
855
|
def methods_coverage_percent: () -> Float?
|
|
998
856
|
|
|
999
|
-
# Whether this file was added via `cover` / `track_files` but never
|
|
1000
|
-
# loaded during the run.
|
|
1001
857
|
def not_loaded?: () -> bool
|
|
1002
858
|
end
|
|
1003
859
|
end
|
|
1004
860
|
|
|
1005
|
-
# ----- source_file/line -----
|
|
1006
861
|
|
|
1007
862
|
module SimpleCov
|
|
1008
863
|
class SourceFile
|
|
1009
|
-
# A single source line with its coverage: nil (not relevant, e.g. a
|
|
1010
|
-
# comment), 0 (missed), or >= 1 (times executed).
|
|
1011
864
|
class Line
|
|
1012
865
|
attr_reader src: String
|
|
1013
866
|
attr_reader line_number: Integer
|
|
@@ -1018,8 +871,6 @@ module SimpleCov
|
|
|
1018
871
|
alias line line_number
|
|
1019
872
|
alias number line_number
|
|
1020
873
|
|
|
1021
|
-
# Raises ArgumentError unless src is a String, line_number an
|
|
1022
|
-
# Integer, and coverage an Integer or nil.
|
|
1023
874
|
def initialize: (String src, Integer line_number, Integer? coverage) -> void
|
|
1024
875
|
|
|
1025
876
|
def missed?: () -> bool
|
|
@@ -1027,22 +878,18 @@ module SimpleCov
|
|
|
1027
878
|
def never?: () -> bool
|
|
1028
879
|
def skipped!: () -> void
|
|
1029
880
|
def skipped?: () -> bool
|
|
1030
|
-
|
|
1031
|
-
def status: () -> String?
|
|
881
|
+
def status: () -> String
|
|
1032
882
|
end
|
|
1033
883
|
end
|
|
1034
884
|
end
|
|
1035
885
|
|
|
1036
|
-
# ----- source_file/branch -----
|
|
1037
886
|
|
|
1038
887
|
module SimpleCov
|
|
1039
888
|
class SourceFile
|
|
1040
|
-
# A single branch detected in the coverage data.
|
|
1041
889
|
class Branch
|
|
1042
890
|
attr_reader start_line: Integer
|
|
1043
891
|
attr_reader end_line: Integer
|
|
1044
892
|
attr_reader coverage: Integer
|
|
1045
|
-
# Branch arm type as reported by Coverage (:then, :else, :when, ...).
|
|
1046
893
|
attr_reader type: Symbol
|
|
1047
894
|
|
|
1048
895
|
@inline: bool
|
|
@@ -1053,28 +900,21 @@ module SimpleCov
|
|
|
1053
900
|
def inline?: () -> bool
|
|
1054
901
|
def covered?: () -> bool
|
|
1055
902
|
def missed?: () -> bool
|
|
1056
|
-
# The line the branch is reported on: its own start line when
|
|
1057
|
-
# inline, otherwise the line above (the if/else itself).
|
|
1058
903
|
def report_line: () -> Integer
|
|
1059
904
|
def skipped!: () -> void
|
|
1060
905
|
def skipped?: () -> bool
|
|
1061
906
|
def overlaps_with?: (Range[Integer] line_range) -> bool
|
|
1062
|
-
# [branch type, hit count]
|
|
1063
907
|
def report: () -> [ Symbol, Integer ]
|
|
1064
908
|
end
|
|
1065
909
|
end
|
|
1066
910
|
end
|
|
1067
911
|
|
|
1068
|
-
# ----- source_file/method -----
|
|
1069
912
|
|
|
1070
913
|
module SimpleCov
|
|
1071
914
|
class SourceFile
|
|
1072
|
-
# A single method detected in the coverage data.
|
|
1073
915
|
class Method
|
|
1074
916
|
attr_reader source_file: SourceFile
|
|
1075
917
|
attr_reader coverage: Integer
|
|
1076
|
-
# A Module when the data comes straight from Coverage, a String
|
|
1077
|
-
# after a JSON round-trip through a resultset.
|
|
1078
918
|
attr_reader class_name: Module | String
|
|
1079
919
|
attr_reader method_name: Symbol | String
|
|
1080
920
|
attr_reader start_line: Integer?
|
|
@@ -1085,15 +925,12 @@ module SimpleCov
|
|
|
1085
925
|
@skipped: bool
|
|
1086
926
|
@lines: Array[Line]?
|
|
1087
927
|
|
|
1088
|
-
# info is the Coverage method key minus its class entry:
|
|
1089
|
-
# [class_name, method_name, start_line, start_col, end_line, end_col].
|
|
1090
928
|
def initialize: (SourceFile source_file, [ Module | String, Symbol | String, Integer?, Integer?, Integer?, Integer? ] info, Integer coverage) -> void
|
|
1091
929
|
|
|
1092
930
|
def covered?: () -> bool
|
|
1093
931
|
def skipped?: () -> bool
|
|
1094
932
|
def skipped!: () -> void
|
|
1095
933
|
def missed?: () -> bool
|
|
1096
|
-
# The source lines spanned by this method ([] when the location is unknown).
|
|
1097
934
|
def lines: () -> Array[Line]
|
|
1098
935
|
def overlaps_with?: (Range[Integer] line_range) -> bool
|
|
1099
936
|
def to_s: () -> String
|
|
@@ -1101,12 +938,9 @@ module SimpleCov
|
|
|
1101
938
|
end
|
|
1102
939
|
end
|
|
1103
940
|
|
|
1104
|
-
# ----- source_file/statistics -----
|
|
1105
941
|
|
|
1106
942
|
module SimpleCov
|
|
1107
943
|
class SourceFile
|
|
1108
|
-
# Builds the CoverageStatistics triple (:line/:branch/:method) for a
|
|
1109
|
-
# SourceFile; disabled or empty criteria collapse to 0/0/0.
|
|
1110
944
|
class Statistics
|
|
1111
945
|
@source_file: SourceFile
|
|
1112
946
|
|
|
@@ -1122,54 +956,35 @@ module SimpleCov
|
|
|
1122
956
|
|
|
1123
957
|
def method_statistics: () -> Hash[criterion, CoverageStatistics]
|
|
1124
958
|
|
|
959
|
+
def unaccounted?: (SourceFile source_file, String table) -> bool
|
|
960
|
+
|
|
1125
961
|
def coverage_statistics: (Array[Line | Branch | Method] covered, Array[Line | Branch | Method] missed, ?omitted: Integer, ?percent: Float?) -> CoverageStatistics
|
|
1126
962
|
end
|
|
1127
963
|
end
|
|
1128
964
|
end
|
|
1129
965
|
|
|
1130
|
-
# ----- source_file/builder_context -----
|
|
1131
966
|
|
|
1132
967
|
module SimpleCov
|
|
1133
968
|
class SourceFile
|
|
1134
|
-
# Helpers shared by the per-criterion builders (LineBuilder /
|
|
1135
|
-
# BranchBuilder / MethodBuilder). Mixed into SourceFile so each
|
|
1136
|
-
# builder can ask the file for its skip-chunk ranges and Prism-derived
|
|
1137
|
-
# real source positions without duplicating the memoization.
|
|
1138
969
|
module BuilderContext
|
|
1139
|
-
# Positions extracted from the parsed source: branch start lines,
|
|
1140
|
-
# and [method name, line] pairs. Method names are Symbols from
|
|
1141
|
-
# runtime data and Strings after a JSON round-trip.
|
|
1142
970
|
type real_positions = { branches: Set[Integer], methods: Set[[untyped, Integer]] }
|
|
1143
971
|
|
|
1144
972
|
@skip_chunks: SkipChunks?
|
|
1145
973
|
@real_source_positions: real_positions?
|
|
1146
974
|
|
|
1147
|
-
# Skip-chunk lookup for the named criterion (`:line`, `:branch`,
|
|
1148
|
-
# `:method`).
|
|
1149
975
|
def skip_chunks_for: (criterion) -> Array[Range[Integer]]
|
|
1150
976
|
|
|
1151
|
-
# Memoized set of real source positions extracted via Prism. Returns
|
|
1152
|
-
# nil when Prism is unavailable or parsing fails, signaling callers
|
|
1153
|
-
# to keep every Coverage entry (no false drops). The `defined?`
|
|
1154
|
-
# guard preserves a nil memoization across calls.
|
|
1155
977
|
def real_source_positions: () -> real_positions?
|
|
1156
978
|
|
|
1157
|
-
# Provided by the including class (SourceFile).
|
|
1158
979
|
def filename: () -> String
|
|
1159
980
|
def src: () -> Array[String]
|
|
1160
981
|
end
|
|
1161
982
|
end
|
|
1162
983
|
end
|
|
1163
984
|
|
|
1164
|
-
# ----- coverage_statistics -----
|
|
1165
985
|
|
|
1166
986
|
module SimpleCov
|
|
1167
|
-
# Uniform per-criterion coverage statistics. Counts are Integers;
|
|
1168
|
-
# percent and strength are Floats. `percent` is 100.0 whenever nothing
|
|
1169
|
-
# was missed, including the 0-of-0 case; `strength` is 0.0 when there
|
|
1170
|
-
# is nothing to cover.
|
|
1171
987
|
class CoverageStatistics
|
|
1172
|
-
# Seed for the reduce in .from: covered, missed, omitted, strength.
|
|
1173
988
|
ZERO_STATS: [Integer, Integer, Integer, Float]
|
|
1174
989
|
|
|
1175
990
|
attr_reader total: Integer
|
|
@@ -1181,8 +996,6 @@ module SimpleCov
|
|
|
1181
996
|
|
|
1182
997
|
def self.from: (Array[CoverageStatistics] coverage_statistics) -> CoverageStatistics
|
|
1183
998
|
|
|
1184
|
-
# `percent:` overrides the computed percentage (used to report 0%
|
|
1185
|
-
# for tracked-but-never-loaded files).
|
|
1186
999
|
def initialize: (covered: Integer, missed: Integer, ?omitted: Integer, ?total_strength: Integer | Float, ?percent: Float?) -> void
|
|
1187
1000
|
|
|
1188
1001
|
private
|
|
@@ -1192,16 +1005,11 @@ module SimpleCov
|
|
|
1192
1005
|
end
|
|
1193
1006
|
end
|
|
1194
1007
|
|
|
1195
|
-
# ----- last_run -----
|
|
1196
1008
|
|
|
1197
1009
|
module SimpleCov
|
|
1198
|
-
# Reads and writes coverage/.last_run.json — the previous run's
|
|
1199
|
-
# coverage percentages used by MaximumCoverageDropCheck.
|
|
1200
1010
|
module LastRun
|
|
1201
1011
|
def self.last_run_path: () -> String
|
|
1202
1012
|
|
|
1203
|
-
# nil when the file does not exist, is blank, or does not hold a
|
|
1204
|
-
# JSON object. Keys are symbolized.
|
|
1205
1013
|
def self.read: () -> Hash[Symbol, untyped]?
|
|
1206
1014
|
|
|
1207
1015
|
def self.write: (Hash[Symbol, untyped] json) -> void
|
|
@@ -1210,41 +1018,29 @@ module SimpleCov
|
|
|
1210
1018
|
end
|
|
1211
1019
|
end
|
|
1212
1020
|
|
|
1213
|
-
# ----- filter -----
|
|
1214
1021
|
|
|
1215
1022
|
module SimpleCov
|
|
1216
|
-
# Base filter class. Inherit and override `matches?` to create custom
|
|
1217
|
-
# filters. `T` is the type of the configured filter argument.
|
|
1218
1023
|
class Filter[T]
|
|
1219
1024
|
attr_reader filter_argument: T
|
|
1220
1025
|
|
|
1221
1026
|
def initialize: (T filter_argument) -> void
|
|
1222
1027
|
|
|
1223
|
-
# The base implementation raises NotImplementedError.
|
|
1224
1028
|
def matches?: (SourceFile source_file) -> boolish
|
|
1225
1029
|
|
|
1226
|
-
# Whether the verdict depends only on the path, so it can be decided
|
|
1227
|
-
# before the file has any coverage.
|
|
1228
1030
|
def path_only?: () -> bool
|
|
1229
1031
|
|
|
1230
1032
|
def self.build_filter: (filter_arg filter_argument, ?string_filter: singleton(Filter)) -> Filter[untyped]
|
|
1231
1033
|
|
|
1232
1034
|
def self.class_for_argument: (filter_arg filter_argument) -> singleton(Filter)
|
|
1233
1035
|
|
|
1234
|
-
# Maps raw filter-argument classes (String, Regexp, Array, Proc) to
|
|
1235
|
-
# the Filter subclass that handles them. Private class method.
|
|
1236
1036
|
self.@filter_classes_by_argument_type: Hash[Class, singleton(Filter)]?
|
|
1237
1037
|
|
|
1238
1038
|
def self.filter_classes_by_argument_type: () -> Hash[Class, singleton(Filter)]
|
|
1239
1039
|
end
|
|
1240
1040
|
|
|
1241
|
-
# Matches when the project path contains the configured string at a
|
|
1242
|
-
# path-segment boundary ("lib" matches "lib/foo.rb" but not "library/").
|
|
1243
1041
|
class StringFilter < Filter[String]
|
|
1244
1042
|
def matches?: (SourceFile source_file) -> bool
|
|
1245
1043
|
|
|
1246
|
-
# Whether the verdict depends only on the path, so it can be decided
|
|
1247
|
-
# before the file has any coverage.
|
|
1248
1044
|
def path_only?: () -> bool
|
|
1249
1045
|
|
|
1250
1046
|
private
|
|
@@ -1256,122 +1052,81 @@ module SimpleCov
|
|
|
1256
1052
|
def compute_segment_pattern: () -> Regexp
|
|
1257
1053
|
end
|
|
1258
1054
|
|
|
1259
|
-
# Matches when the project path matches the configured Regexp.
|
|
1260
1055
|
class RegexFilter < Filter[Regexp]
|
|
1261
1056
|
def matches?: (SourceFile source_file) -> bool
|
|
1262
1057
|
|
|
1263
|
-
# Whether the verdict depends only on the path, so it can be decided
|
|
1264
|
-
# before the file has any coverage.
|
|
1265
1058
|
def path_only?: () -> bool
|
|
1266
1059
|
end
|
|
1267
1060
|
|
|
1268
|
-
# Matches when the configured block returns truthy for the source file.
|
|
1269
1061
|
class BlockFilter < Filter[^(SourceFile) -> boolish]
|
|
1270
1062
|
def matches?: (SourceFile source_file) -> boolish
|
|
1271
1063
|
|
|
1272
|
-
# Whether the verdict depends only on the path, so it can be decided
|
|
1273
|
-
# before the file has any coverage.
|
|
1274
1064
|
def path_only?: () -> bool
|
|
1275
1065
|
end
|
|
1276
1066
|
|
|
1277
|
-
# Matches when the project path matches the configured shell glob
|
|
1278
|
-
# (e.g. "lib/**/*.rb").
|
|
1279
1067
|
class GlobFilter < Filter[String]
|
|
1280
1068
|
def matches?: (SourceFile source_file) -> bool
|
|
1281
1069
|
|
|
1282
|
-
# Whether the verdict depends only on the path, so it can be decided
|
|
1283
|
-
# before the file has any coverage.
|
|
1284
1070
|
def path_only?: () -> bool
|
|
1285
1071
|
end
|
|
1286
1072
|
|
|
1287
|
-
# Matches when any of the component filters built from the array's
|
|
1288
|
-
# elements match. Note: `filter_argument` holds the built Filter
|
|
1289
|
-
# objects, not the raw array passed to `new`.
|
|
1290
1073
|
class ArrayFilter < Filter[Array[Filter[untyped]]]
|
|
1291
1074
|
def initialize: (Array[filter_arg] filter_argument) -> void
|
|
1292
1075
|
|
|
1293
1076
|
def matches?: (SourceFile source_file) -> boolish
|
|
1294
1077
|
|
|
1295
|
-
# Whether the verdict depends only on the path, so it can be decided
|
|
1296
|
-
# before the file has any coverage.
|
|
1297
1078
|
def path_only?: () -> bool
|
|
1298
1079
|
end
|
|
1299
1080
|
end
|
|
1300
1081
|
|
|
1301
|
-
# ----- formatter -----
|
|
1302
1082
|
|
|
1303
1083
|
module SimpleCov
|
|
1304
|
-
# Namespace for result formatters. A formatter is any class whose
|
|
1305
|
-
# instances respond to `#format(result)` and that can be instantiated
|
|
1306
|
-
# with no arguments, or a ready-built instance responding to
|
|
1307
|
-
# `#format(result)`; wire one up via `SimpleCov.formatter=` or
|
|
1308
|
-
# `SimpleCov.formatters=`.
|
|
1309
1084
|
module Formatter
|
|
1310
|
-
# Structural interface for custom formatter instances.
|
|
1311
1085
|
interface _Formatter
|
|
1312
1086
|
def format: (SimpleCov::Result result) -> untyped
|
|
1313
1087
|
end
|
|
1314
1088
|
|
|
1315
|
-
# Normalizes a configured formatter — class or ready-built
|
|
1316
|
-
# instance — into an instance. See #1240.
|
|
1317
1089
|
def self.instance_for: (untyped formatter) -> untyped
|
|
1318
1090
|
|
|
1319
|
-
|
|
1091
|
+
def self.instantiable?: (untyped formatter) -> bool
|
|
1092
|
+
|
|
1320
1093
|
def self.format: (untyped formatter, SimpleCov::Result result) -> untyped
|
|
1321
1094
|
end
|
|
1322
1095
|
end
|
|
1323
1096
|
|
|
1324
|
-
# ----- formatter/base -----
|
|
1325
1097
|
|
|
1326
1098
|
module SimpleCov
|
|
1327
1099
|
module Formatter
|
|
1328
|
-
# @api private — shared scaffolding for formatters that write a
|
|
1329
|
-
# report to an output directory and emit the "Coverage report
|
|
1330
|
-
# generated for X to Y" status line on stderr. Subclasses implement
|
|
1331
|
-
# `format`.
|
|
1332
1100
|
class Base
|
|
1333
1101
|
@silent: bool
|
|
1334
1102
|
@output_dir: String?
|
|
1335
1103
|
|
|
1336
|
-
# `output_dir` defaults to `SimpleCov.coverage_path` when nil.
|
|
1337
1104
|
def initialize: (?silent: bool, ?output_dir: String?) -> void
|
|
1338
1105
|
|
|
1339
1106
|
private
|
|
1340
1107
|
|
|
1341
|
-
# Subclasses prepend a marker (e.g. "JSON ") to the summary line.
|
|
1342
1108
|
def message_prefix: () -> String
|
|
1343
1109
|
|
|
1344
1110
|
def output_path: () -> String
|
|
1345
1111
|
|
|
1346
|
-
# Directory (relative to cwd when inside it) plus the subclass's
|
|
1347
|
-
# `entry_point_filename`, for the status line. See issue #197.
|
|
1348
1112
|
def displayable_output_path: () -> String
|
|
1349
1113
|
|
|
1350
1114
|
def relative_or_absolute_output_path: () -> String
|
|
1351
1115
|
|
|
1352
|
-
# Subclasses name the report's entry-point file (`index.html`,
|
|
1353
|
-
# `coverage.json`); nil leaves the bare directory in the status line.
|
|
1354
1116
|
def entry_point_filename: () -> String?
|
|
1355
1117
|
|
|
1356
|
-
|
|
1357
|
-
# the "status lines go to stderr, not through warn" decision (#1225).
|
|
1358
|
-
def emit_status: (SimpleCov::Result result) -> void
|
|
1118
|
+
def emit_status: (untyped result) -> void
|
|
1359
1119
|
|
|
1360
|
-
def output_message: (
|
|
1120
|
+
def output_message: (untyped result) -> String
|
|
1361
1121
|
|
|
1362
|
-
# nil for branch/method criteria with nothing to measure, so the
|
|
1363
|
-
# summary doesn't print "Branch coverage: 0 / 0 (100.00%)" noise.
|
|
1364
1122
|
def stats_line: (Symbol criterion, SimpleCov::CoverageStatistics stat) -> String?
|
|
1365
1123
|
end
|
|
1366
1124
|
end
|
|
1367
1125
|
end
|
|
1368
1126
|
|
|
1369
|
-
# ----- formatter/simple_formatter -----
|
|
1370
1127
|
|
|
1371
1128
|
module SimpleCov
|
|
1372
1129
|
module Formatter
|
|
1373
|
-
# Renders the result as a plain-text string, one section per group.
|
|
1374
|
-
# Returns the string; does not write anything to disk.
|
|
1375
1130
|
class SimpleFormatter
|
|
1376
1131
|
def format: (SimpleCov::Result result) -> String
|
|
1377
1132
|
|
|
@@ -1382,52 +1137,31 @@ module SimpleCov
|
|
|
1382
1137
|
end
|
|
1383
1138
|
end
|
|
1384
1139
|
|
|
1385
|
-
# ----- formatter/multi_formatter -----
|
|
1386
1140
|
|
|
1387
1141
|
module SimpleCov
|
|
1388
1142
|
module Formatter
|
|
1389
|
-
# Wraps multiple formatters so one configured formatter can drive
|
|
1390
|
-
# several output formats (HTML + JSON, etc.) in a single run.
|
|
1391
1143
|
class MultiFormatter
|
|
1392
|
-
# Shared `#format` implementation, included into the anonymous
|
|
1393
|
-
# classes that `MultiFormatter.new` builds. Formatter errors are
|
|
1394
|
-
# rescued and mapped to nil, so the result array can hold nils.
|
|
1395
1144
|
module InstanceMethods
|
|
1396
1145
|
def format: (SimpleCov::Result result) -> Array[untyped]
|
|
1397
1146
|
|
|
1398
|
-
# Defined via `define_method` on each class `MultiFormatter.new`
|
|
1399
|
-
# builds; declared here so users of those classes type-check.
|
|
1400
1147
|
def formatters: () -> Array[untyped]
|
|
1401
1148
|
end
|
|
1402
1149
|
|
|
1403
|
-
# Returns a newly built Class (not a MultiFormatter instance) whose
|
|
1404
|
-
# instances respond to `#format` and `#formatters`. The argument is
|
|
1405
|
-
# normalized with `Array()`: a single formatter, an array of
|
|
1406
|
-
# formatters, or nil are all accepted.
|
|
1407
1150
|
def self.new: (?untyped formatters) -> Class
|
|
1408
1151
|
end
|
|
1409
1152
|
end
|
|
1410
1153
|
end
|
|
1411
1154
|
|
|
1412
|
-
# ----- formatter/html_formatter -----
|
|
1413
1155
|
|
|
1414
1156
|
module SimpleCov
|
|
1415
1157
|
module Formatter
|
|
1416
|
-
# Writes the HTML report as a single self-contained index.html (the
|
|
1417
|
-
# compiled template with the coverage JSON substituted at the data
|
|
1418
|
-
# marker), and coverage.json as a side artifact (shared serialization
|
|
1419
|
-
# via JSONFormatter.build_hash).
|
|
1420
1158
|
class HTMLFormatter < Base
|
|
1421
1159
|
DATA_MARKER: "<!-- SIMPLECOV_COVERAGE_DATA -->"
|
|
1422
1160
|
|
|
1423
|
-
# The sibling files a 1.0.0 through 1.0.3 report wrote next to
|
|
1424
|
-
# index.html, removed by format when an earlier version left them.
|
|
1425
1161
|
LEGACY_REPORT_FILES: Array[String]
|
|
1426
1162
|
|
|
1427
1163
|
def format: (SimpleCov::Result result) -> void
|
|
1428
1164
|
|
|
1429
|
-
# Generate HTML from a pre-existing coverage.json file without a
|
|
1430
|
-
# live SimpleCov::Result or a running test suite.
|
|
1431
1165
|
def format_from_json: (String json_path, String output_dir) -> void
|
|
1432
1166
|
|
|
1433
1167
|
private
|
|
@@ -1436,11 +1170,8 @@ module SimpleCov
|
|
|
1436
1170
|
|
|
1437
1171
|
def source_less_hash: (Hash[Symbol, untyped] hash) -> Hash[Symbol, untyped]
|
|
1438
1172
|
|
|
1439
|
-
# Write coverage.json and index.html, then clear any legacy
|
|
1440
|
-
# sibling files an earlier version left in the output directory.
|
|
1441
1173
|
def write_report_files: (Hash[untyped, untyped] json_hash, Hash[untyped, untyped] viewer_hash, SimpleCov::Result result) -> void
|
|
1442
1174
|
|
|
1443
|
-
# Substitute the coverage JSON into the compiled template.
|
|
1444
1175
|
def render_report: (String json) -> String
|
|
1445
1176
|
|
|
1446
1177
|
def public_dir: () -> String
|
|
@@ -1448,13 +1179,40 @@ module SimpleCov
|
|
|
1448
1179
|
end
|
|
1449
1180
|
end
|
|
1450
1181
|
|
|
1451
|
-
# ----- formatter/coverage_json_writer -----
|
|
1452
1182
|
|
|
1453
1183
|
module SimpleCov
|
|
1454
1184
|
module Formatter
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1185
|
+
class BaselineFormatter < Base
|
|
1186
|
+
def format: (SimpleCov::Result result) -> void
|
|
1187
|
+
|
|
1188
|
+
private
|
|
1189
|
+
|
|
1190
|
+
def ratchet: (SimpleCov::Result result) -> String
|
|
1191
|
+
|
|
1192
|
+
def generate: (Baseline::current_floors current) -> String
|
|
1193
|
+
|
|
1194
|
+
def summary: (Baseline::Outcome outcome, bool changed) -> String
|
|
1195
|
+
|
|
1196
|
+
def below_floors: (Array[String] regressed) -> String
|
|
1197
|
+
|
|
1198
|
+
def current_floors: (SimpleCov::Result result) -> Baseline::current_floors
|
|
1199
|
+
|
|
1200
|
+
def measured_criteria: () -> Array[Symbol]
|
|
1201
|
+
|
|
1202
|
+
def floor_of: (untyped file, Symbol criterion) -> { percent: Numeric, missed: Integer }
|
|
1203
|
+
|
|
1204
|
+
def write: (Baseline baseline) -> void
|
|
1205
|
+
|
|
1206
|
+
def output_path: () -> String
|
|
1207
|
+
|
|
1208
|
+
def output_message: (untyped message) -> String
|
|
1209
|
+
end
|
|
1210
|
+
end
|
|
1211
|
+
end
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
module SimpleCov
|
|
1215
|
+
module Formatter
|
|
1458
1216
|
module CoverageJSONWriter
|
|
1459
1217
|
FILENAME: "coverage.json"
|
|
1460
1218
|
|
|
@@ -1462,20 +1220,14 @@ module SimpleCov
|
|
|
1462
1220
|
|
|
1463
1221
|
def self?.write: (untyped output_path, Hash[Symbol, untyped] hash, SimpleCov::Result result) -> String
|
|
1464
1222
|
|
|
1465
|
-
# Warns when an existing coverage.json is newer than this process's
|
|
1466
|
-
# start time (a concurrent sibling writer). See issue #1171.
|
|
1467
1223
|
def self?.warn_if_concurrent_overwrite: (String path, SimpleCov::Result result) -> void
|
|
1468
1224
|
|
|
1469
|
-
# timestamp stays untyped (not Time) so the comparison sites don't
|
|
1470
|
-
# require the stdlib `time` extension sigs; the value is produced by
|
|
1471
|
-
# Time.iso8601 at runtime.
|
|
1472
1225
|
def self?.existing_meta: (String path) -> ({ timestamp: untyped, command_name: untyped })?
|
|
1473
1226
|
|
|
1227
|
+
def self?.parse_time: (untyped value) -> untyped
|
|
1228
|
+
|
|
1474
1229
|
def self?.parse_meta: (String path) -> Hash[Symbol, untyped]?
|
|
1475
1230
|
|
|
1476
|
-
# Bounded head read that parses just the flat meta object of files
|
|
1477
|
-
# this module wrote; nil on any miss so parse_meta falls back to a
|
|
1478
|
-
# full parse.
|
|
1479
1231
|
def self?.parse_meta_head: (String path) -> Hash[Symbol, untyped]?
|
|
1480
1232
|
|
|
1481
1233
|
def self?.parse_meta_full: (String path) -> Hash[Symbol, untyped]?
|
|
@@ -1483,18 +1235,12 @@ module SimpleCov
|
|
|
1483
1235
|
end
|
|
1484
1236
|
end
|
|
1485
1237
|
|
|
1486
|
-
# ----- formatter/json_formatter -----
|
|
1487
1238
|
|
|
1488
1239
|
module SimpleCov
|
|
1489
1240
|
module Formatter
|
|
1490
|
-
# Writes coverage results as JSON to coverage/coverage.json.
|
|
1491
1241
|
class JSONFormatter < Base
|
|
1492
1242
|
FILENAME: "coverage.json"
|
|
1493
1243
|
|
|
1494
|
-
# The hash serialized to coverage.json ($schema, meta, total,
|
|
1495
|
-
# coverage, groups, errors). `include_source:` defaults to
|
|
1496
|
-
# `SimpleCov.source_in_json`; pass true to force the per-file
|
|
1497
|
-
# source arrays regardless of the global setting.
|
|
1498
1244
|
def self.build_hash: (SimpleCov::Result result, ?include_source: bool) -> Hash[Symbol, untyped]
|
|
1499
1245
|
|
|
1500
1246
|
def format: (SimpleCov::Result result) -> void
|
|
@@ -1508,10 +1254,8 @@ module SimpleCov
|
|
|
1508
1254
|
end
|
|
1509
1255
|
end
|
|
1510
1256
|
|
|
1511
|
-
# ----- exit_codes -----
|
|
1512
1257
|
|
|
1513
1258
|
module SimpleCov
|
|
1514
|
-
# Exit codes SimpleCov uses when a coverage check fails.
|
|
1515
1259
|
module ExitCodes
|
|
1516
1260
|
SUCCESS: 0
|
|
1517
1261
|
|
|
@@ -1523,20 +1267,15 @@ module SimpleCov
|
|
|
1523
1267
|
|
|
1524
1268
|
MAXIMUM_COVERAGE: 4
|
|
1525
1269
|
|
|
1526
|
-
|
|
1527
|
-
|
|
1270
|
+
UNITS: Hash[Symbol, String]
|
|
1271
|
+
|
|
1528
1272
|
def self.print_error: (String message) -> void
|
|
1529
1273
|
end
|
|
1530
1274
|
end
|
|
1531
1275
|
|
|
1532
|
-
# ----- exit_codes/exit_code_handling -----
|
|
1533
1276
|
|
|
1534
1277
|
module SimpleCov
|
|
1535
1278
|
module ExitCodes
|
|
1536
|
-
# The threshold-limit readers ExitCodeHandling consults. Satisfied by
|
|
1537
|
-
# SimpleCov's own configuration, or by any object exposing the same
|
|
1538
|
-
# readers (see the dogfood check in spec/helper.rb for an example
|
|
1539
|
-
# built from a plain Data class).
|
|
1540
1279
|
interface _CoverageLimits
|
|
1541
1280
|
def minimum_coverage: () -> Hash[Symbol, Numeric]
|
|
1542
1281
|
|
|
@@ -1549,66 +1288,313 @@ module SimpleCov
|
|
|
1549
1288
|
def maximum_coverage: () -> Hash[Symbol, Numeric]
|
|
1550
1289
|
|
|
1551
1290
|
def maximum_coverage_drop: () -> Hash[Symbol, Numeric]
|
|
1291
|
+
|
|
1292
|
+
def maximum_missed: () -> Hash[Symbol, Integer]
|
|
1293
|
+
|
|
1294
|
+
def maximum_missed_per_file: () -> Hash[Symbol, Integer]
|
|
1295
|
+
|
|
1296
|
+
def maximum_missed_per_file_overrides: () -> untyped
|
|
1297
|
+
|
|
1298
|
+
def baseline: () -> Baseline?
|
|
1552
1299
|
end
|
|
1553
1300
|
|
|
1554
|
-
# Runs every coverage check against the result and returns the exit
|
|
1555
|
-
# code of the first failing one, or SUCCESS when all pass.
|
|
1556
1301
|
module ExitCodeHandling
|
|
1557
1302
|
def self?.call: (SimpleCov::Result result, coverage_limits: _CoverageLimits) -> Integer
|
|
1558
1303
|
|
|
1559
1304
|
def self?.coverage_checks: (SimpleCov::Result result, _CoverageLimits coverage_limits) -> Array[untyped]
|
|
1305
|
+
|
|
1306
|
+
def self?.minimum_by_file_check: (SimpleCov::Result result, _CoverageLimits coverage_limits) -> untyped
|
|
1307
|
+
|
|
1308
|
+
def self?.maximum_missed_per_file_check: (SimpleCov::Result result, _CoverageLimits coverage_limits) -> untyped
|
|
1560
1309
|
end
|
|
1561
1310
|
end
|
|
1562
1311
|
end
|
|
1563
1312
|
|
|
1564
|
-
# ----- profiles -----
|
|
1565
1313
|
|
|
1566
1314
|
module SimpleCov
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1315
|
+
module History
|
|
1316
|
+
ENVELOPE: String
|
|
1317
|
+
|
|
1318
|
+
FORMAT_VERSION: Integer
|
|
1319
|
+
|
|
1320
|
+
type entry = Hash[String, untyped]
|
|
1321
|
+
|
|
1322
|
+
def self.history_path: () -> String
|
|
1323
|
+
|
|
1324
|
+
def self.record: (SimpleCov::Result result) -> void
|
|
1325
|
+
|
|
1326
|
+
def self.read: () -> Array[entry]
|
|
1327
|
+
|
|
1328
|
+
def self.entries_with: (SimpleCov::Result result) -> Array[entry]
|
|
1329
|
+
|
|
1330
|
+
def self.git_info: () -> [String?, String?]
|
|
1331
|
+
|
|
1332
|
+
private
|
|
1333
|
+
|
|
1334
|
+
def self.entry_for: (SimpleCov::Result result) -> entry
|
|
1335
|
+
|
|
1336
|
+
def self.measured_percents: (untyped stats_source) -> Hash[String, Numeric]
|
|
1337
|
+
|
|
1338
|
+
def self.files_percents: (SimpleCov::Result result) -> Hash[String, Hash[String, Numeric]]
|
|
1339
|
+
|
|
1340
|
+
def self.write: (Array[entry] entries) -> void
|
|
1341
|
+
|
|
1342
|
+
def self.invalid_history: () -> Array[entry]
|
|
1343
|
+
|
|
1344
|
+
def self.git: (*String args) -> String?
|
|
1345
|
+
end
|
|
1346
|
+
end
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
module SimpleCov
|
|
1350
|
+
module Configuration
|
|
1351
|
+
DROP_BASELINES: Array[Symbol]
|
|
1352
|
+
|
|
1353
|
+
@history_limit: Integer?
|
|
1354
|
+
|
|
1355
|
+
@drop_baseline: Symbol?
|
|
1356
|
+
|
|
1357
|
+
def history_limit: (?Integer? limit) -> Integer
|
|
1358
|
+
|
|
1359
|
+
def history_limit=: (Integer limit) -> Integer
|
|
1360
|
+
|
|
1361
|
+
def drop_baseline: (?Symbol? mode) -> Symbol
|
|
1362
|
+
end
|
|
1363
|
+
end
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
module SimpleCov
|
|
1367
|
+
module Configuration
|
|
1368
|
+
@production_coverage: String?
|
|
1369
|
+
|
|
1370
|
+
def production_coverage: (?String? path) -> String?
|
|
1371
|
+
|
|
1372
|
+
def production_coverage=: (String path) -> String
|
|
1373
|
+
end
|
|
1374
|
+
end
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
module SimpleCov
|
|
1378
|
+
module Production
|
|
1379
|
+
class Error < StandardError
|
|
1380
|
+
end
|
|
1381
|
+
|
|
1382
|
+
interface _Sink
|
|
1383
|
+
def store: (Hash[String, Array[Integer]] coverage) -> untyped
|
|
1384
|
+
end
|
|
1385
|
+
|
|
1386
|
+
self.@running: bool?
|
|
1387
|
+
self.@pid: Integer?
|
|
1388
|
+
self.@started_coverage: bool?
|
|
1389
|
+
self.@root_prefix: String
|
|
1390
|
+
self.@sink: _Sink
|
|
1391
|
+
self.@flush_interval: Float | Integer
|
|
1392
|
+
self.@flush_jitter: Float | Integer
|
|
1393
|
+
self.@sample_rate: Float | Integer
|
|
1394
|
+
self.@max_buffered_lines: Integer
|
|
1395
|
+
self.@pending: Hash[String, Set[Integer]]
|
|
1396
|
+
self.@measuring: bool
|
|
1397
|
+
self.@mutex: Mutex
|
|
1398
|
+
self.@waiter: ConditionVariable
|
|
1399
|
+
self.@thread: Thread?
|
|
1400
|
+
self.@at_exit_installed: bool?
|
|
1401
|
+
|
|
1402
|
+
def self.start: (?root: String, ?sink: _Sink?, ?flush_interval: (Float | Integer),
|
|
1403
|
+
?flush_jitter: (Float | Integer)?, ?sample_rate: (Float | Integer),
|
|
1404
|
+
?max_buffered_lines: Integer) -> bool
|
|
1405
|
+
|
|
1406
|
+
def self.running?: () -> bool
|
|
1407
|
+
|
|
1408
|
+
def self.flush: () -> bool
|
|
1409
|
+
|
|
1410
|
+
def self.stop: () -> bool
|
|
1411
|
+
|
|
1412
|
+
def self.reset!: () -> void
|
|
1413
|
+
|
|
1414
|
+
private
|
|
1415
|
+
|
|
1416
|
+
def self.validate!: ((Float | Integer) flush_interval, (Float | Integer)? flush_jitter,
|
|
1417
|
+
(Float | Integer) sample_rate, Integer max_buffered_lines) -> void
|
|
1418
|
+
|
|
1419
|
+
def self.validate_jitter!: ((Float | Integer)? flush_jitter) -> void
|
|
1420
|
+
|
|
1421
|
+
def self.claim_coverage: () -> boolish
|
|
1422
|
+
|
|
1423
|
+
def self.oneshot_supported?: () -> bool
|
|
1424
|
+
|
|
1425
|
+
def self.configure: (String root, _Sink? sink, flush_interval: (Float | Integer),
|
|
1426
|
+
flush_jitter: (Float | Integer)?, sample_rate: (Float | Integer),
|
|
1427
|
+
max_buffered_lines: Integer) -> void
|
|
1428
|
+
|
|
1429
|
+
def self.default_sink: (String root) -> FileSink
|
|
1430
|
+
|
|
1431
|
+
def self.spawn_flush_thread: () -> void
|
|
1432
|
+
|
|
1433
|
+
def self.flush_loop: () -> void
|
|
1434
|
+
|
|
1435
|
+
def self.interval_with_jitter: () -> (Float | Integer)
|
|
1436
|
+
|
|
1437
|
+
def self.wake_flush_thread: () -> void
|
|
1438
|
+
|
|
1439
|
+
def self.cycle: () -> void
|
|
1440
|
+
|
|
1441
|
+
def self.resample: () -> void
|
|
1442
|
+
|
|
1443
|
+
def self.pull_pending: () -> void
|
|
1444
|
+
|
|
1445
|
+
def self.push_pending: () -> bool
|
|
1446
|
+
|
|
1447
|
+
def self.enforce_ceiling: () -> void
|
|
1448
|
+
|
|
1449
|
+
def self.relativize: (String path) -> String?
|
|
1450
|
+
|
|
1451
|
+
def self.warn_decline: (String reason) -> false
|
|
1452
|
+
|
|
1453
|
+
def self.install_at_exit: () -> void
|
|
1454
|
+
|
|
1455
|
+
end
|
|
1456
|
+
end
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
module SimpleCov
|
|
1460
|
+
module Production
|
|
1461
|
+
class FileSink
|
|
1462
|
+
ENVELOPE: String
|
|
1463
|
+
|
|
1464
|
+
FORMAT_VERSION: Integer
|
|
1465
|
+
|
|
1466
|
+
attr_reader path: String
|
|
1467
|
+
|
|
1468
|
+
def initialize: (path: String) -> void
|
|
1469
|
+
|
|
1470
|
+
def store: (Hash[String, Array[Integer]] coverage) -> true
|
|
1471
|
+
|
|
1472
|
+
def self.read: (String path) -> Hash[String, untyped]
|
|
1473
|
+
|
|
1474
|
+
def self.parse: (String content, String path) -> Hash[String, untyped]
|
|
1475
|
+
|
|
1476
|
+
def self.envelope_of: (untyped document, String path) -> Hash[String, untyped]
|
|
1477
|
+
|
|
1478
|
+
private
|
|
1479
|
+
|
|
1480
|
+
def with_exclusive_lock: [T] () { (File file) -> T } -> T
|
|
1481
|
+
|
|
1482
|
+
def open_file: [T] (String name, Integer mode, Integer perm) { (File file) -> T } -> T
|
|
1483
|
+
|
|
1484
|
+
def rewrite: (File file, Hash[String, untyped] payload) -> void
|
|
1485
|
+
|
|
1486
|
+
def merge: (Hash[String, untyped] existing, Hash[String, Array[Integer]] incoming) -> Hash[String, untyped]
|
|
1487
|
+
|
|
1488
|
+
def envelope: (Hash[String, untyped] existing, Hash[String, Array[Integer]] incoming) -> Hash[String, untyped]
|
|
1489
|
+
end
|
|
1490
|
+
end
|
|
1491
|
+
end
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
module SimpleCov
|
|
1495
|
+
class Baseline
|
|
1496
|
+
DEFAULT_FILENAME: String
|
|
1497
|
+
|
|
1498
|
+
class Floor
|
|
1499
|
+
attr_reader percent: Numeric
|
|
1500
|
+
attr_reader missed: Integer?
|
|
1501
|
+
|
|
1502
|
+
def initialize: (percent: Numeric, missed: Integer?) -> void
|
|
1503
|
+
end
|
|
1504
|
+
|
|
1505
|
+
class Outcome
|
|
1506
|
+
attr_reader baseline: Baseline
|
|
1507
|
+
attr_reader tightened: Array[String]
|
|
1508
|
+
attr_reader pruned: Array[String]
|
|
1509
|
+
attr_reader regressed: Array[String]
|
|
1510
|
+
attr_reader unchanged: Array[String]
|
|
1511
|
+
|
|
1512
|
+
def initialize: (baseline: Baseline, tightened: Array[String], pruned: Array[String],
|
|
1513
|
+
regressed: Array[String], unchanged: Array[String]) -> void
|
|
1514
|
+
end
|
|
1515
|
+
|
|
1516
|
+
type current_floors = Hash[String, Hash[Symbol, {percent: Numeric, missed: Integer}]]
|
|
1517
|
+
|
|
1518
|
+
def self.read_if_exists: (String path) -> Baseline?
|
|
1519
|
+
|
|
1520
|
+
def self.read: (String path) -> Baseline?
|
|
1521
|
+
|
|
1522
|
+
def self.generate: (current_floors current) -> Baseline
|
|
1523
|
+
|
|
1524
|
+
attr_reader entries: Hash[String, Hash[Symbol, Floor]]
|
|
1525
|
+
|
|
1526
|
+
def initialize: (Hash[String, Hash[Symbol, Floor]] entries) -> void
|
|
1527
|
+
|
|
1528
|
+
def entry_for: (String project_filename) -> Hash[Symbol, Floor]?
|
|
1529
|
+
|
|
1530
|
+
def floor_for: (String project_filename, Symbol criterion) -> Floor?
|
|
1531
|
+
|
|
1532
|
+
def covers?: (String project_filename, Symbol criterion) -> bool
|
|
1533
|
+
|
|
1534
|
+
def ratchet: (current_floors current) -> Outcome
|
|
1535
|
+
|
|
1536
|
+
def to_yaml: () -> String
|
|
1537
|
+
|
|
1538
|
+
private
|
|
1539
|
+
|
|
1540
|
+
def ratchet_entry: (Hash[Symbol, Floor] entry, Hash[Symbol, {percent: Numeric, missed: Integer}]? current_entry) -> {bucket: Symbol, ?entry: Hash[Symbol, Floor]}
|
|
1541
|
+
|
|
1542
|
+
def bucket_for: (Hash[Symbol, Floor] entry, Hash[Symbol, Floor] merged, Hash[Symbol, {percent: Numeric, missed: Integer}] current_entry) -> Symbol
|
|
1543
|
+
|
|
1544
|
+
def tighten: (Floor? floor, {percent: Numeric, missed: Integer}? current) -> Floor
|
|
1545
|
+
|
|
1546
|
+
def dump_floor: (Floor floor) -> Hash[String, untyped]
|
|
1547
|
+
end
|
|
1548
|
+
end
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
module SimpleCov
|
|
1552
|
+
module Configuration
|
|
1553
|
+
DEPRECATION_MODES: Array[Symbol]
|
|
1554
|
+
|
|
1555
|
+
@deprecations: Symbol?
|
|
1556
|
+
|
|
1557
|
+
def deprecations: (?Symbol? mode) -> Symbol
|
|
1558
|
+
end
|
|
1559
|
+
end
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
module SimpleCov
|
|
1563
|
+
module Configuration
|
|
1564
|
+
@baseline_file: String?
|
|
1565
|
+
|
|
1566
|
+
@baseline: Baseline?
|
|
1567
|
+
|
|
1568
|
+
@baseline_path: String?
|
|
1569
|
+
|
|
1570
|
+
def baseline_file: (?String? path) -> String
|
|
1571
|
+
|
|
1572
|
+
def baseline_file=: (String path) -> String
|
|
1573
|
+
|
|
1574
|
+
def baseline: () -> Baseline?
|
|
1575
|
+
end
|
|
1576
|
+
end
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
module SimpleCov
|
|
1575
1580
|
type profile_proc = ^() [self: untyped] -> void
|
|
1576
1581
|
|
|
1577
1582
|
class Profiles < Hash[Symbol, profile_proc]
|
|
1578
|
-
# Raises SimpleCov::ConfigurationError when the name is taken.
|
|
1579
|
-
# The block runs via instance_exec against the SimpleCov module itself
|
|
1580
|
-
# (which extends Configuration), not a Configuration instance.
|
|
1581
1583
|
def define: (Symbol | String name) { () [self: singleton(SimpleCov)] -> void } -> profile_proc
|
|
1582
1584
|
|
|
1583
|
-
# Applies the named profile via SimpleCov.configure.
|
|
1584
1585
|
def load: (Symbol | String name) -> void
|
|
1585
1586
|
|
|
1586
|
-
# Returns the proc for the given profile name, autoloading bundled
|
|
1587
|
-
# ("simplecov/profiles/<name>") or plugin-gem
|
|
1588
|
-
# ("simplecov-profile-<name>") profiles on first lookup. Raises
|
|
1589
|
-
# SimpleCov::ConfigurationError when none is found.
|
|
1590
1587
|
def fetch_proc: (Symbol | String name) -> profile_proc
|
|
1591
1588
|
|
|
1592
1589
|
private
|
|
1593
1590
|
|
|
1594
|
-
# Tries `require "simplecov/profiles/<name>"`, then
|
|
1595
|
-
# `require "simplecov-profile-<name>"`; swallows LoadError so
|
|
1596
|
-
# fetch_proc raises the user-facing error.
|
|
1597
1591
|
def autoload_profile: (Symbol name) -> void
|
|
1598
1592
|
end
|
|
1599
1593
|
end
|
|
1600
1594
|
|
|
1601
|
-
# ----- parallel_adapters -----
|
|
1602
1595
|
|
|
1603
1596
|
module SimpleCov
|
|
1604
|
-
# Registry + selection for parallel-test-runner adapters. An adapter is
|
|
1605
|
-
# a class (used as a singleton, never instantiated) answering the
|
|
1606
|
-
# `_Adapter` contract; subclass `ParallelAdapters::Base` to inherit
|
|
1607
|
-
# no-op defaults. Register custom adapters via
|
|
1608
|
-
# `SimpleCov::ParallelAdapters.register MyRunnerAdapter`.
|
|
1609
1597
|
module ParallelAdapters
|
|
1610
|
-
# The class-level contract an adapter must answer. `singleton(Base)`
|
|
1611
|
-
# and its subclasses satisfy this structurally.
|
|
1612
1598
|
interface _Adapter
|
|
1613
1599
|
def active?: () -> boolish
|
|
1614
1600
|
|
|
@@ -1621,93 +1607,51 @@ module SimpleCov
|
|
|
1621
1607
|
def expected_worker_count: () -> Integer
|
|
1622
1608
|
end
|
|
1623
1609
|
|
|
1624
|
-
# Registry state. Declared on both the instance and singleton sides
|
|
1625
|
-
# because `module_function` bodies type-check as instance methods
|
|
1626
|
-
# while runtime state lives on the module itself.
|
|
1627
1610
|
@adapters: Array[_Adapter]?
|
|
1628
1611
|
|
|
1629
1612
|
self.@adapters: Array[_Adapter]?
|
|
1630
1613
|
|
|
1631
|
-
# Memoized current adapter. Distinguishes "not yet computed" (ivar
|
|
1632
|
-
# undefined) from "computed, no adapter active" (nil), hence the
|
|
1633
|
-
# `defined?` guard in the implementation.
|
|
1634
1614
|
@current: _Adapter?
|
|
1635
1615
|
|
|
1636
1616
|
self.@current: _Adapter?
|
|
1637
1617
|
|
|
1638
|
-
# Adapters in selection order: user-registered adapters first, then
|
|
1639
|
-
# ParallelTestsAdapter, then GenericAdapter.
|
|
1640
1618
|
def self?.adapters: () -> Array[_Adapter]
|
|
1641
1619
|
|
|
1642
|
-
# Registers a custom adapter at the front of the selection list and
|
|
1643
|
-
# returns it. Clears the memoized `current` selection.
|
|
1644
1620
|
def self?.register: (_Adapter adapter) -> _Adapter
|
|
1645
1621
|
|
|
1646
|
-
# The first registered adapter whose `active?` returns true, or nil
|
|
1647
|
-
# when no recognized parallel runner is active (single-worker run).
|
|
1648
1622
|
def self?.current: () -> _Adapter?
|
|
1649
1623
|
|
|
1650
|
-
# Clears the memoized `current` selection (primarily for tests that
|
|
1651
|
-
# mutate env vars between examples).
|
|
1652
1624
|
def self?.reset_current!: () -> void
|
|
1653
1625
|
end
|
|
1654
1626
|
end
|
|
1655
1627
|
|
|
1656
|
-
# ----- parallel_adapters/base -----
|
|
1657
1628
|
|
|
1658
1629
|
module SimpleCov
|
|
1659
1630
|
module ParallelAdapters
|
|
1660
|
-
# No-op defaults for a parallel-test-runner adapter: behave like a
|
|
1661
|
-
# single-process run. Real adapters subclass and override what they
|
|
1662
|
-
# need. The contract methods are class methods; adapters are never
|
|
1663
|
-
# instantiated.
|
|
1664
1631
|
class Base
|
|
1665
|
-
# Should this adapter be selected for the current process? The
|
|
1666
|
-
# first registered adapter whose `active?` returns truthy wins.
|
|
1667
1632
|
def self.active?: () -> boolish
|
|
1668
1633
|
|
|
1669
|
-
# Should THIS worker do the final-result work (wait for siblings,
|
|
1670
|
-
# merge resultsets, run threshold checks, format the report)?
|
|
1671
|
-
# Defaults to true for the single-process case.
|
|
1672
1634
|
def self.first_worker?: () -> bool
|
|
1673
1635
|
|
|
1674
|
-
# Optional: block until sibling workers have finished writing
|
|
1675
|
-
# their resultsets. The no-op default leaves synchronization to
|
|
1676
|
-
# SimpleCov's resultset polling fallback.
|
|
1677
1636
|
def self.wait_for_siblings: () -> void
|
|
1678
1637
|
|
|
1679
|
-
# Does `wait_for_siblings` block until every sibling process has
|
|
1680
|
-
# exited? When true, a settled resultset count below
|
|
1681
|
-
# `expected_worker_count` is accepted as final.
|
|
1682
1638
|
def self.native_wait?: () -> boolish
|
|
1683
1639
|
|
|
1684
|
-
# How many parallel workers participate in this run. Defaults to 1.
|
|
1685
1640
|
def self.expected_worker_count: () -> Integer
|
|
1686
1641
|
|
|
1687
|
-
# The user's explicit `SimpleCov.parallel_tests false` opt-out.
|
|
1688
1642
|
def self.forced_off?: () -> bool
|
|
1689
1643
|
|
|
1690
|
-
# Shared PARALLEL_TEST_GROUPS parsing; 1 for unset, empty,
|
|
1691
|
-
# non-numeric, or non-positive values.
|
|
1692
1644
|
def self.parallel_test_groups_count: () -> Integer
|
|
1693
1645
|
end
|
|
1694
1646
|
end
|
|
1695
1647
|
end
|
|
1696
1648
|
|
|
1697
|
-
# ----- parallel_adapters/generic -----
|
|
1698
1649
|
|
|
1699
1650
|
module SimpleCov
|
|
1700
1651
|
module ParallelAdapters
|
|
1701
|
-
# Catch-all adapter for runners that follow the `TEST_ENV_NUMBER` /
|
|
1702
|
-
# `PARALLEL_TEST_GROUPS` env-var convention without shipping a Ruby
|
|
1703
|
-
# API (parallel_rspec, knapsack-style splitters, custom CI sharding).
|
|
1704
|
-
# Activates when `TEST_ENV_NUMBER` is set, unless
|
|
1705
|
-
# `SimpleCov.parallel_tests false` opted out.
|
|
1706
1652
|
class GenericAdapter < Base
|
|
1707
1653
|
def self.active?: () -> bool
|
|
1708
1654
|
|
|
1709
|
-
# First worker is TEST_ENV_NUMBER "" (parallel_tests convention)
|
|
1710
|
-
# or "1" (runners that number from 1).
|
|
1711
1655
|
def self.first_worker?: () -> bool
|
|
1712
1656
|
|
|
1713
1657
|
def self.expected_worker_count: () -> Integer
|
|
@@ -1715,32 +1659,20 @@ module SimpleCov
|
|
|
1715
1659
|
end
|
|
1716
1660
|
end
|
|
1717
1661
|
|
|
1718
|
-
# ----- parallel_adapters/parallel_tests -----
|
|
1719
1662
|
|
|
1720
1663
|
module SimpleCov
|
|
1721
1664
|
module ParallelAdapters
|
|
1722
|
-
# Adapter for grosser/parallel_tests. Requires the full native
|
|
1723
|
-
# coordination contract (ParallelTests constant loaded,
|
|
1724
|
-
# TEST_ENV_NUMBER and PARALLEL_PID_FILE set); env-var-only setups
|
|
1725
|
-
# fall through to GenericAdapter.
|
|
1726
1665
|
class ParallelTestsAdapter < Base
|
|
1727
1666
|
def self.active?: () -> bool
|
|
1728
1667
|
|
|
1729
|
-
# Delegates to ParallelTests.first_process? (the first started
|
|
1730
|
-
# process does the final-result work; see issue #922).
|
|
1731
1668
|
def self.first_worker?: () -> bool
|
|
1732
1669
|
|
|
1733
|
-
# Uses ParallelTests.wait_for_other_processes_to_finish when the
|
|
1734
|
-
# pid-file contract is present.
|
|
1735
1670
|
def self.wait_for_siblings: () -> void
|
|
1736
1671
|
|
|
1737
1672
|
def self.native_wait?: () -> bool
|
|
1738
1673
|
|
|
1739
1674
|
def self.expected_worker_count: () -> Integer
|
|
1740
1675
|
|
|
1741
|
-
# Auto-requires parallel_tests when installed and the env vars it
|
|
1742
|
-
# sets are present; a missing gem is treated as "not using
|
|
1743
|
-
# parallel_tests" (see issue #1018).
|
|
1744
1676
|
def self.ensure_loaded: () -> void
|
|
1745
1677
|
|
|
1746
1678
|
def self.env_suggests_parallel_tests?: () -> bool
|
|
@@ -1750,28 +1682,29 @@ module SimpleCov
|
|
|
1750
1682
|
end
|
|
1751
1683
|
end
|
|
1752
1684
|
|
|
1753
|
-
# ----- deprecation -----
|
|
1754
1685
|
|
|
1755
1686
|
module SimpleCov
|
|
1756
|
-
# Emits legacy-API deprecation warnings, deduplicated by the source
|
|
1757
|
-
# location that triggered them (see issue #1204).
|
|
1758
1687
|
module Deprecation
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1688
|
+
MODES: Array[Symbol]
|
|
1689
|
+
|
|
1690
|
+
def self?.mode: () -> Symbol
|
|
1691
|
+
|
|
1692
|
+
def self?.mode=: (Symbol mode) -> Symbol
|
|
1693
|
+
|
|
1762
1694
|
def self?.warn: (String message, ?location: String?) -> void
|
|
1763
1695
|
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
# singleton sides because `module_function` bodies type-check as
|
|
1767
|
-
# instance methods while runtime state lives on the module itself.
|
|
1696
|
+
def self?.caller_location: () -> String?
|
|
1697
|
+
|
|
1768
1698
|
@emitted: Set[String]?
|
|
1769
1699
|
|
|
1770
1700
|
self.@emitted: Set[String]?
|
|
1771
1701
|
|
|
1702
|
+
@mode: Symbol?
|
|
1703
|
+
|
|
1704
|
+
self.@mode: Symbol?
|
|
1705
|
+
|
|
1772
1706
|
def self?.emitted: () -> Set[String]
|
|
1773
1707
|
|
|
1774
|
-
# @api private — reset emitted state between tests.
|
|
1775
1708
|
def self?.reset!: () -> void
|
|
1776
1709
|
end
|
|
1777
1710
|
end
|