Drop symlink creation from tests

Creating and removing symlinks is brittle because the symlink might get
left over and mess up subsequent tests.  This change makes it so that
the path to the plugin is injected into the runtime path at startup.
This commit is contained in:
HiPhish 2024-07-23 19:12:50 +02:00
parent b29da4a606
commit 594e88ba1d
3 changed files with 7 additions and 18 deletions

View file

@ -45,6 +45,7 @@ describe('Buffer Manipulation', function()
nvim:exec_lua('TSEnsure(...)', {'lua', 'markdown'})
nvim:buf_set_lines(0, 0, -2, true, vim.fn.split(markdown_with_injected_lua, '\n'))
nvim:buf_set_option(0, 'filetype', 'markdown')
nvim:exec_lua('vim.treesitter.start()', {})
assert.nvim(nvim).has_extmarks_at(3, 5, 'lua')
-- Move Lua line out of code block
@ -60,6 +61,7 @@ describe('Buffer Manipulation', function()
nvim:exec_lua('TSEnsure(...)', {'lua', 'markdown'})
nvim:buf_set_lines(0, 0, -2, true, vim.fn.split(markdown_without_injected_lua, '\n'))
nvim:buf_set_option(0, 'filetype', 'markdown')
nvim:exec_lua('vim.treesitter.start()', {})
assert.nvim(nvim).Not.has_extmarks_at(4, 5, 'lua')
-- Move Lua line out of code block

View file

@ -43,29 +43,13 @@ while getopts 'ilEve:' opt; do
done
# We need to add this plugin to the custom configuration. The easiest way is
# to create a symlink. Why not always have a symlink in the project? The Lua
# language server will search for Lua files in every directory, so if it enters
# the symlink it will be trapped in a cycle. What we do instead is create the
# symlink only for the duration of a test session and remove it again
# afterwards.
# We need separate symlinks if we want to run different tasks in parallel.
# Otherwise the one the finishes first would delete the symlink from underneath
# the one that is still running.
uuid=$(uuidgen)
mkdir -p ${XDG_DATA_HOME}/nvim/site/pack/self-${uuid}/start/
ln -fs $(pwd) ${XDG_DATA_HOME}/nvim/site/pack/self-${uuid}/start/
if [ -n "$lua_expr" ]; then
nvim --headless -c "lua $lua_expr" -c 'quitall!'
else
# We have to explicitly enable plugins, see ':h -l'
nvim --cmd 'set loadplugins' -l $@
# We have to explicitly enable plugins and user configuration, see ':h -l'
nvim --cmd 'set loadplugins' -u "${XDG_CONFIG_HOME}/nvim/init.lua" -l $@
fi
exit_code=$?
rm -rf ${XDG_DATA_HOME}/nvim/site/pack/self-${uuid}/
exit $exit_code

View file

@ -1,3 +1,6 @@
-- Add the plugin itself to the runtime path so we can use it in our tests.
vim.opt.runtimepath:append(vim.fn.getcwd())
-- Tree-sitter highlighting needs to be running, otherwise rainbow highlighting
-- won't get updated on tree changes. The following autocommand enables it on
-- every file type change.