Expand unit test coverage across all scripts

Merged
TO
2mo ago
+764-1

Summary

  • Fills in main()/argparse paths and error branches for package_plugin.py (60% -> 98%), gen_spec.py (56% -> 99%), format_json.py (68% -> 97%)
  • Extends check_repo_consistency.py, release_transaction.py, validate_manifest.py test coverage
  • Wires coverage.py into the repo-safety.yml validate job — informational only, reports to the job summary, no --fail-under gate

Test plan

  • python3 -m unittest discover -s scripts -p "test_*.py" -v — 111 tests, all green
  • python3 -m compileall -q scripts — clean

Summary by cubic

Expands unit test coverage across all scripts and prevents package_plugin.py from overwriting an existing archive. CI now runs tests under pinned coverage and appends a coverage report to the job summary.

  • Tests

    • Exercise main()/argparse and error paths for package_plugin.py, gen_spec.py, format_json.py, check_repo_consistency.py, release_transaction.py, and validate_manifest.py.
    • Add edge-case checks: README/manifest mismatches and malformed lines; JSON primitive formatting and multi-file exit codes; packaged-asset parsing, hash verification, and missing assets; release tag_name mismatches, upload guards, finalize checks, and fail-fast when GITHUB_OUTPUT is unset; manifest target selection and exclusions; Windows zip contents and deterministic archives.
    • Restore ADR‑0001 fork identity and commit-snapshot validation; split active-list validation into empty vs non-list cases to cover both branches.
  • Operational notes

    • Packaging behavior change: previously overwrote existing archives; now exits with status 1 if the output file exists. If you rely on overwriting, delete the old file first.
    • CI installs pinned coverage==7.15.4, runs tests with coverage run, and writes coverage report -m to $GITHUB_STEP_SUMMARY (informational only). Adds .coverage and /.claude/worktrees to .gitignore.