Skip to content

Improve test coverage to 100% functions / 88% lines; automate Windows coverage via OpenCppCoverage - #5

Open
VipinKum4r wants to merge 11 commits into
amoldhamale1105:masterfrom
VipinKum4r:master
Open

Improve test coverage to 100% functions / 88% lines; automate Windows coverage via OpenCppCoverage#5
VipinKum4r wants to merge 11 commits into
amoldhamale1105:masterfrom
VipinKum4r:master

Conversation

@VipinKum4r

Copy link
Copy Markdown
Contributor

Improve coverage to 100% functions / ~89% lines and automate Windows coverage report

What this PR does

Builds on the test foundation from #4 to push coverage as high as the library's design permits, and adds automated coverage report generation on Windows via OpenCppCoverage.


Coverage results

Metric Before (#4) After (this PR)
Line coverage 67.5% (154 / 228) 88.6% (202 / 228)
Function coverage 84.8% (39 / 46) 100% (46 / 46) ✅

These are defensive/safety net code paths — their presence is valuable for production robustness even if they cannot be exercised by unit tests.


build.sh changes

The -t flag (test + coverage) now auto-detects the platform:

  • Linux / macOS — existing lcov + genhtml flow (unchanged)
  • Windows (MINGW / MSYS / Cygwin) — uses OpenCppCoverage, producing both an HTML report and a Cobertura XML report suitable for CI

If OpenCppCoverage is not on PATH, the script prints a clear install instruction (winget install OpenCppCoverage) and exits gracefully instead of failing the build.


.gitignore update

Added CoverageReport-*/ to ignore the timestamped report folders OpenCppCoverage generates in the working directory.

Comment thread tests/EventLoopBasicTest.cpp Outdated
Comment thread tests/EventLoopBasicTest.cpp
Comment thread tests/EventLoopBasicTest.cpp Outdated
Comment thread tests/EventLoopBasicTest.cpp Outdated
Comment thread tests/EventLoopBasicTest.cpp Outdated
Comment thread tests/EventLoopBasicTest.cpp Outdated
Comment thread tests/EventLoopBasicTest.cpp Outdated
Comment thread tests/EventLoopBasicTest.cpp Outdated
Comment thread tests/EventLoopBasicTest.cpp Outdated
Comment thread tests/EventLoopBasicTest.cpp Outdated
Broke the two giant TEST() blocks into individual TEST/TEST_F cases
with proper <func>_test_scenario names. Moved event setup/teardown
into fixtures (SetUp/TearDown, SetUpTestSuite for the shared loop)
instead of building everything inline in one function.

Also added a real assertion that halt happens within its scheduled
delay instead of just waiting up to 300ms and hoping, and made the
DataEvent test actually check the handler fired.

While adding a BLOCK-mode test I hit a real bug: start() would call
std::thread(...) on top of a thread that was still joinable from a
previous run, since Halt() signals shutdown but never joins. Fixed
by joining m_mainLoop/m_scheduler at the top of start() if needed.

Cleaned up the coverage-percentage comments in the test file and
build.sh since that stuff belongs in the coverage report, not code.

Not doing in this PR: the dead-code cleanup in eventLoop() (will be
its own PR) or mocking thread-creation failures for the catch blocks
(needs a factory seam in EventManager, also separate).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants