polyrun 3.2.0-java
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 +7 -0
- data/CHANGELOG.md +234 -0
- data/CODE_OF_CONDUCT.md +26 -0
- data/CONTRIBUTING.md +23 -0
- data/LICENSE +21 -0
- data/README.md +251 -0
- data/SECURITY.md +25 -0
- data/bin/polyrun +6 -0
- data/docs/QUALITY.md +82 -0
- data/docs/QUALITY_CONFIGURATION.md +95 -0
- data/docs/SETUP_PROFILE.md +139 -0
- data/lib/polyrun/benchmark/pressure/cooker.rb +191 -0
- data/lib/polyrun/benchmark/pressure/process_sample.rb +127 -0
- data/lib/polyrun/benchmark/pressure.rb +144 -0
- data/lib/polyrun/benchmark/profile.rb +191 -0
- data/lib/polyrun/benchmark/report.rb +87 -0
- data/lib/polyrun/cli/benchmark_commands.rb +66 -0
- data/lib/polyrun/cli/ci_shard_hooks.rb +129 -0
- data/lib/polyrun/cli/ci_shard_run_command.rb +177 -0
- data/lib/polyrun/cli/ci_shard_run_parse.rb +68 -0
- data/lib/polyrun/cli/config_command.rb +42 -0
- data/lib/polyrun/cli/coverage_commands.rb +150 -0
- data/lib/polyrun/cli/coverage_merge_io.rb +150 -0
- data/lib/polyrun/cli/database_commands.rb +163 -0
- data/lib/polyrun/cli/default_run.rb +144 -0
- data/lib/polyrun/cli/doctor_command.rb +94 -0
- data/lib/polyrun/cli/env_commands.rb +43 -0
- data/lib/polyrun/cli/failure_commands.rb +99 -0
- data/lib/polyrun/cli/graph_command.rb +68 -0
- data/lib/polyrun/cli/help.rb +83 -0
- data/lib/polyrun/cli/helpers.rb +162 -0
- data/lib/polyrun/cli/hooks_command.rb +97 -0
- data/lib/polyrun/cli/init_command.rb +108 -0
- data/lib/polyrun/cli/mutation_command.rb +67 -0
- data/lib/polyrun/cli/partition_diagnostics.rb +22 -0
- data/lib/polyrun/cli/plan_command.rb +184 -0
- data/lib/polyrun/cli/prepare_command.rb +70 -0
- data/lib/polyrun/cli/prepare_recipe.rb +82 -0
- data/lib/polyrun/cli/quality_commands.rb +65 -0
- data/lib/polyrun/cli/queue_command.rb +161 -0
- data/lib/polyrun/cli/quick_command.rb +13 -0
- data/lib/polyrun/cli/report_commands.rb +108 -0
- data/lib/polyrun/cli/run_queue_command.rb +127 -0
- data/lib/polyrun/cli/run_shards_command.rb +164 -0
- data/lib/polyrun/cli/run_shards_parallel_children.rb +112 -0
- data/lib/polyrun/cli/run_shards_parallel_wait.rb +252 -0
- data/lib/polyrun/cli/run_shards_plan_boot_phases.rb +207 -0
- data/lib/polyrun/cli/run_shards_plan_options.rb +74 -0
- data/lib/polyrun/cli/run_shards_planning.rb +123 -0
- data/lib/polyrun/cli/run_shards_run.rb +171 -0
- data/lib/polyrun/cli/run_shards_worker_interrupt.rb +101 -0
- data/lib/polyrun/cli/skip_env.rb +34 -0
- data/lib/polyrun/cli/spec_quality_commands.rb +149 -0
- data/lib/polyrun/cli/start_bootstrap.rb +126 -0
- data/lib/polyrun/cli/timing_command.rb +31 -0
- data/lib/polyrun/cli/tool_options.rb +48 -0
- data/lib/polyrun/cli/validate_command.rb +26 -0
- data/lib/polyrun/cli.rb +272 -0
- data/lib/polyrun/config/dotted_path.rb +21 -0
- data/lib/polyrun/config/effective.rb +82 -0
- data/lib/polyrun/config/resolver.rb +114 -0
- data/lib/polyrun/config/schema.rb +39 -0
- data/lib/polyrun/config/suite.rb +109 -0
- data/lib/polyrun/config/tool_defaults.rb +42 -0
- data/lib/polyrun/config/tool_validation.rb +79 -0
- data/lib/polyrun/config/tools.rb +120 -0
- data/lib/polyrun/config.rb +97 -0
- data/lib/polyrun/coverage/cobertura_zero_lines.rb +32 -0
- data/lib/polyrun/coverage/collector.rb +169 -0
- data/lib/polyrun/coverage/collector_blob.rb +53 -0
- data/lib/polyrun/coverage/collector_finish.rb +98 -0
- data/lib/polyrun/coverage/collector_fragment_meta.rb +57 -0
- data/lib/polyrun/coverage/config_resolve.rb +131 -0
- data/lib/polyrun/coverage/example_diff.rb +184 -0
- data/lib/polyrun/coverage/example_diff_snapshot.rb +44 -0
- data/lib/polyrun/coverage/example_diff_track_filter.rb +51 -0
- data/lib/polyrun/coverage/file_stats_report.rb +36 -0
- data/lib/polyrun/coverage/filter.rb +22 -0
- data/lib/polyrun/coverage/formatter.rb +137 -0
- data/lib/polyrun/coverage/merge/formatters.rb +188 -0
- data/lib/polyrun/coverage/merge/formatters_html.rb +221 -0
- data/lib/polyrun/coverage/merge/html/_file_list.html.erb +21 -0
- data/lib/polyrun/coverage/merge/html/_file_section.html.erb +26 -0
- data/lib/polyrun/coverage/merge/html/_groups_table.html.erb +18 -0
- data/lib/polyrun/coverage/merge/html/_overview.html.erb +47 -0
- data/lib/polyrun/coverage/merge/html/report.css +147 -0
- data/lib/polyrun/coverage/merge/html/report.js +48 -0
- data/lib/polyrun/coverage/merge/html/template.html.erb +30 -0
- data/lib/polyrun/coverage/merge.rb +160 -0
- data/lib/polyrun/coverage/merge_fragment_meta.rb +58 -0
- data/lib/polyrun/coverage/merge_merge_two.rb +168 -0
- data/lib/polyrun/coverage/merge_native.rb +39 -0
- data/lib/polyrun/coverage/rails.rb +126 -0
- data/lib/polyrun/coverage/reporting.rb +41 -0
- data/lib/polyrun/coverage/result.rb +18 -0
- data/lib/polyrun/coverage/track_files.rb +150 -0
- data/lib/polyrun/data/cached_fixtures.rb +122 -0
- data/lib/polyrun/data/factory_counts.rb +48 -0
- data/lib/polyrun/data/factory_instrumentation.rb +50 -0
- data/lib/polyrun/data/fixtures.rb +68 -0
- data/lib/polyrun/data/parallel_provisioning.rb +93 -0
- data/lib/polyrun/data/snapshot.rb +84 -0
- data/lib/polyrun/database/clone_shards.rb +106 -0
- data/lib/polyrun/database/provision.rb +83 -0
- data/lib/polyrun/database/shard.rb +64 -0
- data/lib/polyrun/database/url_builder/connection/infer.rb +53 -0
- data/lib/polyrun/database/url_builder/connection/url_builders.rb +43 -0
- data/lib/polyrun/database/url_builder/connection.rb +191 -0
- data/lib/polyrun/database/url_builder/template_prepare.rb +21 -0
- data/lib/polyrun/database/url_builder.rb +188 -0
- data/lib/polyrun/debug.rb +81 -0
- data/lib/polyrun/env/ci.rb +65 -0
- data/lib/polyrun/error.rb +3 -0
- data/lib/polyrun/export/csv.rb +25 -0
- data/lib/polyrun/export/markdown.rb +47 -0
- data/lib/polyrun/graph/client.rb +64 -0
- data/lib/polyrun/graph/error.rb +13 -0
- data/lib/polyrun/graph/index.rb +75 -0
- data/lib/polyrun/graph/inspect.rb +58 -0
- data/lib/polyrun/graph/plan.rb +134 -0
- data/lib/polyrun/graph/planner.rb +117 -0
- data/lib/polyrun/graph/syntax.rb +114 -0
- data/lib/polyrun/graph/transaction.rb +81 -0
- data/lib/polyrun/graph/worker.rb +55 -0
- data/lib/polyrun/graph/workspace.rb +117 -0
- data/lib/polyrun/hooks/dsl.rb +128 -0
- data/lib/polyrun/hooks/shell_runner.rb +33 -0
- data/lib/polyrun/hooks/worker_runner.rb +27 -0
- data/lib/polyrun/hooks/worker_shell.rb +50 -0
- data/lib/polyrun/hooks.rb +190 -0
- data/lib/polyrun/log.rb +86 -0
- data/lib/polyrun/minitest_support.rb +60 -0
- data/lib/polyrun/mutation/candidates.rb +91 -0
- data/lib/polyrun/mutation/operators.rb +51 -0
- data/lib/polyrun/mutation/runner.rb +133 -0
- data/lib/polyrun/mutation/subjects.rb +88 -0
- data/lib/polyrun/partition/constraints.rb +80 -0
- data/lib/polyrun/partition/hrw.rb +70 -0
- data/lib/polyrun/partition/min_heap.rb +64 -0
- data/lib/polyrun/partition/paths.rb +175 -0
- data/lib/polyrun/partition/paths_build.rb +141 -0
- data/lib/polyrun/partition/plan.rb +250 -0
- data/lib/polyrun/partition/plan_lpt.rb +91 -0
- data/lib/polyrun/partition/plan_sharding.rb +56 -0
- data/lib/polyrun/partition/reports.rb +139 -0
- data/lib/polyrun/partition/stable_shuffle.rb +18 -0
- data/lib/polyrun/partition/suite.rb +120 -0
- data/lib/polyrun/partition/timing_diagnostics.rb +138 -0
- data/lib/polyrun/partition/timing_keys.rb +86 -0
- data/lib/polyrun/prepare/artifacts.rb +40 -0
- data/lib/polyrun/prepare/assets.rb +64 -0
- data/lib/polyrun/process_stdio.rb +96 -0
- data/lib/polyrun/quality/command.rb +84 -0
- data/lib/polyrun/quality/measure.rb +38 -0
- data/lib/polyrun/quality/observe.rb +53 -0
- data/lib/polyrun/quality/observe_hook.rb +103 -0
- data/lib/polyrun/quality/sandbox.rb +70 -0
- data/lib/polyrun/queue/duration.rb +30 -0
- data/lib/polyrun/queue/file_store.rb +413 -0
- data/lib/polyrun/queue/file_store_intent.rb +188 -0
- data/lib/polyrun/queue/file_store_pending.rb +48 -0
- data/lib/polyrun/queue/worker_loop.rb +73 -0
- data/lib/polyrun/quick/assertions.rb +32 -0
- data/lib/polyrun/quick/config.rb +56 -0
- data/lib/polyrun/quick/errors.rb +6 -0
- data/lib/polyrun/quick/example_group.rb +111 -0
- data/lib/polyrun/quick/example_runner.rb +129 -0
- data/lib/polyrun/quick/matchers.rb +159 -0
- data/lib/polyrun/quick/matchers_predicates.rb +122 -0
- data/lib/polyrun/quick/reporter.rb +76 -0
- data/lib/polyrun/quick/runner.rb +224 -0
- data/lib/polyrun/quick.rb +1 -0
- data/lib/polyrun/railtie.rb +7 -0
- data/lib/polyrun/reporting/failure_merge.rb +171 -0
- data/lib/polyrun/reporting/junit.rb +126 -0
- data/lib/polyrun/reporting/junit_emit.rb +58 -0
- data/lib/polyrun/reporting/junit_report.rb +87 -0
- data/lib/polyrun/reporting/rspec_failure_fragment_formatter.rb +95 -0
- data/lib/polyrun/reporting/rspec_junit.rb +39 -0
- data/lib/polyrun/rspec_support/active_record_timeout_recovery.rb +51 -0
- data/lib/polyrun/rspec_support/example_debug.rb +167 -0
- data/lib/polyrun/rspec_support/example_debug_instrumentation.rb +73 -0
- data/lib/polyrun/rspec_support/sharded_formatter_compat.rb +57 -0
- data/lib/polyrun/rspec_support.rb +110 -0
- data/lib/polyrun/spec_quality/config.rb +139 -0
- data/lib/polyrun/spec_quality/fragment.rb +39 -0
- data/lib/polyrun/spec_quality/merge.rb +78 -0
- data/lib/polyrun/spec_quality/minitest_hook.rb +42 -0
- data/lib/polyrun/spec_quality/plan_loader.rb +47 -0
- data/lib/polyrun/spec_quality/profile.rb +102 -0
- data/lib/polyrun/spec_quality/report.rb +363 -0
- data/lib/polyrun/spec_quality/rspec_hook.rb +55 -0
- data/lib/polyrun/spec_quality/sql_counter.rb +34 -0
- data/lib/polyrun/spec_quality.rb +212 -0
- data/lib/polyrun/sus_support.rb +55 -0
- data/lib/polyrun/templates/POLYRUN.md +51 -0
- data/lib/polyrun/templates/ci_matrix.polyrun.yml +22 -0
- data/lib/polyrun/templates/minimal_gem.polyrun.yml +13 -0
- data/lib/polyrun/templates/polyrun_hooks_spec_quality.rb +12 -0
- data/lib/polyrun/templates/polyrun_spec_quality.yml +20 -0
- data/lib/polyrun/templates/rails_prepare.polyrun.yml +51 -0
- data/lib/polyrun/templates/rails_prepare_task.rake +16 -0
- data/lib/polyrun/timing/merge.rb +36 -0
- data/lib/polyrun/timing/rspec_example_formatter.rb +60 -0
- data/lib/polyrun/timing/stats.rb +76 -0
- data/lib/polyrun/timing/summary.rb +78 -0
- data/lib/polyrun/timing/variance_report.rb +51 -0
- data/lib/polyrun/version.rb +3 -0
- data/lib/polyrun/worker_output.rb +181 -0
- data/lib/polyrun/worker_output_forwarders.rb +94 -0
- data/lib/polyrun/worker_ping.rb +77 -0
- data/lib/polyrun.rb +59 -0
- data/polyrun.gemspec +49 -0
- data/sig/polyrun/cli.rbs +6 -0
- data/sig/polyrun/config.rbs +20 -0
- data/sig/polyrun/debug.rbs +12 -0
- data/sig/polyrun/log.rbs +12 -0
- data/sig/polyrun/minitest_support.rbs +7 -0
- data/sig/polyrun/quick.rbs +19 -0
- data/sig/polyrun/rspec_support.rbs +21 -0
- data/sig/polyrun/sus_support.rbs +7 -0
- data/sig/polyrun/worker_output.rbs +11 -0
- data/sig/polyrun/worker_ping.rbs +10 -0
- data/sig/polyrun.rbs +11 -0
- metadata +463 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
require_relative "example_diff_track_filter"
|
|
2
|
+
require_relative "example_diff_snapshot"
|
|
3
|
+
|
|
4
|
+
module Polyrun
|
|
5
|
+
module Coverage
|
|
6
|
+
# Per-example line hit deltas from stdlib +Coverage.peek_result+ snapshots.
|
|
7
|
+
module ExampleDiff
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
# @return [Hash{String=>Hash}] path => sparse line snapshot
|
|
11
|
+
def peek_blob(root: nil, track_under: nil, ignore_paths: nil)
|
|
12
|
+
return {} unless coverage_active?
|
|
13
|
+
|
|
14
|
+
snapshot_peek(
|
|
15
|
+
::Coverage.peek_result,
|
|
16
|
+
root: root,
|
|
17
|
+
track_under: track_under,
|
|
18
|
+
ignore_paths: ignore_paths
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Frozen snapshot for storage between peeks (stdlib mutates line arrays in place).
|
|
23
|
+
def snapshot_peek(raw, root: nil, track_under: nil, ignore_paths: nil)
|
|
24
|
+
return {} if raw.nil? || raw.empty?
|
|
25
|
+
|
|
26
|
+
filter = track_filter_for(root: root, track_under: track_under, ignore_paths: ignore_paths)
|
|
27
|
+
out = {}
|
|
28
|
+
raw.each do |path, coverage_entry|
|
|
29
|
+
next if filter && !filter.include_path?(path.to_s)
|
|
30
|
+
|
|
31
|
+
lines = line_array(coverage_entry)
|
|
32
|
+
next if lines.empty?
|
|
33
|
+
|
|
34
|
+
out[path.to_s] = Snapshot.sparse_snapshot_lines(lines)
|
|
35
|
+
end
|
|
36
|
+
out
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# +after_source+ may be a normalized blob or a raw +Coverage.peek_result+ hash.
|
|
40
|
+
def diff(before_blob, after_source, root: nil, track_under: nil, ignore_paths: nil)
|
|
41
|
+
filter = track_filter_for(root: root, track_under: track_under, ignore_paths: ignore_paths)
|
|
42
|
+
if raw_peek_result?(after_source)
|
|
43
|
+
diff_against_peek(before_blob, after_source, filter: filter)
|
|
44
|
+
else
|
|
45
|
+
diff_blobs(before_blob, after_source, filter: filter)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def coverage_active?
|
|
50
|
+
defined?(::Coverage) && ::Coverage.respond_to?(:running?) && ::Coverage.running?
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def diff_blobs(before_blob, after_blob, filter: nil)
|
|
54
|
+
before_blob ||= {}
|
|
55
|
+
after_blob ||= {}
|
|
56
|
+
paths = collect_diff_paths(before_blob, after_blob, filter: filter)
|
|
57
|
+
diff_paths(paths, before_blob, after_blob, raw_after: false)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def diff_against_peek(before_blob, after_raw, filter: nil)
|
|
61
|
+
before_blob ||= {}
|
|
62
|
+
after_raw ||= {}
|
|
63
|
+
paths = collect_diff_paths(before_blob, after_raw, filter: filter)
|
|
64
|
+
diff_paths(paths, before_blob, after_raw, raw_after: true)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def filter_lines(lines, root:, track_under:, ignore_paths: [])
|
|
68
|
+
filter = TrackFilter.new(root: root, track_under: track_under, ignore_paths: ignore_paths)
|
|
69
|
+
lines.select { |path, _line, _delta| filter.include_path?(path) }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def apply_track_under(delta, root:, track_under:, ignore_paths: [])
|
|
73
|
+
filtered = filter_lines(delta[:lines] || [], root: root, track_under: track_under, ignore_paths: ignore_paths)
|
|
74
|
+
unique = filtered.size
|
|
75
|
+
churn = filtered.sum { |(_path, _line, hit_delta)| hit_delta }
|
|
76
|
+
max_churn = filtered.map { |(_path, _line, hit_delta)| hit_delta }.max || 0
|
|
77
|
+
{
|
|
78
|
+
unique_lines: unique,
|
|
79
|
+
line_churn: churn,
|
|
80
|
+
max_line_churn: max_churn,
|
|
81
|
+
lines: filtered
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def line_array(entry)
|
|
86
|
+
return entry if entry.is_a?(Array)
|
|
87
|
+
return [] unless entry.is_a?(Hash)
|
|
88
|
+
return [] if entry["sparse"]
|
|
89
|
+
|
|
90
|
+
arr = entry["lines"] || entry[:lines]
|
|
91
|
+
arr.is_a?(Array) ? arr : []
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def raw_peek_result?(source)
|
|
95
|
+
return false unless source.is_a?(Hash)
|
|
96
|
+
return false if source.empty?
|
|
97
|
+
|
|
98
|
+
entry = source.values.first
|
|
99
|
+
entry.is_a?(Hash) && (entry.key?(:lines) || entry.key?(:branches))
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def diff_paths(paths, before_blob, after_blob, raw_after:)
|
|
103
|
+
line_entries = []
|
|
104
|
+
unique = 0
|
|
105
|
+
churn = 0
|
|
106
|
+
max_churn = 0
|
|
107
|
+
|
|
108
|
+
paths.each do |path|
|
|
109
|
+
before_entry = before_blob[path]
|
|
110
|
+
after_lines =
|
|
111
|
+
if raw_after
|
|
112
|
+
lines_from_peek_entry(path, after_blob)
|
|
113
|
+
else
|
|
114
|
+
line_array(after_blob[path])
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
accumulate_line_delta(before_entry, after_lines) do |delta, line_no|
|
|
118
|
+
unique += 1
|
|
119
|
+
churn += delta
|
|
120
|
+
max_churn = delta if delta > max_churn
|
|
121
|
+
line_entries << [path, line_no, delta]
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
{
|
|
126
|
+
unique_lines: unique,
|
|
127
|
+
line_churn: churn,
|
|
128
|
+
max_line_churn: max_churn,
|
|
129
|
+
lines: line_entries
|
|
130
|
+
}
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def collect_diff_paths(before_blob, after_blob, filter: nil)
|
|
134
|
+
keys = {}
|
|
135
|
+
before_blob.each_key { |path| keys[path.to_s] = true }
|
|
136
|
+
after_blob.each_key { |path| keys[path.to_s] = true }
|
|
137
|
+
list = keys.keys
|
|
138
|
+
return list unless filter
|
|
139
|
+
|
|
140
|
+
list.select { |path| filter.include_path?(path) }
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def accumulate_line_delta(before_entry, after_lines)
|
|
144
|
+
before_hits = Snapshot.hits_map(before_entry)
|
|
145
|
+
before_max = before_hits.empty? ? 0 : before_hits.keys.max + 1
|
|
146
|
+
max_len = [after_lines.size, before_max].max
|
|
147
|
+
|
|
148
|
+
(0...max_len).each do |index|
|
|
149
|
+
before_hit = before_hits[index]
|
|
150
|
+
after_hit = after_lines[index]
|
|
151
|
+
next if after_hit.nil? && before_hit.nil?
|
|
152
|
+
|
|
153
|
+
delta = integer_hit(after_hit) - integer_hit(before_hit)
|
|
154
|
+
next unless delta.positive?
|
|
155
|
+
|
|
156
|
+
yield(delta, index + 1)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def lines_from_peek_entry(path, after_raw)
|
|
161
|
+
line_array(after_raw[path])
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def track_filter_for(root:, track_under:, ignore_paths:)
|
|
165
|
+
return nil if track_under.nil? && ignore_paths.nil?
|
|
166
|
+
|
|
167
|
+
TrackFilter.new(
|
|
168
|
+
root: root || Dir.pwd,
|
|
169
|
+
track_under: track_under,
|
|
170
|
+
ignore_paths: ignore_paths || []
|
|
171
|
+
)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def integer_hit(value)
|
|
175
|
+
return 0 if value.nil?
|
|
176
|
+
return 0 if value == "ignored"
|
|
177
|
+
|
|
178
|
+
value.is_a?(Integer) ? value : value.to_i
|
|
179
|
+
end
|
|
180
|
+
private_class_method :diff_paths, :collect_diff_paths, :accumulate_line_delta,
|
|
181
|
+
:lines_from_peek_entry, :track_filter_for, :integer_hit, :raw_peek_result?
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Polyrun
|
|
2
|
+
module Coverage
|
|
3
|
+
module ExampleDiff
|
|
4
|
+
# Sparse line-hit snapshots for per-example diff storage.
|
|
5
|
+
module Snapshot
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
def sparse_snapshot_lines(lines)
|
|
9
|
+
{"sparse" => true, "hits" => dense_hits_map(lines)}
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def hits_map(entry)
|
|
13
|
+
return {} if entry.nil?
|
|
14
|
+
|
|
15
|
+
if entry.is_a?(Hash) && entry["sparse"]
|
|
16
|
+
entry["hits"] || {}
|
|
17
|
+
else
|
|
18
|
+
dense_hits_map(ExampleDiff.line_array(entry))
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def dense_hits_map(lines)
|
|
23
|
+
hits = {}
|
|
24
|
+
lines.each_with_index do |value, index|
|
|
25
|
+
stored = snapshot_line_value(value)
|
|
26
|
+
hits[index] = stored unless stored.nil?
|
|
27
|
+
end
|
|
28
|
+
hits
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def snapshot_line_value(value)
|
|
32
|
+
case value
|
|
33
|
+
when nil then nil
|
|
34
|
+
when "ignored" then "ignored"
|
|
35
|
+
when Integer then value
|
|
36
|
+
else
|
|
37
|
+
parsed = Integer(value, exception: false)
|
|
38
|
+
parsed.nil? ? value : parsed
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Polyrun
|
|
2
|
+
module Coverage
|
|
3
|
+
module ExampleDiff
|
|
4
|
+
# Path inclusion for scoped snapshots and track-aware diffs.
|
|
5
|
+
class TrackFilter
|
|
6
|
+
def initialize(root:, track_under: nil, ignore_paths: [])
|
|
7
|
+
@root = root ? File.expand_path(root) : nil
|
|
8
|
+
@track_under = Array(track_under).map(&:to_s).reject(&:empty?)
|
|
9
|
+
@ignore = Array(ignore_paths).map(&:to_s).reject(&:empty?)
|
|
10
|
+
@prefixes =
|
|
11
|
+
if @root && !@track_under.empty?
|
|
12
|
+
@track_under.map { |directory| File.join(@root, directory) }
|
|
13
|
+
else
|
|
14
|
+
[]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def include_path?(path)
|
|
19
|
+
absolute = absolute_path(path)
|
|
20
|
+
return false if ignored?(absolute)
|
|
21
|
+
|
|
22
|
+
return true if @prefixes.empty?
|
|
23
|
+
|
|
24
|
+
@prefixes.any? { |prefix| absolute == prefix || absolute.start_with?(prefix + "/") }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def absolute_path(path)
|
|
30
|
+
if @root
|
|
31
|
+
File.expand_path(path.to_s, @root)
|
|
32
|
+
else
|
|
33
|
+
File.expand_path(path.to_s)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def ignored?(absolute)
|
|
38
|
+
@ignore.any? { |pattern| path_matches_ignore?(absolute, pattern) }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def path_matches_ignore?(path, pattern)
|
|
42
|
+
return path.include?(pattern) if !pattern.start_with?("/")
|
|
43
|
+
|
|
44
|
+
path.match?(Regexp.new(pattern))
|
|
45
|
+
rescue RegexpError
|
|
46
|
+
path.include?(pattern)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require_relative "../export/csv"
|
|
2
|
+
require_relative "../export/markdown"
|
|
3
|
+
|
|
4
|
+
module Polyrun
|
|
5
|
+
module Coverage
|
|
6
|
+
# Per-file line coverage tables for CSV and Markdown exports.
|
|
7
|
+
module FileStatsReport
|
|
8
|
+
HEADERS = %w[path line_percent lines_covered lines_relevant].freeze
|
|
9
|
+
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def file_rows(coverage_blob)
|
|
13
|
+
coverage_blob.map do |path, file_entry|
|
|
14
|
+
line_percent, lines_relevant, lines_covered = Merge.file_line_stats(file_entry)
|
|
15
|
+
[path, format("%.2f", line_percent), lines_covered, lines_relevant]
|
|
16
|
+
end.sort_by { |row| row[1].to_f }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def emit_csv(coverage_blob)
|
|
20
|
+
Export::Csv.generate(HEADERS, file_rows(coverage_blob))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def emit_markdown(coverage_blob, title: "Polyrun coverage report")
|
|
24
|
+
summary = Merge.console_summary(coverage_blob)
|
|
25
|
+
summary_line = Merge.format_console_summary(summary).strip
|
|
26
|
+
Export::Markdown.document(
|
|
27
|
+
title,
|
|
28
|
+
[
|
|
29
|
+
{body: summary_line},
|
|
30
|
+
{heading: "Per-file coverage", headers: HEADERS, rows: file_rows(coverage_blob)}
|
|
31
|
+
]
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Polyrun
|
|
2
|
+
module Coverage
|
|
3
|
+
# Drop paths from a coverage blob when the path matches any reject pattern (substring).
|
|
4
|
+
# Mirrors SimpleCov +add_filter+ style paths (e.g. "/lib/generators/").
|
|
5
|
+
module Filter
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
def reject_matching_paths(blob, patterns)
|
|
9
|
+
return blob unless blob.is_a?(Hash)
|
|
10
|
+
|
|
11
|
+
pats = Array(patterns).map(&:to_s).reject(&:empty?)
|
|
12
|
+
return blob if pats.empty?
|
|
13
|
+
|
|
14
|
+
blob.each_with_object({}) do |(path, entry), acc|
|
|
15
|
+
next if pats.any? { |p| path.to_s.include?(p) }
|
|
16
|
+
|
|
17
|
+
acc[path] = entry
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
require "fileutils"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
require_relative "merge"
|
|
5
|
+
require_relative "result"
|
|
6
|
+
require_relative "file_stats_report"
|
|
7
|
+
|
|
8
|
+
module Polyrun
|
|
9
|
+
module Coverage
|
|
10
|
+
# Formatters matching SimpleCov: +#format(result)+ receives a {Result} (and optional +output_dir+/+basename+).
|
|
11
|
+
# Use {MultiFormatter} to run several outputs; {Formatter.multi} builds that from symbols.
|
|
12
|
+
module Formatter
|
|
13
|
+
module_function
|
|
14
|
+
|
|
15
|
+
def multi(*names, output_dir:, basename: "polyrun-coverage")
|
|
16
|
+
names = names.flatten.compact
|
|
17
|
+
raise ArgumentError, "formatter.multi: need at least one format" if names.empty?
|
|
18
|
+
|
|
19
|
+
formatters = names.map { |n| builtin(n).new(output_dir: output_dir, basename: basename) }
|
|
20
|
+
MultiFormatter.new(formatters)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def builtin(name)
|
|
24
|
+
case name.to_sym
|
|
25
|
+
when :json then JsonFormatter
|
|
26
|
+
when :lcov then LcovFormatter
|
|
27
|
+
when :cobertura then CoberturaFormatter
|
|
28
|
+
when :console then ConsoleFormatter
|
|
29
|
+
when :html then HtmlFormatter
|
|
30
|
+
when :csv then CsvFormatter
|
|
31
|
+
when :markdown then MarkdownFormatter
|
|
32
|
+
else
|
|
33
|
+
raise ArgumentError,
|
|
34
|
+
"unknown coverage format: #{name.inspect} (expected :json, :lcov, :cobertura, :console, :html, :csv, :markdown)"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Base: subclasses implement +#write_files(result, output_dir, basename)+ returning +{ key => path }+.
|
|
39
|
+
class Base
|
|
40
|
+
def initialize(output_dir: nil, basename: "polyrun-coverage")
|
|
41
|
+
@default_output_dir = output_dir
|
|
42
|
+
@default_basename = basename
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def format(result, output_dir: @default_output_dir, basename: @default_basename)
|
|
46
|
+
od = output_dir
|
|
47
|
+
raise ArgumentError, "#{self.class}: output_dir is required" if od.nil? || od.to_s.empty?
|
|
48
|
+
|
|
49
|
+
bn = basename || "polyrun-coverage"
|
|
50
|
+
FileUtils.mkdir_p(od)
|
|
51
|
+
write_files(result, od.to_s, bn.to_s)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def write_files(_result, _output_dir, _basename)
|
|
55
|
+
raise NotImplementedError
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Runs each formatter in order; merges returned path hashes (later keys win on duplicate).
|
|
60
|
+
class MultiFormatter
|
|
61
|
+
def initialize(formatters)
|
|
62
|
+
@formatters = Array(formatters)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
attr_reader :formatters
|
|
66
|
+
|
|
67
|
+
def format(result, **kwargs)
|
|
68
|
+
@formatters.each_with_object({}) do |f, acc|
|
|
69
|
+
acc.merge!(f.format(result, **kwargs))
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class JsonFormatter < Base
|
|
75
|
+
def write_files(result, output_dir, basename)
|
|
76
|
+
path = File.join(output_dir, "#{basename}.json")
|
|
77
|
+
payload = Merge.to_simplecov_json(result.coverage_blob, meta: result.meta, groups: result.groups)
|
|
78
|
+
File.write(path, JSON.generate(payload))
|
|
79
|
+
{json: path}
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
class LcovFormatter < Base
|
|
84
|
+
def write_files(result, output_dir, basename)
|
|
85
|
+
path = File.join(output_dir, "#{basename}.lcov")
|
|
86
|
+
File.write(path, Merge.emit_lcov(result.coverage_blob))
|
|
87
|
+
{lcov: path}
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class CoberturaFormatter < Base
|
|
92
|
+
def write_files(result, output_dir, basename)
|
|
93
|
+
path = File.join(output_dir, "#{basename}.xml")
|
|
94
|
+
root = result.meta && (result.meta["polyrun_coverage_root"] || result.meta[:polyrun_coverage_root])
|
|
95
|
+
File.write(path, Merge.emit_cobertura(result.coverage_blob, root: root))
|
|
96
|
+
{cobertura: path}
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class ConsoleFormatter < Base
|
|
101
|
+
def write_files(result, output_dir, basename)
|
|
102
|
+
path = File.join(output_dir, "#{basename}-summary.txt")
|
|
103
|
+
summary = Merge.console_summary(result.coverage_blob)
|
|
104
|
+
File.write(path, Merge.format_console_summary(summary))
|
|
105
|
+
{console: path}
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class HtmlFormatter < Base
|
|
110
|
+
def write_files(result, output_dir, basename)
|
|
111
|
+
path = File.join(output_dir, "#{basename}.html")
|
|
112
|
+
title = (result.meta && result.meta["title"]) || (result.meta && result.meta[:title]) || "Polyrun coverage"
|
|
113
|
+
root = result.meta && (result.meta["polyrun_coverage_root"] || result.meta[:polyrun_coverage_root])
|
|
114
|
+
File.write(path, Merge.emit_html(result.coverage_blob, title: title, root: root, groups: result.groups))
|
|
115
|
+
{html: path}
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
class CsvFormatter < Base
|
|
120
|
+
def write_files(result, output_dir, basename)
|
|
121
|
+
path = File.join(output_dir, "#{basename}.csv")
|
|
122
|
+
File.write(path, FileStatsReport.emit_csv(result.coverage_blob))
|
|
123
|
+
{csv: path}
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
class MarkdownFormatter < Base
|
|
128
|
+
def write_files(result, output_dir, basename)
|
|
129
|
+
path = File.join(output_dir, "#{basename}.md")
|
|
130
|
+
title = (result.meta && result.meta["title"]) || (result.meta && result.meta[:title]) || "Polyrun coverage report"
|
|
131
|
+
File.write(path, FileStatsReport.emit_markdown(result.coverage_blob, title: title))
|
|
132
|
+
{markdown: path}
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
require "cgi"
|
|
2
|
+
require "pathname"
|
|
3
|
+
|
|
4
|
+
module Polyrun
|
|
5
|
+
module Coverage
|
|
6
|
+
module Merge
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def to_simplecov_json(coverage_blob, meta: {}, groups: nil, strip_internal_meta: true)
|
|
10
|
+
m = meta.is_a?(Hash) ? meta : {}
|
|
11
|
+
meta_out = {}
|
|
12
|
+
m.each { |k, v| meta_out[k.to_s] = v }
|
|
13
|
+
if strip_internal_meta
|
|
14
|
+
INTERNAL_META_KEYS.each { |k| meta_out.delete(k) }
|
|
15
|
+
end
|
|
16
|
+
g =
|
|
17
|
+
if groups.nil?
|
|
18
|
+
{}
|
|
19
|
+
else
|
|
20
|
+
stringify_keys_deep(groups)
|
|
21
|
+
end
|
|
22
|
+
{
|
|
23
|
+
"meta" => meta_out,
|
|
24
|
+
"coverage" => stringify_keys_deep(coverage_blob),
|
|
25
|
+
"groups" => g
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def stringify_keys_deep(obj)
|
|
30
|
+
case obj
|
|
31
|
+
when Hash
|
|
32
|
+
obj.each_with_object({}) { |(k, v), h| h[k.to_s] = stringify_keys_deep(v) }
|
|
33
|
+
when Array
|
|
34
|
+
obj.map { |e| stringify_keys_deep(e) }
|
|
35
|
+
else
|
|
36
|
+
obj
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def emit_lcov(coverage_blob)
|
|
41
|
+
lines = []
|
|
42
|
+
coverage_blob.each do |path, file|
|
|
43
|
+
phys = path.to_s
|
|
44
|
+
lines << "TN:polyrun"
|
|
45
|
+
lines << "SF:#{phys}"
|
|
46
|
+
line_arr = line_array_from_file_entry(file)
|
|
47
|
+
next unless line_arr.is_a?(Array)
|
|
48
|
+
|
|
49
|
+
line_arr.each_with_index do |hit, i|
|
|
50
|
+
next if hit.nil? || hit == "ignored"
|
|
51
|
+
|
|
52
|
+
n = hit.to_i
|
|
53
|
+
lines << "DA:#{i + 1},#{n}" if n >= 0
|
|
54
|
+
end
|
|
55
|
+
lines << "end_of_record"
|
|
56
|
+
end
|
|
57
|
+
lines.join("\n") + "\n"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Cobertura XML (no extra gems). Root metrics match common consumers (spec3.md).
|
|
61
|
+
# When +root+ is set, +filename+ on each +class+ is relative to that directory (for tools that expect +lib/...+).
|
|
62
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity -- linear XML assembly
|
|
63
|
+
def emit_cobertura(coverage_blob, root: nil)
|
|
64
|
+
lines_valid = 0
|
|
65
|
+
lines_covered = 0
|
|
66
|
+
coverage_blob.each_value do |file|
|
|
67
|
+
line_arr = line_array_from_file_entry(file)
|
|
68
|
+
next unless line_arr.is_a?(Array)
|
|
69
|
+
|
|
70
|
+
line_arr.each do |hit|
|
|
71
|
+
next if hit.nil? || hit == "ignored"
|
|
72
|
+
|
|
73
|
+
lines_valid += 1
|
|
74
|
+
lines_covered += 1 if hit.to_i > 0
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
line_rate = lines_valid.positive? ? (lines_covered.to_f / lines_valid) : 0.0
|
|
78
|
+
ts = Time.now.to_i
|
|
79
|
+
|
|
80
|
+
lines = []
|
|
81
|
+
lines << '<?xml version="1.0" encoding="UTF-8"?>'
|
|
82
|
+
lines << '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">'
|
|
83
|
+
lines << %(<coverage line-rate="#{line_rate}" branch-rate="0" lines-covered="#{lines_covered}" lines-valid="#{lines_valid}" branches-covered="0" branches-valid="0" complexity="0" timestamp="#{ts}" version="1">)
|
|
84
|
+
lines << '<packages><package name="app"><classes>'
|
|
85
|
+
coverage_blob.each do |path, file|
|
|
86
|
+
line_arr = line_array_from_file_entry(file)
|
|
87
|
+
next unless line_arr.is_a?(Array)
|
|
88
|
+
|
|
89
|
+
fname = CGI.escapeHTML(cobertura_display_path(path, root)).gsub("'", "'")
|
|
90
|
+
lines << %(<class name="#{fname}" filename="#{fname}"><lines>)
|
|
91
|
+
line_arr.each_with_index do |hit, i|
|
|
92
|
+
next if hit.nil? || hit == "ignored"
|
|
93
|
+
|
|
94
|
+
n = hit.to_i
|
|
95
|
+
lines << %(<line number="#{i + 1}" hits="#{n}"/>)
|
|
96
|
+
end
|
|
97
|
+
lines << "</lines></class>"
|
|
98
|
+
end
|
|
99
|
+
lines << "</classes></package></packages></coverage>\n"
|
|
100
|
+
lines.join
|
|
101
|
+
end
|
|
102
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
103
|
+
|
|
104
|
+
def cobertura_display_path(path, root)
|
|
105
|
+
p = path.to_s
|
|
106
|
+
return p if root.nil? || root.to_s.empty?
|
|
107
|
+
|
|
108
|
+
abs = File.expand_path(p)
|
|
109
|
+
r = File.expand_path(root.to_s)
|
|
110
|
+
Pathname.new(abs).relative_path_from(Pathname.new(r)).to_s
|
|
111
|
+
rescue ArgumentError
|
|
112
|
+
abs
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Aggregate stats for a SimpleCov-compatible coverage blob (lines arrays only).
|
|
116
|
+
def console_summary(coverage_blob)
|
|
117
|
+
files = 0
|
|
118
|
+
relevant = 0
|
|
119
|
+
covered = 0
|
|
120
|
+
coverage_blob.each_value do |file|
|
|
121
|
+
line_arr = line_array_from_file_entry(file)
|
|
122
|
+
next unless line_arr.is_a?(Array)
|
|
123
|
+
|
|
124
|
+
files += 1
|
|
125
|
+
line_arr.each do |h|
|
|
126
|
+
next if h.nil? || h == "ignored"
|
|
127
|
+
|
|
128
|
+
relevant += 1
|
|
129
|
+
covered += 1 if h.to_i > 0
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
pct = relevant.positive? ? (100.0 * covered / relevant) : 0.0
|
|
133
|
+
{
|
|
134
|
+
files: files,
|
|
135
|
+
lines_relevant: relevant,
|
|
136
|
+
lines_covered: covered,
|
|
137
|
+
line_percent: pct
|
|
138
|
+
}
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def format_console_summary(summary)
|
|
142
|
+
s = summary.is_a?(Hash) ? summary : console_summary(summary)
|
|
143
|
+
format(
|
|
144
|
+
"Polyrun coverage summary: %.2f%% lines (%d / %d) across %d files\n",
|
|
145
|
+
s[:line_percent] || s["line_percent"],
|
|
146
|
+
s[:lines_covered] || s["lines_covered"],
|
|
147
|
+
s[:lines_relevant] || s["lines_relevant"],
|
|
148
|
+
s[:files] || s["files"]
|
|
149
|
+
)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Per-file line stats for HTML and other formatters.
|
|
153
|
+
# Integer line counts for one file entry (for O(files x groups) group aggregation).
|
|
154
|
+
def line_counts(file_entry)
|
|
155
|
+
if native_acceleration?
|
|
156
|
+
MergeNative.line_counts(file_entry)
|
|
157
|
+
else
|
|
158
|
+
line_counts_ruby(file_entry)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def line_counts_ruby(file_entry)
|
|
163
|
+
line_arr = line_array_from_file_entry(file_entry)
|
|
164
|
+
return {relevant: 0, covered: 0} unless line_arr.is_a?(Array)
|
|
165
|
+
|
|
166
|
+
relevant = 0
|
|
167
|
+
covered = 0
|
|
168
|
+
line_arr.each do |hit|
|
|
169
|
+
next if hit.nil? || hit == "ignored"
|
|
170
|
+
|
|
171
|
+
relevant += 1
|
|
172
|
+
covered += 1 if hit.to_i > 0
|
|
173
|
+
end
|
|
174
|
+
{relevant: relevant, covered: covered}
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def file_line_stats(file)
|
|
178
|
+
c = line_counts(file)
|
|
179
|
+
rel = c[:relevant]
|
|
180
|
+
cov = c[:covered]
|
|
181
|
+
pct = rel.positive? ? (100.0 * cov / rel) : 0.0
|
|
182
|
+
[pct, rel, cov]
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
require_relative "formatters_html"
|