Skip to content

Improve risk-driven test coverage - #9

Merged
han-xudong merged 4 commits into
mainfrom
test/risk-driven-coverage
Jul 23, 2026
Merged

Improve risk-driven test coverage#9
han-xudong merged 4 commits into
mainfrom
test/risk-driven-coverage

Conversation

@han-xudong

@han-xudong han-xudong commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

  • cover unconnected, send, poll, receive, timeout saturation, and reconnect paths in the POSIX UDP transport
  • add CLI process-boundary smoke tests that assert exit codes without coupling tests to output wording
  • keep production code, public APIs, coverage exclusions, and thresholds unchanged

Coverage

Metric Before After
Local line coverage 86.8% 87.9%
Local branch coverage 78.3% 80.2%
POSIX transport line coverage 81.1% 92.2%
POSIX transport branch coverage 67.1% 91.4%
CLI main line coverage 60.0% 85.0%

Verification

  • pixi run format-check
  • pixi run test (13/13 tests)
  • pixi run coverage (line gate >= 85%)
  • pixi run -e cmake-316 cmake-316-test
  • transport RED: send failure tests failed before enabling the linker wrappers
  • CLI RED: CTest reported no matching tests before process tests were registered

Summary by CodeRabbit

  • Tests
    • Expanded POSIX transport test coverage for interrupted operations, send/receive failures, invalid descriptors, timeouts, and datagram payload sizing.
    • Added a shared mechanism to validate program exit codes in test runs.
  • CLI
    • Improved automated checks for --help and invalid commands, ensuring consistent and correct exit codes.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@han-xudong, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 700f284d-4805-4723-ba66-fa03293a7257

📥 Commits

Reviewing files that changed from the base of the PR and between db75a66 and 35ad5dc.

📒 Files selected for processing (1)
  • test/assert_exit_code.cmake
📝 Walkthrough

Walkthrough

The test suite adds configurable POSIX transport wrappers for poll, send, and receive behavior, expands transport edge-case coverage, and introduces CTest checks for CLI help and invalid-command exit codes.

Changes

Test coverage expansion

Layer / File(s) Summary
POSIX transport behavior harness
test/test_posix_transport.cpp, test/CMakeLists.txt
Adds configurable poll, send, and receive wrappers and links the additional wrapped symbols.
POSIX transport scenarios
test/test_posix_transport.cpp
Covers I/O ordering, failures, polling errors, interrupted receives, payload handling, and timeout clamping.
CLI exit-code validation
test/assert_exit_code.cmake, test/CMakeLists.txt
Adds reusable process exit-code validation and tests CLI help and invalid-command statuses.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • netft/netft-cpp#8: Modifies the same __wrap_poll logic for EINTR and expired-deadline behavior.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: broader risk-driven test coverage without production-code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/risk-driven-coverage

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/assert_exit_code.cmake (1)

5-16: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Harden the process-boundary helper against hangs and launch failures.

A hung CLI can block CTest indefinitely because execute_process() has no timeout. Also, RESULT_VARIABLE may contain a launch-error string rather than an integer, so handle that case explicitly before comparing exit codes.

Proposed fix
 execute_process(
   COMMAND "${PROGRAM}" ${ARGUMENTS}
+  TIMEOUT 30
   RESULT_VARIABLE actual_exit_code
   OUTPUT_QUIET
   ERROR_QUIET
 )
 
+if(NOT actual_exit_code MATCHES "^-?[0-9]+$")
+  message(FATAL_ERROR
+    "Failed to execute ${PROGRAM}: ${actual_exit_code}"
+  )
+endif()
+
 if(NOT actual_exit_code EQUAL EXPECTED_EXIT_CODE)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/assert_exit_code.cmake` around lines 5 - 16, Update the execute_process
call in the assert_exit_code helper to enforce a finite timeout, and validate
actual_exit_code before comparing it with EXPECTED_EXIT_CODE because launch
failures may produce a non-numeric error string. Report launch failures and
timeout results through the existing FATAL_ERROR path while preserving the
current successful exit-code comparison.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/assert_exit_code.cmake`:
- Around line 5-16: Update the execute_process call in the assert_exit_code
helper to enforce a finite timeout, and validate actual_exit_code before
comparing it with EXPECTED_EXIT_CODE because launch failures may produce a
non-numeric error string. Report launch failures and timeout results through the
existing FATAL_ERROR path while preserving the current successful exit-code
comparison.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f7459f0-5ed2-438c-9152-244974c50397

📥 Commits

Reviewing files that changed from the base of the PR and between c582769 and 1aadc4c.

📒 Files selected for processing (3)
  • test/CMakeLists.txt
  • test/assert_exit_code.cmake
  • test/test_posix_transport.cpp

@han-xudong han-xudong closed this Jul 23, 2026
@han-xudong han-xudong reopened this Jul 23, 2026
@han-xudong
han-xudong merged commit 9846e0b into main Jul 23, 2026
17 checks passed
@han-xudong
han-xudong deleted the test/risk-driven-coverage branch July 23, 2026 07:33
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.

1 participant