#!/usr/bin/env bash # The tests of the LLeMbas IDE distribution (ide/): the scripts, a dry run, real installs into # temporary homes, a headless start checked from the inside, updating in place, failing without # leaving anything half-done, and uninstalling. # # scripts/test-ide.sh everything: also downloads the pinned Neovim (about 12 MB, its # SHA-256 checked) and compiles the Treesitter grammars, twice # scripts/test-ide.sh --quick no download and no compiling: the Neovim on this machine and # its bundled grammars only # scripts/test-ide.sh --update-readme rewrite the key table in ide/README.md from the key map # # Needs bash, git, curl, tar, shellcheck, python3 and a Neovim 0.10 or newer on PATH (or in # IDE_TEST_NVIM): the oldest supported one is what the installed IDE is also run on. # The plugins are fetched from GitHub at their pinned commits; LLEMBAS_IDE_GIT_MIRROR (a # directory of clones) spares the network. Nothing is written outside a temporary directory, # which is removed on every way out. # shellcheck disable=SC2016 # the small scripts given to bash -c are single-quoted on purpose set -euo pipefail cd "$(dirname "$0")/.." REPO="$PWD" QUICK=0 case "${1:-}" in --quick) QUICK=1 ;; --update-readme) nvim --headless -u NONE --cmd "set rtp+=ide/config" \ -c 'lua io.stdout:write(table.concat(require("llembas_ide.keys").markdown(), "\n"))' -c q >ide/README.keys.tmp python3 - <<'PY' import re from pathlib import Path keys = Path("ide/README.keys.tmp").read_text(encoding="utf-8").strip() readme = Path("ide/README.md") text = readme.read_text(encoding="utf-8") text = re.sub(r"\n.*?", lambda _: "\n" + keys + "\n", text, flags=re.S) readme.write_text(text, encoding="utf-8") PY rm -f ide/README.keys.tmp echo "test-ide: ide/README.md has the key map's table" exit 0 ;; "") ;; *) echo "test-ide: unknown option $1" >&2 && exit 2 ;; esac SYSTEM_NVIM="${IDE_TEST_NVIM:-$(command -v nvim || true)}" [ -n "$SYSTEM_NVIM" ] || { echo "test-ide: needs a Neovim on PATH (or IDE_TEST_NVIM)" >&2 && exit 2; } VERSION="$(tr -d '[:space:]' &1)"; then ok "$name"; else fail "$name" "$out"; fi } # attempt command… runs it; its output is in OUT and its exit status in RC OUT="" RC=0 attempt() { if OUT="$("$@" 2>&1)"; then RC=0; else RC=$?; fi } passes() { if [ "$RC" = 0 ]; then ok "$1"; else fail "$1" "$OUT"; fi; } refuses() { if [ "$RC" != 0 ]; then ok "$1"; else fail "$1" "$OUT"; fi; } has() { grep -q -F -- "$2" <<<"$1"; } expect() { # expect "name" "text" "needle" if has "$2" "$3"; then ok "$1"; else fail "$1" "wanted: $3 $2"; fi } # PATH without any LLeMbas CLI of this machine: the tests decide whether there is one. CLEAN_PATH="" IFS=: read -r -a parts <<<"$PATH" for d in "${parts[@]}"; do if [ -n "$d" ] && [ ! -x "$d/lembas" ]; then CLEAN_PATH="${CLEAN_PATH:+$CLEAN_PATH:}$d"; fi done BG_DARK="$(sed -n '/data-theme="moria"/,/}/s/^ *--bg: *\(#[0-9A-Fa-f]*\);.*/\1/p' ide/tokens.css)" BG_LIGHT="$(sed -n '/data-theme="shire"/,/}/s/^ *--bg: *\(#[0-9A-Fa-f]*\);.*/\1/p' ide/tokens.css)" # Run something as a person whose home is $1, with nothing of this machine's environment. as() { local home="$1" shift env -i PATH="$home/.local/bin:${EXTRA_PATH:+$EXTRA_PATH:}$CLEAN_PATH" HOME="$home" TERM=dumb LANG=C.UTF-8 LLEMBAS_IDE_PUBKEY= \ ${LLEMBAS_IDE_GIT_MIRROR:+LLEMBAS_IDE_GIT_MIRROR="$LLEMBAS_IDE_GIT_MIRROR"} "$@" } installer() { # installer local home="$1" shift as "$home" bash "$REPO/ide/install.sh" --no-cli "$@" 2>&1 } # The headless checks, through the launcher. headless [VAR=value…] headless() { local home="$1" parsers="$2" shift 2 (cd "$WORK" && as "$home" env IDE_TEST_REPO="$REPO" IDE_TEST_PARSERS="$parsers" IDE_TEST_BG_DARK="$BG_DARK" \ IDE_TEST_BG_LIGHT="$BG_LIGHT" "$@" timeout 120 "$home/.local/bin/llembas-ide" --headless \ -c "luafile $REPO/ide/tests/headless.lua" 2>&1) } typing() { # the completion menu, through the launcher local home="$1" out out="$( (cd "$WORK" && as "$home" timeout 60 "$home/.local/bin/llembas-ide" --headless -c "luafile $REPO/ide/tests/typing.lua" 2>&1) || true)" if grep -q -F 'ide-typing: the menu opens' <<<"$out"; then ok "$2"; else fail "$2" "$out"; fi } report_headless() { # report_headless "name" "output" local line line="$(grep -o -E 'ide-headless: [0-9]+ passed, 0 failed.*' <<<"$2" || true)" if [ -n "$line" ]; then ok "$1: ${line#ide-headless: }"; else fail "$1" "$2"; fi } startup_ms() { # the best of three starts, in milliseconds local home="$1" best="" ms i for i in 1 2 3; do rm -f "$WORK/startup.$i" as "$home" "$home/.local/bin/llembas-ide" --headless --startuptime "$WORK/startup.$i" -c 'qa!' >/dev/null 2>&1 || true ms="$(grep -F 'NVIM STARTED' "$WORK/startup.$i" 2>/dev/null | tail -n1 | awk '{ print $1 + 0 }')" if [ -n "$ms" ] && { [ -z "$best" ] || awk -v a="$ms" -v b="$best" 'BEGIN { exit !(a < b) }'; }; then best="$ms"; fi done echo "${best:-?}" } files_in() { (cd "$1" && find . -type f -o -type l | sort); } # A copy of what a release carries, to break on purpose. payload_copy() { local to="$1" mkdir -p "$to" git ls-files -z -- VERSION LICENSE ide nvim | while IFS= read -r -d '' f; do mkdir -p "$to/$(dirname "$f")" cp -p "$f" "$to/$f" done } # --- 1. the files themselves ------------------------------------------------------------------- echo "The scripts and the pins" check "shellcheck: install.sh, the launcher, the packaging and test scripts" \ shellcheck ide/install.sh ide/bin/llembas-ide scripts/package-ide.sh scripts/test-ide.sh check "the colourscheme is what the tokens give" python3 scripts/gen-ide-theme.py --check check "install.sh runs nothing until its last line" bash -c '[ "$(tail -n1 ide/install.sh)" = "main \"\$@\"" ]' check "no sudo anywhere in the scripts" bash -c '! grep -n -w sudo ide/install.sh ide/bin/llembas-ide' check "no colour is written outside the generated theme" \ bash -c '! grep -rn -E "#[0-9A-Fa-f]{6}\b" ide/config/init.lua ide/config/lua' check "every plugin is pinned to a full commit over https, under MIT, Apache-2.0, BSD or ISC" \ bash -c 'grep -v -E "^\s*(#|$)" ide/plugins.lock | awk "{ if (\$3 !~ /^https:\/\/github\.com\// || \$4 !~ /^[0-9a-f]{40}\$/ || \$5 !~ /^(MIT|Apache-2\.0|BSD-[23]-Clause|ISC)\$/) { print; bad = 1 } } END { exit bad }"' check "every grammar is pinned to a full commit over https, under MIT, Apache-2.0, BSD or ISC" \ bash -c 'grep -v -E "^\s*(#|$)" ide/parsers.lock | awk "{ if (\$2 !~ /^https:\/\/github\.com\// || \$3 !~ /^[0-9a-f]{40}\$/ || \$5 !~ /^(MIT|Apache-2\.0|BSD-[23]-Clause|ISC)\$/) { print; bad = 1 } } END { exit bad }"' check "THIRD_PARTY.md names every pinned commit" \ bash -c 'for c in $(grep -v -E "^\s*(#|$)" ide/plugins.lock | awk "{ print \$4 }") $(grep -v -E "^\s*(#|$)" ide/parsers.lock | awk "{ print \$3 }"); do grep -q "$c" ide/THIRD_PARTY.md || { echo "missing $c"; exit 1; }; done' check "Neovim is pinned with a SHA-256 for each of the four platforms" \ bash -c '[ "$(grep -c -E "^[0-9a-f]{64} nvim-(linux|macos)-(x86_64|arm64)\.tar\.gz$" ide/neovim.sha256)" = 4 ] && grep -q -E "^[0-9]+\.[0-9]+\.[0-9]+$" ide/neovim.version' check "nothing private in the tracked files" scripts/hygiene.sh check "the Lua of the configuration parses" \ bash -c 'for f in ide/config/init.lua ide/config/colors/llembas.lua ide/config/lua/llembas_ide/*.lua ide/user-init.lua ide/tests/headless.lua; do "$0" --headless -u NONE -c "lua local f, e = loadfile([[$f]]); if not f then io.stdout:write(e) vim.cmd([[cquit 1]]) end" -c q || exit 1; done' "$SYSTEM_NVIM" # --- 2. a dry run ------------------------------------------------------------------------------ echo "A dry run" A="$WORK/a" mkdir -p "$A" out="$(installer "$A" --from-checkout --dry-run || true)" expect "says it is a dry run" "$out" "dry run: nothing is downloaded or written" case "$(uname -s)-$(uname -m)" in Linux-x86_64) ASSET=nvim-linux-x86_64 ;; Linux-aarch64 | Linux-arm64) ASSET=nvim-linux-arm64 ;; Darwin-arm64) ASSET=nvim-macos-arm64 ;; *) ASSET=nvim-macos-x86_64 ;; esac expect "names the pinned Neovim's address" "$out" "download https://github.com/neovim/neovim/releases/download/v$(cat ide/neovim.version)/$ASSET.tar.gz" expect "and its checksum" "$out" "check its SHA-256 is $(awk -v f="$ASSET.tar.gz" '$2 == f { print $1 }' ide/neovim.sha256)" while read -r name _ url commit _; do expect "names $name, its source and its commit" "$out" "fetch $name from $url at commit $commit" done < <(grep -v -E '^\s*(#|$)' ide/plugins.lock) expect "names the staging and the swap" "$out" "would swap the staged nvim/, site/pack/llembas/ and lib/ into $A/.local/share/llembas-ide" expect "names the launcher" "$out" "would write the launcher $A/.local/bin/llembas-ide" expect "names the person's own file" "$out" "would create $A/.config/llembas-ide/lua/user/init.lua" expect "names the menu entry" "$out" "would write the menu entry $A/.local/share/applications/llembas-ide.desktop" if [ -z "$(find "$A" -mindepth 1 | head -n1)" ]; then ok "writes nothing"; else fail "writes nothing" "$(find "$A" -mindepth 1 | head)"; fi out="$(as "$A" bash "$REPO/ide/install.sh" --from-checkout --dry-run 2>&1 || true)" expect "with the CLI missing, offers the CLI's own installer" "$out" "offer to install the LLeMbas CLI (beta) with its own installer" out="$(as "$A" bash "$REPO/ide/install.sh" --dry-run --version 9.9.9 2>&1 || true)" expect "from a release: names the archive and the checksum check" "$out" "releases/download/v9.9.9/llembas-ide-9.9.9.tar.gz" out="$(installer "$A" --from-checkout --prefix relative/dir 2>&1 || true)" expect "a relative --prefix is refused in words" "$out" "--prefix must be an absolute path" out="$(installer "$A" --from-checkout --nvim-bin /bin/true 2>&1 || true)" expect "a --nvim-bin that is not Neovim 0.10 or newer is refused in words" "$out" "older than Neovim 0.10" out="$(as "$A" bash -c 'cat "$1" | bash -s -- --from-checkout' _ "$REPO/ide/install.sh" 2>&1 || true)" expect "piped into bash, --from-checkout is refused in words" "$out" "--from-checkout needs this script run as a file" if [ -z "$(find "$A" -mindepth 1 | head -n1)" ]; then ok "refusals write nothing"; else fail "refusals write nothing" "$(find "$A" -mindepth 1 | head)"; fi # --- 3. a real install, with the Neovim of this machine and its bundled grammars --------------- echo "A real install (the Neovim on this machine: $("$SYSTEM_NVIM" --version | head -n1), bundled grammars)" attempt installer "$A" --from-checkout --nvim-bin "$SYSTEM_NVIM" --no-parsers out="$OUT" passes "installs" expect "says so" "$out" "LLeMbas IDE $VERSION is installed" P="$A/.local/share/llembas-ide" check "the launcher, the configuration, the person's file, the menu entry and the icon are there" \ test -x "$A/.local/bin/llembas-ide" -a -f "$A/.config/llembas-ide/init.lua" -a -f "$A/.config/llembas-ide/lua/user/init.lua" \ -a -f "$A/.local/share/applications/llembas-ide.desktop" -a -f "$A/.local/share/icons/hicolor/256x256/apps/llembas-ide.png" check "the menu entry is a terminal application with the IDE's name" \ bash -c 'grep -q "^Terminal=true$" "$1" && grep -q "^Name=LLeMbas IDE$" "$1" && grep -q "^Icon=llembas-ide$" "$1"' _ "$A/.local/share/applications/llembas-ide.desktop" stray="$(files_in "$A" | grep -v -E '^\./(\.local/share/llembas-ide/|\.config/llembas-ide/|\.local/bin/llembas-ide$|\.local/share/applications/llembas-ide\.desktop$|\.local/share/icons/hicolor/256x256/apps/llembas-ide\.png$|\.local/state/llembas-ide/|\.cache/llembas-ide/)' || true)" if [ -z "$stray" ]; then ok "nothing is written outside the IDE's own places"; else fail "nothing is written outside the IDE's own places" "$stray"; fi check "no ~/.config/nvim is made" test ! -e "$A/.config/nvim" if [ -z "$(find "$P" -maxdepth 1 \( -name '.staging.*' -o -name '.old.*' \) | head -n1)" ]; then ok "no staging directory is left"; else fail "no staging directory is left"; fi out="$(as "$A" "$A/.local/bin/llembas-ide" --version 2>&1 || true)" expect "--version: the IDE" "$out" "LLeMbas IDE $VERSION" expect "--version: Neovim" "$out" "Neovim $("$SYSTEM_NVIM" --version | sed -n '1s/^NVIM v//p')" expect "--version: the plugin" "$out" "LLeMbas plugin $VERSION" report_headless "headless start, from the inside" "$(headless "$A" 0 IDE_TEST_FIRST=1 || true)" typing "$A" "typing: the completion menu opens with the buffer's words, and stays LLeMbas's" attempt as "$A" "$A/.local/bin/llembas-ide" doctor out="$OUT" passes "doctor finds the installation sound" expect "doctor: plugins at their pins" "$out" "ok mini.nvim $(awk '$1 == "mini.nvim" { print substr($4, 1, 12) }' ide/plugins.lock)" expect "doctor: says what is off without compiled grammars" "$out" "Treesitter grammars are not compiled" expect "doctor: says the CLI is missing and the editor works" "$out" "the LLeMbas CLI (lembas) is not installed" expect "doctor: a clean headless start" "$out" "every part of the IDE loads" START_A="$(startup_ms "$A")" ok "startup, best of three: ${START_A} ms" out="$(as "$A" "$A/.local/bin/llembas-ide" --headless -c 'lua io.stdout:write(vim.env.NVIM_APPNAME .. " " .. vim.fn.argv(0))' -c 'qa!' some-file.txt 2>&1 || true)" expect "arguments go through to Neovim" "$out" "llembas-ide some-file.txt" # --- 4. again: an update in place -------------------------------------------------------------- echo "Installing again" echo 'vim.g.llembas_ide_test_user = 42' >>"$A/.config/llembas-ide/lua/user/init.lua" # A plugin of the person's own, in the directory the README names. mkdir -p "$A/.config/llembas-ide/pack/user/start/mine/plugin" echo 'vim.g.llembas_ide_test_plugin = "loaded"' >"$A/.config/llembas-ide/pack/user/start/mine/plugin/mine.lua" user_before="$(sha256sum "$A/.config/llembas-ide/lua/user/init.lua")" attempt installer "$A" --from-checkout --nvim-bin "$SYSTEM_NVIM" --no-parsers out="$OUT" passes "installs over itself" if [ "$(grep -c 'already installed, unchanged' <<<"$out")" = "$(grep -c -v -E '^\s*(#|$)' ide/plugins.lock)" ]; then ok "keeps every plugin that is at its pin"; else fail "keeps every plugin that is at its pin" "$out"; fi expect "keeps the person's own file" "$out" "keep your $A/.config/llembas-ide/lua/user/init.lua as it is" if [ "$(sha256sum "$A/.config/llembas-ide/lua/user/init.lua")" = "$user_before" ]; then ok "the person's own file is byte for byte the same"; else fail "the person's own file is byte for byte the same"; fi report_headless "headless start again, with the person's file saying something" "$(headless "$A" 0 IDE_TEST_USER=1 || true)" echo '-- mine' >>"$A/.config/llembas-ide/init.lua" out="$(installer "$A" --from-checkout --nvim-bin "$SYSTEM_NVIM" --no-parsers || true)" expect "an init.lua the person edited is kept" "$out" "keep your edited $A/.config/llembas-ide/init.lua" check "and the IDE's own lies beside it" bash -c 'grep -q "^-- mine$" "$1/init.lua" && cmp -s "$1/init.lua.new" ide/config/init.lua' _ "$A/.config/llembas-ide" cp ide/config/init.lua "$A/.config/llembas-ide/init.lua" rm -f "$A/.config/llembas-ide/init.lua.new" # A plugin somebody changed is fetched again, not trusted. echo '-- changed' >>"$P/site/pack/llembas/start/conform.nvim/lua/conform/init.lua" out="$(as "$A" "$A/.local/bin/llembas-ide" doctor 2>&1 || true)" expect "doctor: a plugin whose files were changed is a failure" "$out" "FAIL conform.nvim is at its pin but its files were changed" out="$(installer "$A" --from-checkout --nvim-bin "$SYSTEM_NVIM" --no-parsers || true)" expect "the installer fetches that plugin again" "$out" "fetch conform.nvim from" check "and doctor is content" as "$A" "$A/.local/bin/llembas-ide" doctor # --- 5. failing without leaving anything half-done ---------------------------------------------- echo "Failures" before="$(files_in "$A" | grep -v -E '/(\.local/state|\.cache)/' | sha256sum)" payload_copy "$WORK/broken" echo 'error("broken on purpose")' >>"$WORK/broken/ide/config/lua/llembas_ide/options.lua" attempt as "$A" bash "$WORK/broken/ide/install.sh" --no-cli --from-dir "$WORK/broken" --nvim-bin "$SYSTEM_NVIM" --no-parsers out="$OUT" refuses "a configuration that does not start is refused" expect "in words" "$out" "the staged IDE did not start" expect "and says nothing was installed" "$out" "nothing installed" payload_copy "$WORK/wrongpin" sed -i -E 's/^(conform\.nvim .*)[0-9a-f]{6}( +MIT)/\1000000\2/' "$WORK/wrongpin/ide/plugins.lock" attempt as "$A" bash "$WORK/wrongpin/ide/install.sh" --no-cli --from-dir "$WORK/wrongpin" --nvim-bin "$SYSTEM_NVIM" --no-parsers out="$OUT" refuses "a commit that cannot be fetched stops the install" expect "in words" "$out" "could not fetch https://github.com/stevearc/conform.nvim at" if [ "$(files_in "$A" | grep -v -E '/(\.local/state|\.cache)/' | sha256sum)" = "$before" ]; then ok "after both, the installation has exactly the files it had"; else fail "after both, the installation has exactly the files it had"; fi if [ -z "$(find "$P" -maxdepth 1 \( -name '.staging.*' -o -name '.old.*' \) | head -n1)" ]; then ok "and no staging directory is left"; else fail "and no staging directory is left"; fi check "and it still starts" as "$A" "$A/.local/bin/llembas-ide" doctor E="$WORK/empty" mkdir -p "$E" out="$(as "$E" bash "$WORK/broken/ide/install.sh" --no-cli --from-dir "$WORK/broken" --nvim-bin "$SYSTEM_NVIM" --no-parsers 2>&1 || true)" left="$(files_in "$E")$(cd "$E" && find . -mindepth 1 -type d -name '*llembas*')" if [ -z "$left" ]; then ok "a failed first install leaves no file and no directory of the IDE's"; else fail "a failed first install leaves no file and no directory of the IDE's" "$left"; fi # --- 6. with a LLeMbas CLI on PATH (a stand-in) ------------------------------------------------- echo "With a LLeMbas CLI" mkdir -p "$WORK/cli/bin" "$WORK/cli/config" cat >"$WORK/cli/bin/lembas" <&1 || true)" expect "doctor: finds it and its version" "$out" "LLeMbas CLI 2.0.0-beta.99" expect "doctor: not signed in" "$out" "not signed in: lembas login" printf '{ "instances": { "home": { "base_url": "https://llembas.example.org" } } }\n' >"$WORK/cli/config/lembas.json" out="$(EXTRA_PATH="$WORK/cli/bin" as "$A" "$A/.local/bin/llembas-ide" doctor 2>&1 || true)" expect "doctor: signed in" "$out" "signed in to a LLeMbas server" out="$(EXTRA_PATH="$WORK/cli/bin" as "$A" bash "$REPO/ide/install.sh" --from-checkout --dry-run 2>&1 || true)" expect "the installer leaves an installed CLI alone" "$out" "leave the LLeMbas CLI alone: it is installed" out="$(EXTRA_PATH="$WORK/cli/bin" as "$A" "$A/.local/bin/llembas-ide" --headless \ -c 'lua local t, live = require("llembas_ide.llembas").status(); io.stdout:write(t .. " live=" .. tostring(live))' -c 'qa!' 2>&1 || true)" expect "the statusline shows LLeMbas and that suggestions are on" "$out" "◈ LLeMbas · suggest on live=true" # --- 7. a release: packaged, checked, installed with the pinned Neovim and compiled grammars ---- echo "A release" check "package-ide.sh writes the release files" scripts/package-ide.sh REL="$WORK/rel" mkdir -p "$REL/v$VERSION" cp "dist/llembas-ide-$VERSION.tar.gz" dist/install.sh dist/SHA256SUMS "$REL/v$VERSION/" check "SHA256SUMS lists the archive and the installer, and they match" \ bash -c 'cd "$1" && sha256sum -c --quiet SHA256SUMS && grep -q " install.sh$" SHA256SUMS && grep -q " llembas-ide-.*\.tar\.gz$" SHA256SUMS' _ "$REL/v$VERSION" check "the release's install.sh is the repository's" cmp -s "$REL/v$VERSION/install.sh" ide/install.sh check "the archive holds the installer, the configuration, the plugin and no tests" \ bash -c 't="$(tar -tzf "$1")"; for f in ide/install.sh ide/plugins.lock ide/config/init.lua nvim/plugin/llembas.lua VERSION LICENSE; do grep -q "^llembas-ide-$2/$f$" <<<"$t" || { echo "missing $f"; exit 1; }; done; ! grep -q "/tests/" <<<"$t"' _ "$REL/v$VERSION/llembas-ide-$VERSION.tar.gz" "$VERSION" B="$WORK/b" C="$WORK/c" mkdir -p "$B" "$C" # Tampered with: one byte of the archive changed. mkdir -p "$WORK/bad/v$VERSION" cp "$REL/v$VERSION"/* "$WORK/bad/v$VERSION/" printf 'x' >>"$WORK/bad/v$VERSION/llembas-ide-$VERSION.tar.gz" attempt as "$C" env LLEMBAS_IDE_RELEASE_BASE="file://$WORK/bad" bash "$REL/v$VERSION/install.sh" --no-cli --version "$VERSION" --nvim-bin "$SYSTEM_NVIM" --no-parsers out="$OUT" refuses "an archive that does not match SHA256SUMS is refused" expect "in words" "$out" "does not match SHA256SUMS — nothing installed" out="$(as "$C" env LLEMBAS_IDE_RELEASE_BASE="http://example.org/releases" bash "$REL/v$VERSION/install.sh" --no-cli --version "$VERSION" 2>&1 || true)" expect "a release over plain http is refused" "$out" "only https://" # Signed releases: a key made here, for this test only. ssh-keygen -q -t ed25519 -N '' -C test -f "$WORK/key" >/dev/null ssh-keygen -q -t ed25519 -N '' -C other -f "$WORK/otherkey" >/dev/null out="$(as "$C" env LLEMBAS_IDE_RELEASE_BASE="file://$REL" LLEMBAS_IDE_PUBKEY="$(cut -d' ' -f1,2 "$WORK/key.pub")" bash "$REL/v$VERSION/install.sh" --no-cli --version "$VERSION" --nvim-bin "$SYSTEM_NVIM" --no-parsers 2>&1 || true)" expect "with a release key set, an unsigned release is refused" "$out" "the release is not signed" ssh-keygen -Y sign -q -f "$WORK/otherkey" -n lembas-release "$REL/v$VERSION/SHA256SUMS" 2>/dev/null out="$(as "$C" env LLEMBAS_IDE_RELEASE_BASE="file://$REL" LLEMBAS_IDE_PUBKEY="$(cut -d' ' -f1,2 "$WORK/key.pub")" bash "$REL/v$VERSION/install.sh" --no-cli --version "$VERSION" --nvim-bin "$SYSTEM_NVIM" --no-parsers 2>&1 || true)" expect "one signed with another key is refused" "$out" "SHA256SUMS is not signed by the release key" if [ -z "$(find "$C" -mindepth 1 | head -n1)" ]; then ok "every refusal leaves nothing behind"; else fail "every refusal leaves nothing behind" "$(find "$C" -mindepth 1 | head)"; fi rm -f "$REL/v$VERSION/SHA256SUMS.sig" ssh-keygen -Y sign -q -f "$WORK/key" -n lembas-release "$REL/v$VERSION/SHA256SUMS" 2>/dev/null if [ "$QUICK" = 1 ]; then attempt as "$B" env LLEMBAS_IDE_RELEASE_BASE="file://$REL" LLEMBAS_IDE_PUBKEY="$(cut -d' ' -f1,2 "$WORK/key.pub")" bash "$REL/v$VERSION/install.sh" --no-cli --version "$VERSION" --nvim-bin "$SYSTEM_NVIM" --no-parsers out="$OUT" passes "installs from the release (quick: this machine's Neovim, bundled grammars)" expect "its signature is checked" "$out" "signature good (release key)" expect "its checksum is checked" "$out" "checksum good" report_headless "headless start of the release's install" "$(headless "$B" 0 IDE_TEST_FIRST=1 || true)" else attempt as "$B" env LLEMBAS_IDE_RELEASE_BASE="file://$REL" LLEMBAS_IDE_PUBKEY="$(cut -d' ' -f1,2 "$WORK/key.pub")" bash "$REL/v$VERSION/install.sh" --no-cli --version "$VERSION" out="$OUT" passes "installs from the release, with the pinned Neovim downloaded and the grammars compiled" expect "its signature is checked" "$out" "signature good (release key)" expect "its checksum is checked" "$out" "checksum good" expect "Neovim's SHA-256 is checked before unpacking" "$out" "check its SHA-256 is" expect "the grammars are compiled" "$out" "compiled $(grep -c -v -E '^\s*(#|$)' ide/parsers.lock) Treesitter grammars" out="$(as "$B" "$B/.local/bin/llembas-ide" --version 2>&1 || true)" expect "the installed Neovim is the pinned one" "$out" "Neovim $(cat ide/neovim.version)" check "it is the IDE's own copy" test -x "$B/.local/share/llembas-ide/nvim/bin/nvim" report_headless "headless start on the pinned Neovim with compiled grammars" "$(headless "$B" 1 IDE_TEST_FIRST=1 || true)" typing "$B" "typing on the pinned Neovim: the completion menu opens, and stays LLeMbas's" attempt as "$B" "$B/.local/bin/llembas-ide" doctor out="$OUT" passes "doctor finds it sound" expect "doctor: the grammars" "$out" "Treesitter grammars compiled" START_B="$(startup_ms "$B")" ok "startup on the pinned Neovim, best of three: ${START_B} ms" # A Neovim download that is not the pinned bytes. payload_copy "$WORK/wrongsha" sed -i -E 's/^[0-9a-f]{8}/00000000/' "$WORK/wrongsha/ide/neovim.sha256" attempt as "$C" bash "$WORK/wrongsha/ide/install.sh" --no-cli --from-dir "$WORK/wrongsha" --no-parsers out="$OUT" refuses "a Neovim download with another SHA-256 is refused" expect "in words" "$out" "not the pinned" if [ -z "$(find "$C" -mindepth 1 | head -n1)" ]; then ok "and leaves nothing behind"; else fail "and leaves nothing behind" "$(find "$C" -mindepth 1 | head)"; fi # The oldest supported Neovim with the compiled grammars: the first home, updated in place. attempt installer "$A" --from-checkout --nvim-bin "$SYSTEM_NVIM" out="$OUT" passes "the first home takes the compiled grammars in an update" report_headless "headless start on this machine's Neovim with compiled grammars" "$(headless "$A" 1 IDE_TEST_USER=1 || true)" fi attempt as "$B" env LLEMBAS_IDE_RELEASE_BASE="file://$REL" LLEMBAS_IDE_PUBKEY="$(cut -d' ' -f1,2 "$WORK/key.pub")" "$B/.local/bin/llembas-ide" update --no-cli --version "$VERSION" out="$OUT" passes "llembas-ide update runs the installed installer against the release" expect "and keeps what is already there" "$out" "already installed, unchanged" if [ "$QUICK" != 1 ]; then expect "Neovim included" "$out" "keep Neovim $(cat ide/neovim.version)" expect "and the compiled grammars" "$out" "compiled Treesitter grammars (already installed, same pins)" fi # --- 8. somewhere else: --prefix ----------------------------------------------------------------- echo "A prefix of the person's choosing" D="$WORK/d" mkdir -p "$D" attempt installer "$D" --from-checkout --nvim-bin "$SYSTEM_NVIM" --no-parsers --prefix "$WORK/opt/my ide" passes "installs into a directory with a space in its name" check "the IDE is there and not in the default place" test -d "$WORK/opt/my ide/lib" -a ! -e "$D/.local/share/llembas-ide" check "doctor is content" as "$D" "$D/.local/bin/llembas-ide" doctor attempt as "$D" "$D/.local/bin/llembas-ide" uninstall --purge --yes passes "uninstall --purge --yes" if [ -z "$(files_in "$D")" ] && [ ! -e "$WORK/opt/my ide" ]; then ok "leaves nothing, and the prefix is gone"; else fail "leaves nothing, and the prefix is gone" "$(files_in "$D"; ls -la "$WORK/opt")"; fi # --- 9. uninstalling --------------------------------------------------------------------------- echo "Uninstalling" attempt as "$A" "$A/.local/bin/llembas-ide" uninstall --yes out="$OUT" passes "uninstall --yes" left="$(files_in "$A" | tr '\n' ' ')" if [ "$left" = "./.config/llembas-ide/lua/user/init.lua ./.config/llembas-ide/pack/user/start/mine/plugin/mine.lua " ]; then ok "leaves nothing but the person's own file and plugin"; else fail "leaves nothing but the person's own file and plugin" "$left"; fi check "which still has what the person wrote" grep -q 'llembas_ide_test_user = 42' "$A/.config/llembas-ide/lua/user/init.lua" attempt as "$B" "$B/.local/bin/llembas-ide" uninstall --purge --yes out="$OUT" passes "uninstall --purge --yes" left="$(files_in "$B")" if [ -z "$left" ]; then ok "leaves nothing at all"; else fail "leaves nothing at all" "$left"; fi left="$(cd "$B" && find . -mindepth 1 -type d -name '*llembas*')" if [ -z "$left" ]; then ok "not even an empty directory of its own"; else fail "not even an empty directory of its own" "$left"; fi echo echo "test-ide: $PASSED passed, $FAILED failed$([ "$QUICK" = 1 ] && echo ' (quick)')" echo "test-ide: startup ${START_A} ms on $("$SYSTEM_NVIM" --version | head -n1)${START_B:+, ${START_B} ms on the pinned NVIM v$(cat ide/neovim.version) with compiled grammars}" [ "$FAILED" = 0 ]