Skip to content

Raise risk-driven coverage to 85% - #10

Merged
han-xudong merged 4 commits into
mainfrom
test/codecov-85
Jul 23, 2026
Merged

Raise risk-driven coverage to 85%#10
han-xudong merged 4 commits into
mainfrom
test/codecov-85

Conversation

@han-xudong

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

Copy link
Copy Markdown
Member

Summary

  • cover public enum conversions and invalid discovery options
  • cover CLI parser, serialization, interruption, and output failure boundaries
  • enforce 85% local line and branch gates
  • enforce 85% Codecov project and 90% patch targets

No production source or public API is changed.

Verification

  • pixi run format-check
  • pixi run test
  • pixi run coverage
  • pixi run -e cmake-316 cmake-316-test
  • Codecov YAML validation API

Local coverage before:

  • line: 87.87%
  • branch: 80.04%

Local coverage after:

  • line: 92.81%
  • branch: 86.12%

Summary by CodeRabbit

  • Bug Fixes

    • Improved command-line validation and error reporting for invalid options, timeouts, interruptions, and output-file failures.
    • Improved human-readable and JSON information output, including correct escaping of special characters.
    • Added validation for invalid sensor discovery settings.
  • Tests

    • Expanded coverage for units, states, fault codes, CLI behavior, and sensor discovery.
    • Enforced 85% project, line, and branch coverage thresholds.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 55c23ded-5975-4cc9-b0be-efb00c294610

📥 Commits

Reviewing files that changed from the base of the PR and between 436bb63 and 9aaf0e8.

📒 Files selected for processing (3)
  • .codecov.yml
  • test/test_cli.cpp
  • test/test_types.cpp

📝 Walkthrough

Walkthrough

Coverage reporting now enforces line and branch thresholds and emits formatted XML. Tests expand validation for CLI parsing, output, interruptions, faults, file replacement, discovery options, and unit/state string conversions.

Changes

Coverage and test coverage

Layer / File(s) Summary
CLI and discovery validation tests
test/test_cli.cpp, test/test_discovery.cpp
Tests cover invalid CLI arguments, JSON and human-readable info output, monitor and bias failure handling, output replacement failures, and invalid discovery options.
Unit and state conversion tests
test/test_types.cpp
Table-driven tests cover all listed force, torque, client-state, and fault-code string conversions, plus invalid unit spellings.
Coverage reporting and thresholds
pixi.toml, .codecov.yml
The coverage task adds branch exclusions, formatted XML output, and an 85% branch threshold; Codecov uses an explicit 85% project target.

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

🚥 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 clearly matches the main change: increasing risk-driven coverage to 85%.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/codecov-85

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.

Actionable comments posted: 3

🤖 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.

Inline comments:
In `@test/test_cli.cpp`:
- Around line 421-433: Strengthen the stderr assertions in both CliMonitor
tests: test/test_cli.cpp lines 421-433 should check for a stable substring
identifying the stored client failure, and test/test_cli.cpp lines 467-479
should check for a stable substring identifying the fail-stop client fault. Keep
the existing non-empty checks and return-code expectations, but ensure each test
rejects generic first-sample timeout diagnostics.
- Around line 257-278: Strengthen CliInfo.SerializesEveryJsonControlBranch by
asserting the output JSON contains the product field with the complete escaped
value, including escaped quotes, backslashes, backspace, form feed, newline,
carriage return, tab, and the control-byte escape. Keep the existing success and
empty-error assertions unchanged.

In `@test/test_types.cpp`:
- Around line 300-317: Update ConvertsStateAndFaultCodeStrings to assert each
individual ClientState and FaultCode maps to its exact expected public string,
rather than relying only on set-size uniqueness. Retain the existing coverage of
all enum values, but add direct expectations for each netft::to_string result.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d4ccf229-ea69-46d0-8040-5ec019d5653f

📥 Commits

Reviewing files that changed from the base of the PR and between 9846e0b and 436bb63.

📒 Files selected for processing (5)
  • codecov.yml
  • pixi.toml
  • test/test_cli.cpp
  • test/test_discovery.cpp
  • test/test_types.cpp

Comment thread test/test_cli.cpp
Comment thread test/test_cli.cpp Outdated
Comment on lines +421 to +433
TEST(CliMonitor, IncludesAStoredClientFailureWhenNoSampleArrives) {
netft::test::FakeSensor sensor;
auto options = options_for(netft::cli::Command::Monitor, sensor);
options.config.rdt_port = 1;
options.config.recovery_policy = netft::RecoveryPolicy::FailStop;
options.duration = 50ms;
std::ostringstream output;
std::ostringstream errors;

EXPECT_EQ(netft::cli::run(options, output, errors), 2);
EXPECT_TRUE(output.str().empty());
EXPECT_FALSE(errors.str().empty());
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Verify the specific client-failure diagnostics. Both tests accept any stderr text, including a generic first-sample timeout, rather than proving the intended client failure was propagated.

  • test/test_cli.cpp#L421-L433: assert a stable substring identifying the stored client failure.
  • test/test_cli.cpp#L467-L479: assert a stable substring identifying the fail-stop client fault.
📍 Affects 1 file
  • test/test_cli.cpp#L421-L433 (this comment)
  • test/test_cli.cpp#L467-L479
🤖 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/test_cli.cpp` around lines 421 - 433, Strengthen the stderr assertions
in both CliMonitor tests: test/test_cli.cpp lines 421-433 should check for a
stable substring identifying the stored client failure, and test/test_cli.cpp
lines 467-479 should check for a stable substring identifying the fail-stop
client fault. Keep the existing non-empty checks and return-code expectations,
but ensure each test rejects generic first-sample timeout diagnostics.

Comment thread test/test_types.cpp Outdated
@han-xudong

Copy link
Copy Markdown
Member Author

@coderabbitai review

@han-xudong
han-xudong merged commit d8cf748 into main Jul 23, 2026
16 of 17 checks passed
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@han-xudong
han-xudong deleted the test/codecov-85 branch July 23, 2026 09:04
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