Skip to content

Make harness scripts portable and fail on failed gates - #24

Merged
loiane merged 1 commit into
mainfrom
loiane/portable-scripts-harness-exit
Nov 4, 2026
Merged

loiane merged 1 commit into
mainfrom
loiane/portable-scripts-harness-exit

Conversation

@loiane

@loiane loiane commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Summary

Step 4 of the review. The harness now reports failures correctly, and the new-code coverage gate works on macOS.

harness.sh

Problem Fix
Exited 0 even when the coverage or mutation gates failed Exits 1 if any gate fails, 2 on a missing prerequisite or unknown option. --baseline still exits 0, since brownfield capture should succeed
set -e stopped the script when mvn verify failed, before the summary was written The mvn verify result is now a build gate and the summary is always written; PIT is skipped after a failed build
--report > target/harness-summary.json and --baseline > .specs/_baseline.json (as the commands/agents tell you to run them) captured Maven's log In those modes build output goes to stderr and stdout carries only JSON
--module X --baseline wrote .specs/ inside the module Writes to the repo root's .specs/_baseline.json
Coverage used the last <counter> in the file Uses the report-level totals; a project with no branches no longer fails the branch threshold
PIT crash with no report was reported as skipped Reported as fail
jq/python3 not checked Checked up front (python3 added to the documented prerequisites)

The summary also gains finished_at and overall. The harness-report-parsing skill now documents the shape the script actually emits.

check-new-code-coverage.sh

  • Failed on macOS: it used mapfile and gawk-only match(…, arr). It now works on bash 3.2 + BSD awk, with python3 parsing the XML.
  • Could not read single-line JaCoCo reports, which JaCoCo 0.8.x writes.
  • Counted comments, blank lines and imports as uncovered. Now only lines JaCoCo reports on count.
  • Ignored new files that aren't committed yet, which is the normal state during /build. Untracked files now count as new code.
  • Diffed against the tip of origin/main, so changes others merged to main since branching were counted; it now diffs from the merge base.
  • Exits 2 with a clear message when BASE_REF can't be resolved.

Testing

  • tests/run.sh: 21 new cases (65 total). They use a fake mvn on PATH and a single-line JaCoCo report in a throwaway git repo, and pass on /bin/bash 3.2 and bash 5.
  • shellcheck is clean, markdownlint reports 0 issues, and parity is OK.

- harness.sh: exit 1 on any failed gate (2 on missing prerequisites), always
  write the summary (build result is a gate), keep stdout JSON-only in
  --report/--baseline, write the baseline at the repo root, use JaCoCo
  report-level totals, skip PIT after a failed build
- check-new-code-coverage.sh: bash 3.2 + BSD awk, python3 XML parsing,
  executable lines only, include untracked files, diff from the merge base
- tests for both scripts; docs, skills and changelog updated
@loiane
loiane merged commit 89c8c72 into main Nov 4, 2026
6 checks passed
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