Repository navigation
tests/vim: share the headless-Vim launcher; fold.bats; helper docs - #151
Merged
Merged
Conversation
Every Vim test file built the same environment and Vim command line: HOME and the XDG directories in the test's temp directory, a PATH holding only a stub directory, and `vim -N -u .vimrc -es` under a 30-second timeout. They now load helpers/vim.bash, which sets that up once (vim_fixture), runs Vim in it (headless_vim), drops a variable a test needs unset (vim_env_unset) and adds the node tripwire (with_node). vimrc.bats and xdg.bats now also get XDG_CONFIG_HOME and XDG_CACHE_HOME inside the temp directory, which they previously left unset; neither tests those two. Refs #136 Co-Authored-By: AI Agent <noreply@harleypig.com>
oldfiles.bats tests CustomFoldText() in the late fold.vim, and its name and header still pointed at the OLD_FILES/ directory it was merged out of, which is gone. It is fold.bats now, beside set.bats and maps.bats, with a header saying what it checks. Refs #44 Co-Authored-By: AI Agent <noreply@harleypig.com>
TESTS.md now says shared test code goes in each suite's helpers/ directory, loaded with `load`, and names the two there: tests/shell/helpers/git-fixture.bash and tests/vim/helpers/vim.bash. Refs #44 Co-Authored-By: AI Agent <noreply@harleypig.com>
harleypig
added a commit
that referenced
this pull request
Nov 4, 2026
…er (#155) * fix(settings): CustomFoldText is script-local (#44) The late fold.vim's fold-text function is now s:CustomFoldText(), and 'foldtext' is set with the s: form, which Vim (8.2.3908 and later) replaces with the function's <SNR> name. tests/vim/fold.bats checks for that name and that no global CustomFoldText() exists. Co-Authored-By: AI Agent <noreply@harleypig.com> * fix(settings): gutter toggles are script-local Normal-mode mappings (#44) ToggleLineNumbers and its sibling ToggleSigns in the late gutter.vim are now script-local, and <leader>ln and <leader>signs are nnoremap calls to <SID> versions. The old recursive map also defined them in Visual and Operator-pending mode, where the :call ran once per selected line. The docs name no mode for either, so they are unchanged. tests/vim/tidy.bats checks the mappings' modes, that neither function is global, and that each toggle still cycles as documented. Co-Authored-By: AI Agent <noreply@harleypig.com> * docs: drop the coc-ale-setup bullet on removed completion branches (#44) The <Tab> and <C-Space> mappings in the late coc.vim no longer check for a completion plugin that is not installed (removed in #152 - coc.vim tidy-ups), so the bullet saying they do is gone. Co-Authored-By: AI Agent <noreply@harleypig.com> * test(vim): colors, ale-settings and tidy use the shared launcher (#44) The three Vim test files added alongside #151 each carried their own copy of the headless-Vim launcher. They now load helpers/vim, set up with vim_fixture and start Vim with headless_vim, as every other file in tests/vim does. No test changes what it checks. Each file was seen to fail with one guarded behaviour broken: the Insert mode StatusLine colour (colors), g:ale_disable_lsp in the early ale.vim (ale-settings) and 'spellfile' (tidy). Co-Authored-By: AI Agent <noreply@harleypig.com> --------- Co-authored-by: AI Agent <noreply@harleypig.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
tests/vimhalf of #136. Thetests/shellhalf landed in #141.Shared launcher (
tests/vim/helpers/vim.bash). All twelve Vim test files built the same environment and the same Vim command line themselves:HOMEand the XDG directories in the test's temp directory, aPATHholding only a stub directory, andtimeout 30 env -i … vim -N -u .vimrc -es. They now load one helper, following the shell half'sload helpers/<name>pattern:vim_fixture, called fromsetup, sets$repo,$vim,$vimrc,$home,$stubs(holding onlysh),$reportand the$vim_envarray.headless_vim [VAR=VALUE...] [--] [VIM ARGS...]runs Vim in that environment, with any extra variables taking precedence, and returns Vim's exit status.vim_env_unset NAME...removes a variable for tests that need it unset (vimrc.batsunsetsXDG_DOTVIM,xdg.batsunsetsXDG_STATE_HOMEandXDG_DATA_HOME).with_nodeis the node tripwire stub, whichcoc.batsandload.batseach had a copy of.Each file's
report.vimscaffolding and its own submodule check are left as they were. Their contents differ from file to file, so they are not a shared launcher.oldfiles.bats→fold.bats(from Small tidy-ups: envsubstitute help quote, old shell-lint warnings, proselint config path #44). The file testsCustomFoldText()in the latefold.vim. Its name and header still referred to the deletedOLD_FILES/. The new name matchesset.batsandmaps.bats, and the header now says what the file checks..claude/TESTS.mdgets a Shared helpers section saying where each suite's helpers live and naming both of them (v0.2.0).Refs #44
Closes #136
For files added later: other
tests/vim/*.batsfiles being written at the same time as this PR still carry their own copy of the launcher. Each one should switch toload helpers/vimand callvim_fixture/headless_vimonce it and this PR have both merged.Test plan
bats tests/vimwith a fresh, emptyTMPDIR: 75/75 ok, which is the same count as onmasterbefore the change.TMPDIRwas still empty afterwards.bats tests/shellwith a fresh, emptyTMPDIR: all ok,TMPDIRstill empty afterwards.shellcheck -s bashandshfmt -i 2 -s -bn -ci -sr -d(the repo's shfmt style) on the helper: both clean..claude/TESTS.md: clean.Testing evaluation
I ran this myself to the qa-tester's standard; there is no
team-managed:sentinel.tests/vim/*.bats..vimrcXDG_DOTVIM fallback pointed at/nowhere→vimrc.batsred in 3 tests (unset, empty, symlink). This showsvim_env_unset XDG_DOTVIMreally leaves the variable unset.vim_env_unsetmade a no-op →xdg.bats"unset, Vim uses the defaults" red.headless_vimdrops its extraVAR=VALUEargs →xdg.bats"set, Vim uses them" red.with_nodestub left non-executable →coc.bats"with node" and "Tab at the start of a line" red.PATH(host has node) invim_env→coc.bats"without node, CoC … not loaded" red.set foldtext=commented out infold.vim→fold.batsred in all 3 tests.algorithm:patiencecommented out inset.vim→set.batsred.set.vim→load.bats"starts with no error message" red in both tests (with and without node).helptags.vimmade to always rebuild →helptags.bats"tags newer … left alone" red.--indent 2→--indent 4in the sh ftplugin →sh-ftplugin.batsred.Manual verification
git submodule update --init) andBATS_LIB_PATHpointing at bats-support/bats-assert.d=$(mktemp -d); TMPDIR=$d bats tests/vim; ls -A "$d".1..75, every lineok, exit 0, andls -Aprints nothing.not okline, or a leftover entry in$d.1..75, 75ok, 0not ok, exit 0. The temp directory was left with 0 entries.Review
opt-out: no named review skill (
code-reviewor similar) ran on this test-only refactor. In its place, the falsifiers above stand as evidence, together with a self-review of the diff, which turned up the points below for a reviewer to check.vimrc.batsandxdg.batsnow also getXDG_CONFIG_HOMEandXDG_CACHE_HOMEinside the temp directory. Before, they left both unset, which falls back to$home/.configand$home/.cache, also inside the temp directory. Neither file tests those two variables.headless_vimtreats leadingVAR=VALUEwords as environment variables. A file argument containing=therefore has to come after--.statusline.batsandsh-ftplugin.batsalready pass--before their file paths.reportandhomebelong invim_fixture.reportis unused byhelptags.batsandsh-ftplugin.bats, and has a SC2034 suppression with its reason. Also check whether movingwith_node(two copies, not three) goes beyond the issue's "launcher".Completion report
|| vim_status=$?or|| truehandling..claude/TESTS.mdShared helpers, the helper's own header, and the updated test-file headers.Co-Authored-By: AI Agent noreply@harleypig.com