#!/usr/bin/env bash # # development/tests/test-global-shorthand.sh — Neovim client global-shorthand # folding (vimwiki-style per-wiki defaults). Runs test-global-shorthand.lua # under headless Neovim; that script asserts the init_options payload folds a # top-level / g:nuwiki_* setting into every wiki, lets a per-wiki value # override it, and does NOT fold built-in defaults. # # Exit code: 0 when every check passes, 1 on any FAIL or missing output. # Skips (exit 0) when nvim is not installed. set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" log() { printf '\033[1;34m[global-shorthand]\033[0m %s\n' "$*"; } if ! command -v nvim >/dev/null 2>&1; then log 'nvim not installed — skipping' exit 0 fi TMP="$(mktemp -d -t nuwiki-gs-test-XXXXXX)" trap 'rm -rf "$TMP"' EXIT OUT="$TMP/gs.out" INIT="$TMP/init.lua" cat > "$INIT" <"$TMP/nvim.log" 2>&1 || true if [[ ! -f "$OUT" ]]; then echo 'global-shorthand harness produced no output' >&2 echo '--- nvim log ---' >&2 cat "$TMP/nvim.log" >&2 || true exit 1 fi cat "$OUT" PASSED="$(grep -c '^PASS ' "$OUT" || true)" FAILED="$(grep -c '^FAIL ' "$OUT" || true)" echo "SUMMARY: ${PASSED} passed, ${FAILED} failed" if [[ "$FAILED" -ne 0 ]]; then exit 1 fi log 'global shorthand OK ✓' exit 0