Skip to content

tests: close small real coverage gaps in outbox/logger; document 3 dead default: arms - #107

Merged
Yaraslaut merged 4 commits into
masterfrom
investigate/small-coverage-gaps
Aug 16, 2026
Merged

tests: close small real coverage gaps in outbox/logger; document 3 dead default: arms#107
Yaraslaut merged 4 commits into
masterfrom
investigate/small-coverage-gaps

Conversation

@Yaraslaut

@Yaraslaut Yaraslaut commented Aug 16, 2026

Copy link
Copy Markdown
Member

Investigated 8 small (1-3 gap-unit) flagged files. 2 real gaps closed
with tests, 3 unreachable default: arms documented, 3 already fully
resolved (no action needed -- confirmed already covered/documented by
prior rounds). Also fixes a real root-cause coverage-tooling bug
found while doing this (see below).

Closed with real tests

  • outbox.hpp: OutboxRelay::relay()'s null-sink warning path --
    every existing test paired a null sink with a non-empty
    drainOutbox(), which would dereference the null sink (real UB, not
    exercisable). Pairs it with an empty drainOutbox() instead, keeping
    relay() on its early-return path (after the warning fires, before
    any sink use). The sink dereference itself remains tracked by
    LASTRADA-Software/morph#95, unchanged.
  • logger.hpp: logFormat's (the std::format_string template
    overload, e.g. logWarn(fmt, args...)) suppressed-below-threshold
    branch -- every existing test only called the plain
    std::string_view overloads.

Documented as unreachable (no test forced)

Three closed-enum-to-string helpers each have a default: arm that
only exists to satisfy the compiler's exhaustiveness check for an
out-of-range static_cast -- every real enumerator is already handled
explicitly, mirroring forms.hpp's already-established
ruleKindName pattern:

  • i18n.hpp's fieldSlotName (FieldSlot)
  • layout.hpp's groupKindName (GroupKind)
  • reconnect_coordinator.hpp's reconnectOutcomeName (ReconnectOutcome)

Already resolved, no action needed

  • network_monitor.hpp -- confirmed already covered/documented by the
    prior round (deadlock-on-destructor case).
  • executor.hpp -- both flagged call sites already exercised
    extensively, including exception-throwing tasks.
  • wire.hpp -- already documented as unreachable, tracked by
    LASTRADA-Software/morph#96.

Also: fixes a real coverage-tooling root cause

examples/common/testkit/ mixes real, reusable test-support code
(backend_rig.hpp, db_fixture.hpp, strand_interleaver.hpp, ...)
with actual Catch2 test files (test_event_poller.cpp,
test_presenter.cpp, test_fault_proxy.cpp, ...) in the same
directory. scripts/coverage.sh's SOURCES+=(examples/common) swept
both kinds in indiscriminately -- a TEST_CASE body's own untaken
assertion/lambda branches (a REQUIRE's fail arm, a "must not run"
callback proving itself unreachable) were being measured as if they
were product code.

This is the exact "phantom uncovered branch" pattern this session
repeatedly had to hand-verify file by file across several PRs before
concluding each one was tooling noise, not a real gap. Adds
-ignore-filename-regex='.*/testkit/test_[^/]+\.cpp$' to all four
llvm-cov invocations, verified directly against the real llvm-cov
binary/version this repo's CI uses: correctly excludes every
test_*.cpp under testkit/ while leaving every real testkit helper
measured exactly as before. scripts/aggregate_lcov_branches.py's own
output is confirmed byte-identical before/after (this change doesn't
touch that script).

Also investigated LASTRADA-Software/morph#92 (proposed DA:
line-record aggregation, mirroring the existing BRDA: branch
aggregation) while here -- checked its premise against real downloaded
CI data and found llvm-cov's lcov exporter already merges line-hit
counts across template instantiations correctly (no duplicate DA:
records found for any of the file/line examples the issue names).
Posted findings there; left the issue open for a second opinion rather
than closing it myself.

Verification

Full morph_tests suite: 1046 test cases, 10038 assertions, all
passing.

Yaraslau Tamashevich added 3 commits August 16, 2026 09:19
Every existing test paired a null sink with a non-empty drainOutbox(),
which would dereference the null sink -- real UB, not exercisable. This
pairs the null sink with an empty drainOutbox() result instead, keeping
relay() on its early-return path (which runs after logIfAnyDepNull()
but before any sink use), so the null-sink warning fires without ever
calling through the null pointer. The surrounding comment is updated to
reflect exactly what's now covered vs. what's still tracked by
#95 (the sink dereference itself, on a non-empty
drain, which still needs the fault-injection seam that issue requests).
Every existing test called the plain std::string_view overloads
(going through detail::log directly); none exercised the
std::format_string template overload (logFormat/logWarn(fmt, args...))
at a suppressed level, so its own early-return-before-formatting
branch never ran.
…lpers

FieldSlot::fieldSlotName, GroupKind::groupKindName, and
ReconnectOutcome::reconnectOutcomeName each have a default: arm that
only exists to satisfy the compiler's return-on-every-path check for
an out-of-range static_cast -- every enumerator is already handled
explicitly. Mirrors forms.hpp's identical ruleKindName pattern.
@Yaraslaut Yaraslaut added the no docs update Skip the header<->spec sync gate for this PR label Aug 16, 2026
…easurement

examples/common/testkit/ mixes real, reusable test-support code
(backend_rig.hpp, db_fixture.hpp, strand_interleaver.hpp, ...) with
actual Catch2 test files (test_event_poller.cpp, test_presenter.cpp,
test_fault_proxy.cpp, ...) in the same directory. Unlike include/morph
and examples/pastebin's SOURCES entries, which contain no test files
at all, `SOURCES+=(examples/common)` swept both kinds in
indiscriminately -- a TEST_CASE body's own untaken assertion/lambda
branches (a REQUIRE's fail arm, a "must not run" callback proving
itself unreachable, the untested half of a dispatch closure a sibling
test exercises instead) were being measured as if they were product
code.

This is the exact "phantom uncovered branch" pattern this session
repeatedly had to hand-verify file by file across several PRs
(test_event_poller.cpp, test_presenter.cpp, test_fault_proxy.cpp,
test_backend_rig.cpp, and others) before concluding each one was
tooling noise, not a real gap -- this fix addresses the actual root
cause once, for the whole category, instead of continuing to verify
each test file individually as its turn comes up in a coverage sweep.

Adds -ignore-filename-regex='.*/testkit/test_[^/]+\.cpp$' to all four
llvm-cov invocations (show/report/export-lcov/export-json). Verified
directly against the real llvm-cov binary this repo's CI uses (a local
Windows build of the same clang/llvm-cov version): the flag correctly
excludes every test_*.cpp under testkit/ while leaving every real
testkit helper (backend_rig.hpp/.cpp, db_fixture.hpp, etc.) and
examples/common/gui/*.hpp measured exactly as before. Confirmed
scripts/aggregate_lcov_branches.py's own output is byte-identical
before/after this change (it only reads whatever coverage.sh already
filtered out for it -- no change to that script itself).
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Yaraslaut
Yaraslaut merged commit 60a354a into master Aug 16, 2026
26 checks passed
@Yaraslaut
Yaraslaut deleted the investigate/small-coverage-gaps branch August 16, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no docs update Skip the header<->spec sync gate for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant