← 输入框|github.com|刷新
Skip to content

test: cover the three branches the suite never took - #640

Merged
shenxianpeng merged 1 commit into
mainfrom
test/branch-coverage
Oct 22, 2026
Merged

shenxianpeng merged 1 commit into
mainfrom
test/branch-coverage

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Requested by Xianpeng · project thread

Summary

Line coverage of commit_check/ was already 100%, but three conditions were only ever taken one way. This adds one test for each and turns on branch measurement, so Codecov keeps reporting both.

Before After
Lines 2429 / 2429 (100%) 2429 / 2429 (100%)
Branches 937 / 940, 3 partial 940 / 940, 0 partial
Total (coverage report, branch mode) 99% 100%

The branches that were never taken, and the test that now takes them:

  • config.py _load_parent_config: a relative inherit_from that exists neither next to the config, nor in the current directory, nor at the repository top. The new test checks it is reported and skipped, not read from somewhere else.
  • engine.py _tags_on_pushed_commits: a pre-commit pre-push line that deletes a branch (all-zero local SHA). The new test checks that it contributes no commits, and only the branch pushed beside it is read.
  • rule_builder.py _build_tag_rules: a TAG_RULES entry whose check is not tag. Only one entry exists today, so the test adds a second one and checks the [tag] regex is not applied to it.

pyproject.toml gets branch = true under [tool.coverage.run], so nox -s coverage and the uploaded coverage.xml carry branch data. No exclusions or pragma: no cover were added.

Test plan

  • coverage run --source commit_check -m pytest then coverage report: TOTAL 2429 stmts, 0 miss, 940 branches, 0 partial, 100%.
  • ruff check and ruff format --check pass on tests/.

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for configuration inheritance, pre-commit handling of deleted branches, and tag validation rules. These checks help ensure existing behavior remains consistent across common scenarios.
    • Coverage measurement now includes both executed lines and branches, providing a broader view of test coverage.

Line coverage was already 100%, but three conditions only ever went one
way. Add a test for each and measure branches from now on, so Codecov
reports both.
@shenxianpeng
shenxianpeng requested a review from a team as a code owner October 22, 2026 20:38
@github-actions github-actions Bot added the tests Add test related changes label Oct 22, 2026
@shenxianpeng shenxianpeng self-assigned this Oct 22, 2026
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74e9b94a-64f7-4e3a-b21f-3c58cd634170
📥 Commits

Reviewing files that changed from the base of the PR and between 4917ea9 and 597edce.

📒 Files selected for processing: 4
  • pyproject.toml
  • tests/config_test.py
  • tests/engine_test.py
  • tests/rule_builder_test.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The changes enable branch measurement in coverage and add tests for missing relative config paths, mixed pre-commit branch pushes, and tag regex selection.

Changes: Branch coverage

Layer / File(s) Summary
Enable branch measurement
pyproject.toml
Coverage configuration enables branch measurement.

Configuration loading test

Layer / File(s) Summary
Test missing parent path handling
tests/config_test.py
The test checks that load_config retains a local setting and reports an unresolved relative parent path.

Pre-commit tag validation test

Layer / File(s) Summary
Test mixed push scanning
tests/engine_test.py
The test checks that the deleted branch contributes no commits to scanning and that the surviving branch’s commit range is scanned.

Tag rule builder test

Layer / File(s) Summary
Test tag regex selection
tests/rule_builder_test.py
The test checks that the configured regex applies to the tag rule and not to the tag_signed entry.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 597ed

The coverage and regression-test updates are ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding tests for three previously uncovered branch paths and enabling branch coverage measurement.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7b12450) to head (597edce).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #640    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           14        14            
  Lines         2429      2429            
  Branches         0       470   +470     
==========================================
  Hits          2429      2429            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shenxianpeng
shenxianpeng merged commit e8389e5 into main Oct 22, 2026
33 checks passed
@shenxianpeng
shenxianpeng deleted the test/branch-coverage branch October 22, 2026 21:15
@codspeed

codspeed Bot commented Oct 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 137 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 647 untouched benchmarks
🆕 4 new benchmarks
⏩ 126 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 test_bare_human_name_not_detected[Co-authored-by: Devin <devin@example.org>] N/A 383.3 µs N/A
🆕 test_bare_human_name_not_detected[Signed-off-by: Devin <devin@example.org>] N/A 381.3 µs N/A
🆕 test_tag_validator_pre_commit_branch_deletion_adds_no_commits N/A 2.2 ms N/A
🆕 test_only_the_tag_check_reads_the_tag_section N/A 337.8 µs N/A

Comparing test/branch-coverage (597edce) with main (88ca3dc)2

Open in CodSpeed

Footnotes

  1. 126 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (4917ea9) during the generation of this report, so 88ca3dc was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Add test related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant