Files

60 lines
1.6 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
#
# development/tests/test-vimwiki-compat-vim.sh — upstream-vimwiki config
# drop-in compatibility for the Vim client.
#
# Runs test-vimwiki-compat-vim.vim under headless Vim; that script sets an
# upstream `g:vimwiki_list` + `g:vimwiki_*` config and asserts
# nuwiki#lsp#settings() translates it into the server's schema (per-wiki key
# remap + global scalar settings folded into each wiki). Also checks that
# nuwiki-native config takes precedence.
#
# Exit code: 0 when every check passes, 1 on any FAIL or missing output.
# Skips (exit 0) when vim is not installed.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
log() { printf '\033[1;34m[vimwiki-compat]\033[0m %s\n' "$*"; }
if ! command -v vim >/dev/null 2>&1; then
log 'vim not installed — skipping'
exit 0
fi
TMP="$(mktemp -d -t nuwiki-vwc-test-XXXXXX)"
trap 'rm -rf "$TMP"' EXIT
OUT="$TMP/vwc.out"
VIMRC="$TMP/vimrc"
cat > "$VIMRC" <<EOF
set nocompatible
let &runtimepath = '$REPO_ROOT' . ',' . &runtimepath
EOF
log 'running Vim vimwiki-compat harness…'
NUWIKI_VWC_OUT="$OUT" \
timeout 30 vim -e -s -u "$VIMRC" \
-c "source $REPO_ROOT/development/tests/test-vimwiki-compat-vim.vim" \
</dev/null >"$TMP/vim.log" 2>&1 || true
if [[ ! -f "$OUT" ]]; then
echo 'vimwiki-compat harness produced no output' >&2
echo '--- vim log ---' >&2
cat "$TMP/vim.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 'vimwiki config compat OK ✓'
exit 0