make quick lints and tests the packages changed since the branch left main (or PKGS), runs the oracle when it changed, and the e2e tests and golden screens defined in changed e2e files, or all of e2e when the harness changed or with E2E=1.
- commit
- 2dd41e8ba6f12602e9e15e54e360404c027ab50d
- parent
- 05c0cd4c91b29fd6735acbf31a8823f2ee9682bb
- author
- Dami <dami.etoile@gmail.com>
- kind
- build risk score 1.0 of 3, Jev's estimate
| M | Makefile | 8 | ++- |
| A | scripts/ | 118 | ++++++++++++++++++++++++++++++ |
@@ -7,7 +7,7 @@ GHOSTTY_SRC := $(DEPS)/ghostty-src
77 GHOSTTY_OUT := $(DEPS)/ghostty88 GHOSTTY_STAMP := $(GHOSTTY_OUT)/.built-$(GHOSTTY_COMMIT)99 10-10+1111 1212 build:1313 CGO_ENABLED=0 go build -o bin/012 ./cmd/012@@ -27,10 +27,14 @@ test:
2727 2828 # Everything that must pass before a push: lint, unit tests, the excelize2929 # oracle and the end-to-end tests in libghostty at once, then the speed30-# gate and timed tests alone (scripts/check.sh).30+# gate and timed tests alone (scripts/check.sh). make quick checks only31+# what changed, for iterating.3132 check: $(GHOSTTY_STAMP)3233 @scripts/check.sh3334 35+quick:36+ @PKGS="$(PKGS)" TIMED='^($(TIMED_UI)|$(TIMED_NBVIEW))$$' scripts/quick.sh37+3438 # gofmt, vet (with the stress benchmarks), staticcheck, shape limits and3539 # the docs checks, at once.3640 lint:@@ -0,0 +1,118 @@
1+2+# make quick: the checks of make check that concern what changed, for3+# iterating. The packages are those with Go files changed since the4+# branch left BASE (main), committed or not, or PKGS when set (./x/y or5+# ./x/... directories). For them: make lint's Go checks (the docs checks6+# cover the repo), and their unit tests; the oracle when it changed; and7+# the e2e tests and golden screens defined in changed e2e files, or all8+# of e2e with E2E=1. It is no stand-in for make check, which must pass9+# before a push. See docs/contributing/testing.md.10+set -u11+cd "$(dirname "$0")/.."12+MAKE=${MAKE:-make}13+BASE=${BASE:-main}14+# TIMED is the tests make test leaves to make speed, from the Makefile.15+TIMED=${TIMED:-^$}16+17+if [ -n "${PKGS:-}" ]; then18+ dirs="" files=""19+ for p in $PKGS; do20+ p=${p#./}21+ case $p in22+ ... | */...) dirs="$dirs $(git ls-files "${p%...}*.go" | xargs -n1 dirname | sort -u)" ;;23+ *) dirs="$dirs $p" ;;24+ esac25+ done26+else27+ from=$(git merge-base "$BASE" HEAD) || exit 128+ files=$( (git diff --name-only "$from"; git ls-files --others --exclude-standard) | sort -u)29+ dirs=$(for f in $files; do30+ case $f in (*.go) [ -f "$f" ] && dirname "$f" ;; esac31+ done | sort -u)32+fi33+dirs=$(echo $dirs)34+35+out=$(mktemp -d)36+trap 'rm -rf "$out"' EXIT37+fail=038+names=""39+run() {40+ name=$141+ shift42+ ("$@") >"$out/$name" 2>&1 &43+ eval "pid_$name=$!"44+ names="$names $name"45+}46+47+lint() {48+ if [ -n "$dirs" ]; then49+ scripts/lint.sh $dirs50+ else51+ go run ./scripts/doclint && go run ./scripts/doccheck52+ fi53+}54+55+unit() {56+ set --57+ for d in $dirs; do58+ case $d in oracle | oracle/* | e2e | e2e/*) ;; *) set -- "$@" "./$d" ;; esac59+ done60+ [ $# -eq 0 ] || STRESS_DIR=$(pwd)/.deps/stress go test -skip "$TIMED" "$@"61+}62+63+oracle() {64+ case " $dirs " in65+ *" oracle"*) cd oracle && go test -count=1 ./... ;;66+ esac67+}68+69+# e2e runs the tests named in changed e2e files, and the golden screens70+# they define with their light and high-contrast variants; all of e2e71+# with E2E=1 or when the harness changed.72+e2e() {73+ pattern="" screens=""74+ for f in $files; do75+ case $f in76+ e2e/harness_test.go | e2e/screens_test.go) E2E=1 ;;77+ e2e/*_test.go)78+ [ -f "$f" ] || continue79+ pattern="$pattern$(sed -n 's/^func \(Test[A-Za-z0-9_]*\)(t \*testing\.T).*/|\1/p' "$f" | tr -d '\n')"80+ screens="$screens$(sed -n 's/.*{name: "\([^"]*\)".*/|\1/p' "$f" | tr -d '\n')"81+ ;;82+ esac83+ done84+ if [ -z "${E2E:-}" ] && [ -z "$pattern$screens" ]; then85+ return 086+ fi87+ "$MAKE" --no-print-directory -s libghostty || return 188+ PKG_CONFIG_PATH=$(pwd)/.deps/ghostty/share/pkgconfig89+ export PKG_CONFIG_PATH90+ cd e2e || return 191+ if [ -n "${E2E:-}" ]; then92+ go test -count=1 ./...93+ return94+ fi95+ ok=096+ if [ -n "$pattern" ]; then97+ go test -count=1 -run "^(${pattern#|})\$" ./... || ok=198+ fi99+ if [ -n "$screens" ]; then100+ go test -count=1 -run "^TestScreens\$/^(${screens#|})(-light|-high-contrast)?\$" ./... || ok=1101+ fi102+ return $ok103+}104+105+echo "quick: ${dirs:-no Go packages} changed"106+run lint lint107+run unit unit108+run oracle oracle109+run e2e e2e110+for name in $names; do111+ eval "pid=\$pid_$name"112+ wait "$pid" || { fail=1; echo "=== $name: FAILED"; }113+ cat "$out/$name"114+done115+if [ $fail = 0 ]; then116+ echo "quick: ok; make check before a push"117+fi118+exit $fail