test(config): verify Vim/Neovim config payload parity
Expose the init_options payload builders publicly in both clients
(M.init_options/M.server_settings in Lua, nuwiki#lsp#settings() in Vim) so
they can be inspected. Add editor harnesses that dump each client's
server-bound config as deterministic key=value lines and diff against a
shared golden file: nvim == golden and vim == golden together prove the two
clients send identical config. Add a server-side test asserting the Vim flat
shape and the Neovim {nuwiki:{...}} wrapper desugar to the same WikiConfig.
Wire both harnesses into CI.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# development/tests/test-config-vim.sh — Vim counterpart of test-config.sh.
|
||||
#
|
||||
# Runs development/tests/test-config-vim.vim under headless Vim, which dumps
|
||||
# the Vim client's `initialization_options` payload (nuwiki#lsp#settings())
|
||||
# as `key=value` lines, then diffs against the shared golden
|
||||
# config-expected.txt. Matching the same golden the Neovim harness uses is
|
||||
# what proves Vim/Neovim config parity.
|
||||
#
|
||||
# Exit code: 0 when the payload matches the golden, 1 otherwise. Skips
|
||||
# (exit 0) when vim is not installed.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
log() { printf '\033[1;34m[config-vim]\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-config-vim-test-XXXXXX)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
GOLDEN="$REPO_ROOT/development/tests/config-expected.txt"
|
||||
OUT="$TMP/vim-config.txt"
|
||||
|
||||
VIMRC="$TMP/vimrc"
|
||||
cat > "$VIMRC" <<EOF
|
||||
set nocompatible
|
||||
let &runtimepath = '$REPO_ROOT' . ',' . &runtimepath
|
||||
filetype plugin indent on
|
||||
EOF
|
||||
|
||||
log 'running Vim config harness…'
|
||||
# `</dev/null` so ex-mode doesn't hang on stdin; `timeout` guards CI.
|
||||
NUWIKI_CONFIG_OUT="$OUT" \
|
||||
timeout 30 vim -e -s -u "$VIMRC" \
|
||||
-c "source $REPO_ROOT/development/tests/test-config-vim.vim" \
|
||||
</dev/null >"$TMP/vim.log" 2>&1 || true
|
||||
|
||||
if [[ ! -f "$OUT" ]]; then
|
||||
echo 'config harness produced no output' >&2
|
||||
echo '--- vim log ---' >&2
|
||||
cat "$TMP/vim.log" >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if diff -u "$GOLDEN" "$OUT"; then
|
||||
log 'Vim config payload matches golden ✓'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo 'Vim config payload DIVERGED from golden (see diff above)' >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user