View raw

1 #!/bin/sh 2 # Run the STE linter test suite in a batch Emacs. 3 # 4 # Required dependency: emacs, with Org mode. Org mode ships with Emacs. 5 # The suite runs the ERT tests, then runs the batch command on two 6 # temporary files to check its exit status. 7 # 8 # Exit status: 0 when every test passes, 1 otherwise. 9 10 set -eu 11 12 dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) 13 14 if ! command -v emacs >/dev/null 2>&1; then 15 echo "Error: emacs is not on PATH. Install Emacs, then run this script again." >&2 16 exit 1 17 fi 18 19 for file in ste-lint.el ste-lint-tests.el; do 20 if [ ! -r "$dir/$file" ]; then 21 echo "Error: cannot read $dir/$file. The skill directory is incomplete." >&2 22 exit 1 23 fi 24 done 25 26 if ! emacs --batch -Q -L "$dir" \ 27 -l "$dir/ste-lint-tests.el" \ 28 -f ert-run-tests-batch-and-exit; then 29 echo "Error: STE linter tests failed. Read the ERT output above for the failing test." >&2 30 exit 1 31 fi 32 33 tmp=$(mktemp -d "${TMPDIR:-/tmp}/ste-lint.XXXXXXXX") 34 trap 'rm -f "$tmp/clean.org" "$tmp/dirty.org"; rmdir "$tmp"' EXIT 35 printf 'Run the script.\n' > "$tmp/clean.org" 36 printf 'We cannot stop; we must go.\n' > "$tmp/dirty.org" 37 38 lint() { 39 emacs --batch -Q -l "$dir/ste-lint.el" -f ste-lint-batch "$1" 2>/dev/null 40 } 41 42 if ! lint "$tmp/clean.org"; then 43 echo "Error: the batch command failed on a clean file." >&2 44 exit 1 45 fi 46 if lint "$tmp/dirty.org"; then 47 echo "Error: the batch command passed a file with an ERROR finding." >&2 48 exit 1 49 fi 50 51 echo "STE linter tests passed." 52