test: raise statement coverage to 90% and enforce it in CI (#747)

* test: raise statement coverage to 90% and enforce it in CI

Add unit tests across the cmd and internal packages to bring total
statement coverage above 90%, and gate future regressions.

- Cover CLI helpers, provider TUI handlers, resume/manifest paths, and
  error branches in config, llm, llmloop, scan, session, agent, viewer,
  mcp, pathutil, and telemetry.
- Raise the coverage threshold from 80% to 90% in the Makefile
  (COVERAGE_THRESHOLD) and in the CI "Check coverage threshold" step.
- Ignore generated coverage.out and coverage.html artifacts.

Total statement coverage is now 90.5%, measured consistently by both
`make coverage` and the CI `go test ./...` scope.

* test: widen statement coverage margin with environment-independent unit tests

Add table-driven unit tests for pure, environment-independent functions to
raise the statement-coverage safety margin above the 90% threshold:

- session.ResumeState.ValidateScanOptions (70% -> 100%)
- rules.SystemRule.UnmarshalJSON error branches (71% -> 82%)
- llmloop.stripMarkdownFences no-newline branch (82% -> 100%)
- diff.firstLine empty/blank-input branch
- diff.extractCodeBlock missing-newline and no-closing-fence branches
- main.truncate n<=1 and normalization branches
- agent.Agent nil-receiver accessor guards
This commit is contained in:
kite 2026-08-06 12:55:44 +08:00 committed by GitHub
parent 955220c0ad
commit 840f85f9bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
58 changed files with 5014 additions and 4 deletions

View file

@ -64,11 +64,11 @@ jobs:
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total: | awk '{print $3}' | sed 's/%//')
echo "Total coverage: ${COVERAGE}%"
if awk "BEGIN {exit !($COVERAGE < 80)}"; then
echo "FAIL: Coverage ${COVERAGE}% is below 80% threshold"
if awk "BEGIN {exit !($COVERAGE < 90)}"; then
echo "FAIL: Coverage ${COVERAGE}% is below 90% threshold"
exit 1
fi
echo "PASS: Coverage ${COVERAGE}% meets 80% threshold"
echo "PASS: Coverage ${COVERAGE}% meets 90% threshold"
- name: Build
run: go build -o ./opencodereview ./cmd/opencodereview