#!/bin/sh # The Neovim plugin's tests: headless, against the stand-in agent (tests/fake_agent.py) and, when its # source is at hand, the LLeMbas CLI itself. Needs nvim 0.10+ and python3. # # scripts/test-nvim.sh all of them # scripts/test-nvim.sh rules the rules both editors keep, against tests/rules/ # scripts/test-nvim.sh plugin the plugin on its own: chat, rewrite, suggestions, sign-in # scripts/test-nvim.sh layout the bars: top, bottom, tree, right bar, keys, what is remembered # # Nothing of this machine's own Neovim is read or written: the state, data, cache and configuration # directories are temporary ones, removed on every way out. set -eu cd "$(dirname "$0")/.." WORK="$(mktemp -d "${TMPDIR:-/tmp}/llembas-nvim-test.XXXXXX")" trap 'rm -rf "$WORK"' EXIT trap 'exit 130' INT trap 'exit 143' TERM mkdir -p "$WORK/state" "$WORK/data" "$WORK/cache" "$WORK/config" export XDG_STATE_HOME="$WORK/state" XDG_DATA_HOME="$WORK/data" XDG_CACHE_HOME="$WORK/cache" XDG_CONFIG_HOME="$WORK/config" export LLEMBAS_NVIM_TEST_WORK="$WORK" # The terminal these tests run in says nothing about itself to the plugin. unset LLEMBAS_TERM LLEMBAS_TTY TMUX STY ZELLIJ KITTY_WINDOW_ID GHOSTTY_RESOURCES_DIR TERM_PROGRAM export TERM=dumb which="${1:-all}" status=0 if [ "$which" = all ] || [ "$which" = rules ]; then # The rules both editors keep, against the shared cases in tests/rules/. nvim --headless -u NONE -i NONE --cmd "set rtp+=nvim" -l nvim/tests/rules.lua || status=$? fi if [ "$which" = all ] || [ "$which" = plugin ]; then nvim --headless -u NONE -i NONE --cmd "set rtp+=nvim" -l nvim/tests/run.lua || status=$? fi if [ "$which" = all ] || [ "$which" = layout ]; then # With a screen (no -l): the bars are read from what is drawn. nvim --headless -u NONE -i NONE --cmd "set rtp+=nvim" -c "luafile nvim/tests/layout.lua" || status=$? fi exit "$status"