sagefs.nvim uses two test runners for different types of tests:
Pure Lua tests that don't require Neovim runtime. Run with:
lua run_busted.lua --helper=spec/helper.luaTests live in spec/*.lua and use busted's describe/it/assert API.
These tests mock vim.* APIs via spec/helper.lua.
run_busted.lua carries Windows LuaRocks paths. On Linux and macOS, plain
busted at the repo root is enough: .busted points it at spec/ and at
spec/helper.lua (which mocks vim.*), and skips spec/e2e/. This is the
command the GitHub workflow runs (under Lua 5.1). SageFs's scripts/sync-nvim-version
runs the same suite as its gate before it publishes a plugin release, but through
luajit with the Lua 5.1 LuaRocks tree: the interpreter Neovim itself embeds.
busted # exits non-zero on any failure
nvim --headless --clean -u NONE -l spec/nvim_harness.lua # headless integrationIf busted says module 'busted.runner' not found, LuaRocks is not on the Lua
path of your shell. With several Lua versions installed, pick the tree that
matches the interpreter busted will use, for example:
eval "$(luarocks --lua-version 5.1 path)"Do not add a lua = "..." key to .busted. It makes busted re-run itself through
that interpreter name without the LuaRocks package path, which is exactly the
failure above, and spec/busted_config_spec.lua guards against it.
sagefs.nvim only targets the Lua that Neovim embeds, which is LuaJIT (Lua 5.1
semantics). The specs run under LuaJIT, and the GitHub workflow runs them under
PUC Lua 5.1, so write 5.1 Lua: no //, no goto, no bit operators, no
table.unpack without a fallback to unpack, and no \u{XXXX} string escape
(write the character; spec/lua51_source_spec.lua checks). To run the suite the
way the release hook does, with the Lua 5.1 LuaRocks tree:
rocks="$HOME/.luarocks"
LUA_PATH="$rocks/share/lua/5.1/?.lua;$rocks/share/lua/5.1/?/init.lua;;" \
LUA_CPATH="$rocks/lib/lua/5.1/?.so;;" \
luajit "$rocks"/lib/luarocks/rocks-5.1/busted/*/bin/bustedThe summary line is where the current counts live: busted prints
N successes / N failures / N errors / N pending, the headless harness prints
Results: N passed, N failed. I do not copy those numbers into the README or
into this file, because they change with every spec.
The plugin's version tracks the SageFs release (see "Versions" in the README).
spec/version_spec.lua checks it against a SageFs checkout:
SAGEFS_REPO=~/Work/SageFs busted spec/version_spec.luais strict. It fails whilelua/sagefs/version.luadiffers from that checkout'sDirectory.Build.props, and the fix is./sync-version.sh ~/Work/SageFs.- With no
SAGEFS_REPO, it looks for a checkout at../SageFs(or the same from a git worktree under.worktrees/). Equal versions pass. Different versions make it pending with both numbers, never failing: the release script bumps this plugin after it pushes SageFs and gates the bump on this suite, so a plugin that is one release behind has to stay green. - With no checkout (the GitHub workflow has none) it is pending and says so.
Coverage: SSE parsing, cell boundary detection (;;), model state, transport, rendering, completions, format, diagnostics, etc.
How results are placed in a real window, how an eval is routed by working
directory, :SageFsHelp, the first-run hint and the slow-eval status. They run
in a real headless Neovim with only the daemon transport stubbed (real
windows, real extmarks, real checkouts on disk, including a git worktree):
nvim --headless --clean -u NONE -l spec/nvim_display_harness.luaThe file is self-contained like spec/nvim_harness.lua and exits non-zero on a
failure. It is not named *_spec.lua so busted does not try to load it.
The pure pieces have busted specs: spec/placement_spec.lua (where a result is
drawn, with a seeded generator for the property that it is inside the window),
spec/result_display_spec.lua, spec/pending_spec.lua,
spec/session_routing_spec.lua, spec/help_spec.lua, spec/cells_refine_spec.lua.
Tests requiring Neovim's tree-sitter runtime. Run with:
nvim --headless -l spec/treesitter_cells_spec.luaThese tests use a minimal self-contained harness (no busted dependency)
because they need vim.treesitter, vim.api, and the tree-sitter-fsharp
grammar, none of which are available in busted.
Prerequisite: tree-sitter-fsharp grammar must be installed in Neovim
(TSInstall fsharp).
The spec file includes a guard (if not vim or not vim.opt then return end)
so busted skips it without errors.
Coverage: Tree-sitter cell detection across the fixture files in fixtures/:
fixtures/basic_bindings.fs: simple lets, records, DUs, matchfixtures/complex_expressions.fs: multi-arm match, async CE, seq CEfixtures/attributed_and_typed.fs: attributes, let rec...and, interfacesfixtures/nested_modules.fs: namespace with nested modulesfixtures/type_with_members.fs:type...withmember workaroundfixtures/do_expressions.fs:doexpressions (common in .fsx)
Fixture files in fixtures/ are test data. Do not edit without updating
spec/treesitter_cells_spec.lua - tests assert specific line numbers.
- Transport integration: No test starts a real curl process or connects to a mock SSE server. Transport behavior is tested via mocked callbacks.
- tree-sitter-fsharp
withmembers: The grammar incorrectly parsestype Foo = { ... } with member ...as separate nodes. We work around this intreesitter_cells.lua(seeextract_from_app_expr).
spec/fixtures/wire/ holds payloads captured from a dev SageFs daemon (live
bindings snapshots, click and mode answers, debug hold answers, a
coverage_view replay, file_annotations). The specs that read them say which
parts are real and which are derived by hand from the documented shape (for
example file_annotations_covering_synthetic.json fills in CoveringTests,
which were empty in every payload the daemon sent while I captured).
Running one spec file: with plain busted (Linux and macOS) a path works,
busted spec/debug_test_spec.lua, and so does busted --filter "hint". The
Windows runner run_busted.lua takes no file argument, so point a config at
the spec instead, e.g. return { default = { pattern = "debug_test_spec", ROOT = {"spec/"}, helper = "spec/helper.lua" } }
with lua run_busted.lua -f that-config.lua.