Files
w3cjandClaude Opus 5.5 09f7f3b568 test(e2e): the Go end-to-end runner, tests/e2e, and its gc section
tests/e2e (build tag e2e) is the end-to-end runner in Go that takes over
tests/e2e.sh's sections one at a time. TestE2E is the run, with
tests/e2e.sh's options as flags (-e2e.only, -e2e.from, -e2e.clean,
-e2e.every-feature, -e2e.slots, -e2e.slot, -e2e.newest-base, -e2e.golden)
and its own -e2e.reuse. It keeps the sandbox (each slot's paths, Lima
home, XDG folders, Keychain service, ports +100 per slot, the lock),
devvm built from the checkout, config.toml and the pinned tool lock, the
host-tool check, the output lines (PASS/FAIL/SKIP/RETRY [n/N], times,
ETA), the heartbeat, each check's time limit (process groups: TERM, then
KILL), the timings files and the check-count guard (keyed by a checksum
of tests/e2e's Go files), the retry of checks marked Flaky, the slots'
plan, seeding (clonefile, reflinks) and summing, and the cleanup of only
what the run made.

Files: main_test.go (TestMain, TestE2E), options_test.go (flags),
sandbox_test.go, runner_test.go, check_test.go (S, Check, Skip, Flaky,
Builds, Tail, Needs), cmd_test.go (Run, Devvm, DevvmNames, Msg, Limactl,
InVM, Status), state_test.go (Paths: State, VMOf, VMDir, KeysOf, Record;
NewProject, Launch, Reuse, Layer, Own, Until, Settle, Port, Defer),
shared_test.go (Golden, GoE2E), slots_test.go, clone_{darwin,linux}_test.go,
sections_test.go (the table), gc_test.go (the gc section, its five check
titles tests/e2e.sh's word for word) and harness_test.go (TestHarness*,
no VM, run by scripts/test.sh).

tests/e2e.sh no longer has the gc block: after its own sections it hands
the chosen sections that go_sections lists to TestE2E in its sandbox and
under its lock, passing its pid, check count, expected total and start,
and adds the Go run's summary.go to its results. mise run e2e:go runs the
Go runner on its own. golangci-lint builds with the e2e tag; tests/e2e may
print, exit from TestMain, signal its own process groups, and run and read
its sandbox's commands and files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 21:28:44 -07:00

46 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Run the unit and CLI tests with the race detector, then hold each package's coverage to its
# baseline (scripts/coverage.sh).
# scripts/test.sh fail when a package's coverage drops below its baseline (mise run test)
# scripts/test.sh --raise raise the baselines instead (mise run coverage)
# Tests get a throwaway HOME and XDG folders, so none can reach the real ones, no SSH agent, and
# no color settings of your own. Each package gets 30 minutes, not go test's 10, so the CLI tests
# finish on a busy machine instead of timing out. Coverage comes from each package's own tests and
# from the CLI tests' devvm, built with -cover for every package (CLI_GOCOVERDIR, a folder for each script), merged with
# go tool covdata. The baselines are in testdata/coverage/.
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
mode=check
case ${1:-} in
'') ;;
--raise) mode=raise ;;
*) echo "usage: scripts/test.sh [--raise]" >&2; exit 2 ;;
esac
GOCACHE="$(go env GOCACHE)" GOMODCACHE="$(go env GOMODCACHE)" GOPATH="$(go env GOPATH)"
export GOCACHE GOMODCACHE GOPATH
home="$(mktemp -d "${TMPDIR:-/tmp}/devvm-test.XXXXXX")"
trap 'rm -rf "$home"' EXIT
cov="$home/coverage"
mkdir -p "$cov/unit" "$cov/cli" "$cov/merged"
unset SSH_AUTH_SOCK NO_COLOR FORCE_COLOR CLICOLOR_FORCE
cd "$root"
HOME="$home" XDG_DATA_HOME="$home/.local/share" XDG_CONFIG_HOME="$home/.config" XDG_CACHE_HOME="$home/.cache" \
CLI_GOCOVERDIR="$cov/cli" \
gotestsum -- -race -cover -timeout 30m ./... -args -test.gocoverdir="$cov/unit"
# The end-to-end runner's own tests, which need no VM: tests/e2e builds only with the e2e tag, and
# its TestE2E, the run itself, is left out.
HOME="$home" XDG_DATA_HOME="$home/.local/share" XDG_CONFIG_HOME="$home/.config" XDG_CACHE_HOME="$home/.cache" \
gotestsum -- -race -tags e2e -run '^TestHarness' ./tests/e2e
# Each CLI test script writes its devvm's coverage to a folder of its own under $cov/cli, so
# devvm runs in parallel scripts don't race on one meta-data file. A script that never ran
# devvm leaves its folder empty, and it's left out.
inputs="$cov/unit"
for dir in "$cov/cli"/*/; do
dir="${dir%/}"
if [ -d "$dir" ] && [ -n "$(ls -A "$dir")" ]; then inputs="$inputs,$dir"; fi
done
go tool covdata merge -i="$inputs" -o="$cov/merged"
go tool covdata percent -i="$cov/merged" >"$cov/percents"
scripts/coverage.sh "$mode" "$cov/percents"