test(config): verify Vim/Neovim config payload parity
CI / cargo fmt --check (push) Successful in 15s
CI / cargo clippy (push) Successful in 27s
CI / cargo test (push) Successful in 30s
CI / editor keymaps (push) Successful in 1m24s

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:
2026-05-30 19:24:20 -03:00
parent 47af0d6c1e
commit b922f0d612
9 changed files with 319 additions and 6 deletions
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# development/tests/test-config.sh — verify the Neovim client builds the
# exact `initialization_options` payload the server expects.
#
# Runs development/tests/test-config.lua under headless Neovim, which dumps
# the server-bound config (wiki_root, file_extension, syntax, log_level,
# wikis[*]) for a default and a sample scenario as `key=value` lines, then
# diffs the result against the shared golden config-expected.txt.
#
# The Vim harness (test-config-vim.sh) diffs against the SAME golden, so a
# green run of both proves Vim/Neovim config parity.
#
# Exit code: 0 when the payload matches the golden, 1 otherwise.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
TMP="$(mktemp -d -t nuwiki-config-test-XXXXXX)"
trap 'rm -rf "$TMP"' EXIT
log() { printf '\033[1;34m[config-test]\033[0m %s\n' "$*"; }
GOLDEN="$REPO_ROOT/development/tests/config-expected.txt"
OUT="$TMP/nvim-config.txt"
# No LSP server needed — we only inspect the payload the client would send.
INIT="$TMP/init.lua"
cat > "$INIT" <<EOF
vim.opt.runtimepath:prepend('$REPO_ROOT')
EOF
log 'running Neovim config harness…'
NUWIKI_CONFIG_OUT="$OUT" \
timeout 30 nvim --clean -u "$INIT" --headless \
-c "luafile $REPO_ROOT/development/tests/test-config.lua" \
>"$TMP/nvim.log" 2>&1 || true
if [[ ! -f "$OUT" ]]; then
echo 'config harness produced no output' >&2
echo '--- nvim log ---' >&2
cat "$TMP/nvim.log" >&2 || true
exit 1
fi
if diff -u "$GOLDEN" "$OUT"; then
log 'Neovim config payload matches golden ✓'
exit 0
fi
echo 'Neovim config payload DIVERGED from golden (see diff above)' >&2
exit 1