Commit 3453353
Gcov plugin: expand unit test coverage, two small production fixes
CI's coverage report on PR #1261 revealed the Gcov plugin's just-added unit
coverage was still thin relative to file size. This adds ~172 new examples
targeting core branching, parsing, and dispatch logic across the four
under-covered files -- explicitly avoiding tests that just mirror a single
line of production code back as an assertion. Coverage:
console_reportinator.rb 18% -> 90% (15/81 -> 75/83)
gcov.rb 22% -> 79% (40/182 -> 143/182)
gcovr_reportinator.rb 44% -> 93% (88/200 -> 185/200)
reportgenerator_reportinator.rb 59% -> 85% (67/113 -> 97/114)
gcov_reportinator.rb 86% -> 93% (36/42 -> 39/42, untouched --
already well covered)
New spec file: spec/units/plugins/console_reportinator_spec.rb (24 examples)
covering the real gcov-text-output parsing logic (remap_partial_sources,
extract_gcov_source_path, log_coverage_report, run_gcov_summary) that had
zero coverage before.
Extended spec/units/plugins/gcov_spec.rb (+41 examples): process_untested_sources
(the largest single gap -- all three :ignore/:list/:compile modes, MC/DC flag
injection, ShellException guidance handling), generate_coverage_reports
(reportinator memoization, per-reportinator exception isolation as a build
failure rather than aborting the whole build), post_build's gating chain,
build_reportinators' utility-to-class dispatch, validate_untested_sources/
validate_utilities_config, collect_untested_sources, post_test_fixture_execute,
and the MC/DC-flag-injection pre_test_compile_register/pre_test_link_register
paths. Deliberately excludes thin one-line predicates, pure field-copies, and
setup() itself (would need an enormous collaborator double for wiring already
covered piecemeal by the extracted methods above).
Extended spec/units/plugins/gcovr_reportinator_spec.rb (+39 examples): the four
args_builder_* report-type methods, generate_reports_modern's skip-when-nothing-
enabled branch, collect_gcovr_opts' config-file-vs-normal exclusion handling,
run_gcovr's exception/summary flow, and the two previously-untested pure text
parsers extract_gcovr_error_message/extract_gcovr_summary (including the
multiple-summary-blocks-picks-the-last-one case a naive test would get wrong).
Extended spec/units/plugins/reportgenerator_reportinator_spec.rb (+10 examples):
build_report_types, and -- after a small testability refactor (below) --
run_gcov's gcov-output filename-extraction/rename regex logic (the biggest
previously-untested gap in this file) and generate_gcov_files' directory
discovery/sort/exclude logic.
Two small production changes, made while designing the above:
1. ConsoleReportinator#log_coverage_report: a Partial-implementation source
whose gcov output can't be matched at all previously produced no report
AND no log -- silently different from the equivalent non-Partial "found no
coverage results" case just below it. Added the same COMPLAIN log to that
branch.
2. ReportGeneratorReportinator previously called Dir.glob/File.exist?/
File.rename directly in generate_gcov_files, run_reportgenerator, and
run_gcov -- real filesystem I/O with no mockable seam, which is exactly why
those methods had zero unit coverage. Routed all of it through FileWrapper
(lib/ceedling/file_wrapper.rb), the same DI-friendly abstraction Gcov
itself already uses: Dir.glob -> @file_wrapper.directory_listing,
File.exist? -> @file_wrapper.exist?, File.rename -> @file_wrapper.mv.
Added @file_wrapper = @ceedling[:file_wrapper] to initialize. No unit spec
in this PR touches a real file or directory.
Verified: full unit suite (3107 examples, 0 failures), mkdocs build --strict,
and the full Gcov system-test suite (26 examples, 0 failures, 2 pending --
gdb unavailable, unrelated) run against real gcc/gcovr/reportgenerator via
throwtheswitch/madsciencelab-plugins Docker, confirming the FileWrapper
refactor and the log_coverage_report fix behave identically end-to-end.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent 4cd0c2b commit 3453353
6 files changed
Lines changed: 1096 additions & 15 deletions
File tree
- plugins/gcov/lib
- spec/units/plugins
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
181 | 188 | | |
182 | 189 | | |
183 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
228 | | - | |
| 229 | + | |
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
236 | | - | |
| 237 | + | |
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| |||
256 | 257 | | |
257 | 258 | | |
258 | 259 | | |
259 | | - | |
| 260 | + | |
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
| |||
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
365 | | - | |
| 366 | + | |
366 | 367 | | |
367 | 368 | | |
368 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
0 commit comments