tests: close small real coverage gaps in outbox/logger; document 3 dead default: arms - #107
Merged
Merged
Conversation
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.
…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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, notexercisable). Pairs it with an empty
drainOutbox()instead, keepingrelay()on its early-return path (after the warning fires, beforeany sink use). The sink dereference itself remains tracked by
LASTRADA-Software/morph#95, unchanged.logger.hpp:logFormat's (thestd::format_stringtemplateoverload, e.g.
logWarn(fmt, args...)) suppressed-below-thresholdbranch -- every existing test only called the plain
std::string_viewoverloads.Documented as unreachable (no test forced)
Three closed-enum-to-string helpers each have a
default:arm thatonly exists to satisfy the compiler's exhaustiveness check for an
out-of-range
static_cast-- every real enumerator is already handledexplicitly, mirroring
forms.hpp's already-establishedruleKindNamepattern:i18n.hpp'sfieldSlotName(FieldSlot)layout.hpp'sgroupKindName(GroupKind)reconnect_coordinator.hpp'sreconnectOutcomeName(ReconnectOutcome)Already resolved, no action needed
network_monitor.hpp-- confirmed already covered/documented by theprior round (deadlock-on-destructor case).
executor.hpp-- both flagged call sites already exercisedextensively, including exception-throwing tasks.
wire.hpp-- already documented as unreachable, tracked byLASTRADA-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 samedirectory.
scripts/coverage.sh'sSOURCES+=(examples/common)sweptboth kinds in indiscriminately -- a
TEST_CASEbody's own untakenassertion/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 fourllvm-covinvocations, verified directly against the realllvm-covbinary/version this repo's CI uses: correctly excludes every
test_*.cppundertestkit/while leaving every real testkit helpermeasured exactly as before.
scripts/aggregate_lcov_branches.py's ownoutput is confirmed byte-identical before/after (this change doesn't
touch that script).
Also investigated
LASTRADA-Software/morph#92(proposedDA:line-record aggregation, mirroring the existing
BRDA:branchaggregation) while here -- checked its premise against real downloaded
CI data and found
llvm-cov's lcov exporter already merges line-hitcounts 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_testssuite: 1046 test cases, 10038 assertions, allpassing.