Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,13 @@ The first command of a new release also rewrites the skill wherever it is alread
## Project and releases

[usestring/cli](https://github.com/usestring/cli) is the canonical upstream for the native CLI, npm client, source releases, issues, the Homebrew formula and the Scoop manifest. CLI maintainers own release publication, and the release workflow updates the formula and the manifest; see [releasing the CLI](docs/releasing.md).

### Mutation testing

`scripts/mutation-test.sh` runs [gremlins](https://github.com/go-gremlins/gremlins) (pinned to v0.6.0) on one package. It plants small faults and reports which ones no test catches. It is opt-in and report-only: CI does not run it, and it never fails on a low score.

```bash
scripts/mutation-test.sh ./internal/release [--out report.json] [--workers 2]
```

Score only code where a missed fault does real damage, such as release signature checks, credentials and the output contract other tools read. Read each `LIVED` mutant there: either add an assertion to an existing test that kills it, or record why it is equivalent. A surviving mutant anywhere else is not a reason to write a test.
56 changes: 56 additions & 0 deletions scripts/mutation-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Mutation-test Go packages with gremlins. Opt-in and report-only: nothing in CI runs it, and it
# never fails on a low score.
#
# Usage:
# scripts/mutation-test.sh <package-path> [--out <report.json>] [--workers <n>]
#
# Example:
# scripts/mutation-test.sh ./internal/release
#
# gremlins mutates copies in its own temp workdirs and leaves the checkout untouched, so it runs in
# place from the module root. A mutant whose tests fail is KILLED; one they still pass is LIVED.
# Score only code in a protected category (money, auth and secrets, safety gates, data correctness,
# contracts) and read each LIVED mutant there.
set -euo pipefail

GREMLINS_VERSION=v0.6.0

usage() {
sed -n '5,9p' "$0" | sed 's/^# \{0,1\}//' >&2
exit 2
}

[[ $# -ge 1 && "$1" != -* ]] || usage
pkg="$1"
shift
args=()
while [[ $# -gt 0 ]]; do
case "$1" in
--out)
[[ $# -ge 2 ]] || usage
if [[ "$2" = /* ]]; then
out="$2"
else
out="$PWD/$2"
fi
args+=(--output "$out")
shift 2
;;
--workers)
[[ $# -ge 2 ]] || usage
args+=(--workers "$2")
shift 2
;;
*) usage ;;
esac
done

root="$(cd "$(dirname "$0")/.." && pwd)"
tools="${XDG_CACHE_HOME:-$HOME/.cache}/go-mutation-test/gremlins-$GREMLINS_VERSION"
if [[ ! -x "$tools/gremlins" ]]; then
GOBIN="$tools" go install "github.com/go-gremlins/gremlins/cmd/gremlins@$GREMLINS_VERSION"
fi

cd "$root"
GOWORK=off "$tools/gremlins" unleash ${args[@]+"${args[@]}"} "$pkg"
Loading