cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

cat/module-path
012 / scripts / quick.sh
quick.sh 3.1K executable
1#!/bin/sh2# 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.10set -u11cd "$(dirname "$0")/.."12MAKE=${MAKE:-make}13BASE=${BASE:-main}14# TIMED is the tests make test leaves to make speed, from the Makefile.15TIMED=${TIMED:-^$}1617if [ -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 done26else27 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)32fi33dirs=$(echo $dirs)3435out=$(mktemp -d)36trap 'rm -rf "$out"' EXIT37fail=038names=""39run() {40 name=$141 shift42 ("$@") >"$out/$name" 2>&1 &43 eval "pid_$name=$!"44 names="$names $name"45}4647lint() {48 if [ -n "$dirs" ]; then49 scripts/lint.sh $dirs50 else51 go run ./scripts/doclint && go run ./scripts/doccheck52 fi53}5455unit() {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}6263oracle() {64 case " $dirs " in65 *" oracle"*) cd oracle && go test -count=1 ./... ;;66 esac67}6869# 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.72e2e() {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}104105echo "quick: ${dirs:-no Go packages} changed"106run lint lint107run unit unit108run oracle oracle109run e2e e2e110for name in $names; do111 eval "pid=\$pid_$name"112 wait "$pid" || { fail=1; echo "=== $name: FAILED"; }113 cat "$out/$name"114done115if [ $fail = 0 ]; then116 echo "quick: ok; make check before a push"117fi118exit $fail