#!/bin/sh # Run the STE linter test suite in a batch Emacs. # # Required dependency: emacs, with Org mode. Org mode ships with Emacs. # The suite runs the ERT tests, then runs the batch command on two # temporary files to check its exit status. # # Exit status: 0 when every test passes, 1 otherwise. set -eu dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) if ! command -v emacs >/dev/null 2>&1; then echo "Error: emacs is not on PATH. Install Emacs, then run this script again." >&2 exit 1 fi for file in ste-lint.el ste-lint-tests.el; do if [ ! -r "$dir/$file" ]; then echo "Error: cannot read $dir/$file. The skill directory is incomplete." >&2 exit 1 fi done if ! emacs --batch -Q -L "$dir" \ -l "$dir/ste-lint-tests.el" \ -f ert-run-tests-batch-and-exit; then echo "Error: STE linter tests failed. Read the ERT output above for the failing test." >&2 exit 1 fi tmp=$(mktemp -d "${TMPDIR:-/tmp}/ste-lint.XXXXXXXX") trap 'rm -f "$tmp/clean.org" "$tmp/dirty.org"; rmdir "$tmp"' EXIT printf 'Run the script.\n' > "$tmp/clean.org" printf 'We cannot stop; we must go.\n' > "$tmp/dirty.org" lint() { emacs --batch -Q -l "$dir/ste-lint.el" -f ste-lint-batch "$1" 2>/dev/null } if ! lint "$tmp/clean.org"; then echo "Error: the batch command failed on a clean file." >&2 exit 1 fi if lint "$tmp/dirty.org"; then echo "Error: the batch command passed a file with an ERROR finding." >&2 exit 1 fi echo "STE linter tests passed."