nvim-neotest / neotest-plenary

MIT License
38 stars 12 forks source link

[Bug] Running plenary tests errors with missing busted module #4

Closed akinsho closed 1 year ago

akinsho commented 1 year ago

I'm cross posting this issue https://github.com/nvim-lua/plenary.nvim/issues/357#issue-1211088483, since I'm not really sure where the fix is needed but since I know that the way that modules are loaded in order to run tests in neotest-plenary involves loading mechanisms in a specific way based on #3. I thought there might also be something that needs fixing here.

The issue is that when trying to run plenary tests (in any way) whilst using lazy.nvim, my guess is that this is a key factor here because lazy takes over all plugin loading and doesn't use packpath and other mechanisms like that, the following error occurs:

.../.local/share/nvim/lazy/neotest-plenary/run_tests.lua:26: module 'plenary.busted' not found:
^Ino field package.preload['plenary.busted']
^Ino file './plenary/busted.lua'
^Ino file '/Users/runner/work/neovim/neovim/.deps/usr/share/luajit-2.1.0-beta3/plenary/busted.lua'
^Ino file '/usr/local/share/lua/5.1/plenary/busted.lua'
^Ino file '/usr/local/share/lua/5.1/plenary/busted/init.lua'
^Ino file '/Users/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/plenary/busted.lua'
^Ino file '/Users/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/plenary/busted/init.lua'
^Ino file './plenary/busted.so'
^Ino file '/usr/local/lib/lua/5.1/plenary/busted.so'
^Ino file '/Users/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/plenary/busted.so'
^Ino file '/usr/local/lib/lua/5.1/loadall.so'
^Ino file './plenary.so'
^Ino file '/usr/local/lib/lua/5.1/plenary.so'
^Ino file '/Users/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/plenary.so'
^Ino file '/usr/local/lib/lua/5.1/loadall.so'

It's hard to tell if this is because when neotest tries to load the plenary modules it tries to use the rtp or packpath in some way that no longer applies because of how lazy.nvim works.

rcarriga commented 1 year ago

Yeah this is because lazy doesn't use packpath as you said and neotest-plenary doesn't use the users init.lua so lazy is probably not loaded.

This could be worked around by using a minimal init.lua to add plenary to the rtp. We look for one here https://github.com/rcarriga/neotest-plenary/blob/d49bfd9470f791e7c29149e75d56b6f925bb391b/lua/neotest-plenary/init.lua#L89-L97

akinsho commented 1 year ago

@rcarriga that did work I had a file already that did this but had called it init.lua I'm wondering if your glob could also check for that since it seems to only check for init.vim which I guess is by design since maybe someone might call a file not intended for this purpose init.lua but I'm wondering if this isn't a mistake on their part

wookayin commented 1 year ago

I submitted a PR #10 that would make neotest-plenary work out-of-box (without any minimal_init.lua/vim)