Skip to content

chore/improve test runner#32

Merged
gbrennon merged 2 commits intomainfrom
chore/improve-test-runner
Mar 9, 2026
Merged

chore/improve test runner#32
gbrennon merged 2 commits intomainfrom
chore/improve-test-runner

Conversation

@gbrennon
Copy link
Copy Markdown
Owner

@gbrennon gbrennon commented Mar 9, 2026

  • chore(scripts): add coverage check script
  • chore(scripts): improve test runner

Copilot AI review requested due to automatic review settings March 9, 2026 01:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the test workflow by introducing a dedicated coverage-check script and wiring just test to run through it, aiming to provide a clearer coverage summary and enforce a minimum coverage threshold.

Changes:

  • Add scripts/check_coverage.sh to run cargo llvm-cov, extract JSON totals, print a summary, and enforce a lines-coverage threshold.
  • Update just test to run the new coverage-check script instead of invoking cargo llvm-cov directly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scripts/check_coverage.sh New coverage-check runner that generates/parses cargo llvm-cov JSON and enforces a threshold.
justfile Routes just test through the new coverage-check script.

Comment on lines +22 to +25
# Normalize null to 0
lines_percent=${lines_percent:-0}
functions_percent=${functions_percent:-0}
regions_percent=${regions_percent:-0}
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

The “Normalize null to 0” logic doesn’t work as written: jq -r will emit the literal string null when a field is missing, and ${lines_percent:-0} won’t replace that. Handle the null string explicitly (or make jq default to 0) to avoid printing null% and to keep comparisons predictable.

Copilot uses AI. Check for mistakes.
# Run all tests with coverage
test:
cargo llvm-cov --features test-helpers --ignore-filename-regex "ports/fakes"
./scripts/check_coverage.sh
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

Running ./scripts/check_coverage.sh makes just test depend on external tools like jq in addition to cargo-llvm-cov. Consider updating the workflow/docs/dev tooling to ensure jq is available (or have the script emit a clear install hint), otherwise just test may fail unexpectedly on fresh machines/CI images.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +12
# Generate JSON + text report; do not fail immediately so we can print friendly summary
cargo llvm-cov --features test-helpers --ignore-filename-regex "ports/fakes" --json --output-path cov.json || true

if [ ! -f cov.json ]; then
echo "ERROR: cov.json not found. cargo-llvm-cov failed to produce JSON output."
exit 1
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

The cargo llvm-cov ... || true suppresses test/coverage command failures, and since the script doesn’t remove any existing cov.json first, a failed run can still pass by reading a stale cov.json from a previous successful run. Capture the exit code, delete/overwrite cov.json before running, and fail the script if cargo llvm-cov fails (after printing any available summary).

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +20
# Extract totals
lines_count=$(jq -r '.data[0].totals.lines.count' cov.json)
lines_covered=$(jq -r '.data[0].totals.lines.covered' cov.json)
lines_percent=$(jq -r '.data[0].totals.lines.percent' cov.json)
functions_percent=$(jq -r '.data[0].totals.functions.percent' cov.json)
regions_percent=$(jq -r '.data[0].totals.regions.percent' cov.json)
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

This script assumes jq is installed, but there’s no preflight check, so the failure mode is a terse jq: command not found. Add a command -v jq check with a clear error message (or document/install it via the dev tooling) so just test fails with actionable guidance.

Copilot uses AI. Check for mistakes.
@gbrennon gbrennon self-assigned this Mar 9, 2026
@gbrennon gbrennon merged commit 3c4ed70 into main Mar 9, 2026
4 checks passed
@gbrennon gbrennon deleted the chore/improve-test-runner branch March 9, 2026 02:09
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