Files
LLeMbas-TTY/scripts/test-lua.sh
T
HomerandClaude Fable 5.2 6f1d304fd7 The LLeMbas layer's tests, without a terminal
llembas/tests/run.lua runs the layer against a stand-in for the terminal;
scripts/test-lua.sh runs it with lua5.4, lua, luajit or nvim -l.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-01 19:15:13 +00:00

34 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run the tests of the LLeMbas layer (llembas/tests/run.lua) with whatever Lua is here:
# lua5.4 (what the terminal embeds), else lua, luajit, or Neovim's LuaJIT (`nvim -l`).
#
# scripts/test-lua.sh the first one found
# scripts/test-lua.sh --all every one found (CI: 5.4 and LuaJIT must agree)
# LUA="lua5.4" scripts/test-lua.sh
set -euo pipefail
cd "$(dirname "$0")/.."
tmp="$(mktemp -d)"
trap 'rm -rf "${tmp:?}"' EXIT
found=()
if [ -n "${LUA:-}" ]; then
found=("$LUA")
else
for c in lua5.4 lua luajit; do
command -v "$c" >/dev/null 2>&1 && found+=("$c")
done
command -v nvim >/dev/null 2>&1 && found+=("nvim -l")
fi
[ "${#found[@]}" -gt 0 ] || { echo "test-lua: no Lua here (lua5.4, lua, luajit or nvim)" >&2; exit 2; }
[ "${1:-}" = "--all" ] || found=("${found[0]}")
n=0
for lua in "${found[@]}"; do
echo "test-lua: $lua"
n=$((n + 1))
mkdir "$tmp/run$n"
# shellcheck disable=SC2086 # "nvim -l" is two words on purpose
LLEMBAS_TEST_TMP="$tmp/run$n" $lua llembas/tests/run.lua
done