-
Notifications
You must be signed in to change notification settings - Fork 0
chore/improve test runner #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| export PATH="$HOME/.cargo/bin:$PATH" | ||
|
|
||
| echo "Running cargo-llvm-cov (generating JSON report)..." | ||
| # 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 | ||
|
Comment on lines
+7
to
+12
|
||
| fi | ||
|
|
||
| # 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) | ||
|
Comment on lines
+15
to
+20
|
||
|
|
||
| # Normalize null to 0 | ||
| lines_percent=${lines_percent:-0} | ||
| functions_percent=${functions_percent:-0} | ||
| regions_percent=${regions_percent:-0} | ||
|
Comment on lines
+22
to
+25
|
||
|
|
||
| printf "\nCoverage summary:\n" | ||
| printf " Lines: %s%% (%s/%s)\n" "$lines_percent" "$lines_covered" "$lines_count" | ||
| printf " Functions: %s%%\n" "$functions_percent" | ||
| printf " Regions: %s%%\n" "$regions_percent" | ||
|
|
||
| # Enforce threshold | ||
| threshold=90 | ||
| # Use awk for numeric comparison (handles floats) | ||
| cmp=$(awk -v p="$lines_percent" -v t="$threshold" 'BEGIN{ if (p+0 >= t+0) print 0; else print 1 }') | ||
| if [ "$cmp" -eq 0 ]; then | ||
| echo "Coverage check: PASS (>= ${threshold}%)" | ||
| exit 0 | ||
| else | ||
| echo "Coverage check: FAIL (< ${threshold}%)" | ||
| exit 1 | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running
./scripts/check_coverage.shmakesjust testdepend on external tools likejqin addition tocargo-llvm-cov. Consider updating the workflow/docs/dev tooling to ensurejqis available (or have the script emit a clear install hint), otherwisejust testmay fail unexpectedly on fresh machines/CI images.