rocks.nvim icon indicating copy to clipboard operation
rocks.nvim copied to clipboard

test: tag internet tests with #online

Open teto opened this issue 11 months ago • 3 comments

to allow to run offline tests via busted --exclude-tags=online see https://github.com/nvim-neorocks/rocks.nvim/issues/631

busted provides several filters : --exclude-pattern, --exclude-tags, --filter and --exclude-names-file. (and the equivalent include parts). exclude-names-file accepts a file with a list of filenames to skip. I preferred the tag approach so that's what I ended up doing.

currently fails with:

NVIM_APPNAME=rocks-nvim-test busted --tags=online spec/
✱Error executing luv callback:
...6ya-lua5.1-nvim-nio-1.10.1-1/share/lua/5.1/nio/tasks.lua:100: Async task failed without callback: The coroutine failed with this message: 
...ya-lua5.1-nvim-nio-1.10.1-1/share/lua/5.1/nio/logger.lua:51: E5560: Vimscript function must not be called in a lua loop callback
stack traceback:
	[C]: in function 'require'
	lua/rocks/adapter.lua:164: in function 'init_site_symlinks_async'
	lua/rocks/adapter.lua:207: in function 'synchronise_site_symlinks'
	lua/rocks/adapter.lua:199: in function 'ensure_site_links'
	lua/rocks/adapter.lua:213: in function 'func'
	...6ya-lua5.1-nvim-nio-1.10.1-1/share/lua/5.1/nio/tasks.lua:169: in function <...6ya-lua5.1-nvim-nio-1.10.1-1/share/lua/5.1/nio/tasks.lua:168>
stack traceback:
	[C]: in function 'error'
	...6ya-lua5.1-nvim-nio-1.10.1-1/share/lua/5.1/nio/tasks.lua:100: in function 'close_task'
	...6ya-lua5.1-nvim-nio-1.10.1-1/share/lua/5.1/nio/tasks.lua:122: in function 'cb'
	...6ya-lua5.1-nvim-nio-1.10.1-1/share/lua/5.1/nio/tasks.lua:183: in function <...6ya-lua5.1-nvim-nio-1.10.1-1/share/lua/5.1/nio/tasks.lua:182>
	[C]: in function 'wait'
	...-unwrapped-0.10.4/share/nvim/runtime/lua/vim/_system.lua:99: in function 'wait'
	spec/config_spec.lua:4: in main chunk
	[C]: in function 'xpcall'
	...f0z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/core.lua:178: in function 'safe'
	...0z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/block.lua:146: in function 'execute'
	...f0z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/init.lua:7: in function 'executor'
	...f0z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/core.lua:314: in function <...f0z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/core.lua:314>
	[C]: in function 'xpcall'
	...f0z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/core.lua:178: in function 'safe'
	...f0z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/core.lua:314: in function 'execute'
	...8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/execute.lua:58: in function 'execute'
	...z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/runner.lua:210: in function <...z8-lua5.1-busted-2.2.0-1/share/lua/5.1/busted/runner.lua:11>
	...d-2.2.0-1/busted-2.2.0-1-rocks/busted/2.2.0-1/bin/busted:3: in function 'fn'
	...clgmlib9alkyyzz9nm376193icy-lua5.1-nlua-0.2.0-1/bin/nlua:79: in main chunk●●●●●●●
Recursive import detected: /tmp/nix-shell.LGRGYS/rocks-nvim-test.teto/RnDIIW/5/rocks.tom

I have a hunch the logger is calling a forbidden vim function ?

teto avatar Feb 14 '25 10:02 teto

lua/rocks/adapter.lua:164: in function 'init_site_symlinks_async'

I would look here. The error is logged by nvim-nio's logger, which makes traces a bit confusing

mrcjkb avatar Feb 14 '25 11:02 mrcjkb

So basically the tests fail because mkdir is called in fast context by adapter.init(). I've tried to convert the async adapter.init into a sync one replacing everything nio.X by vim.X but I it's a bit of a rabbithole and I dont know what consequences it has on rocks.nvim startup. I am a bit out of my depth and would appreciate if you could have a look. The problem should already be in master I think ? I am just running the tests, nothing extraordinary.

To help me debug more systematically, I added a custom built neovim from https://github.com/teto/neovim/tree/teto/log-vim-function in PATH (dont forget to export VIMRUNTIME to point at the custom neovim as well if you run this) but basically the problem is the calls to vim.fn.mkdir in async context.

teto avatar Feb 22 '25 23:02 teto

So basically the tests fail because mkdir is called in fast context by adapter.init().

Are you sure about that? I'd be surprised because we haven't encountered that in our tests which we run in CI and users haven't complained either.

I've tried to convert the async adapter.init into a sync one replacing everything nio.X by vim.X

We definitely shouldn't do that. It's meant to be async (hence the _async suffix in the function name). It would be better to find out exactly which function is being called (we call uv.mkdir, which should be fine to call in an async context). But more importantly, why do the tests fail for you, but not in CI? Could this be a bug in the Neovim version you're using?

mrcjkb avatar Feb 23 '25 08:02 mrcjkb

the async problem should have been solved in https://github.com/lumen-oss/rocks.nvim/pull/686, which makes this PR simpler, aka just tagging the tests such that we can select tests that run in the nix sandbox. I quickly tried to modify the integration test to run make test-offline with nix build -L --option sandbox true .#checks.x86_64-linux.integration-nightly to check if tests passed in the sandbox , to no avail. Once merged, it might be easier for me to test it works with the nixpkgs infra rather than neorocks.

teto avatar Nov 14 '25 22:11 teto