Skip to content

Conversation

@seflue
Copy link
Contributor

@seflue seflue commented Dec 31, 2023

Fix test on CLI AND Neotest by executing the vim commands asynchronously.

This test was not marked as failed when it ran from the command line, although the error was visible in the output.
In Neotest it was actually marked as failed.

@kristijanhusak
Copy link
Member

although the error was visible in the output

I can't see any errors in the CLI output:

╰─ make test FILE=tests/plenary/state/state_spec.lua                                                                                                                                                                                         ─╯
zsh: correct 'test' to 'tests' [nyae]? n
nvim --headless --clean -u tests/test.lua "tests/plenary/state/state_spec.lua"
Individual Test File/Directory provided: tests/plenary/state/state_spec.lua
Running all tests at tests/plenary/state/state_spec.lua
Starting...Scheduling: tests/plenary/state/state_spec.lua

========================================	
Testing: 	/home/kristijan/github/orgmode/tests/plenary/state/state_spec.lua	
Success	||	State should create a state file if it doesn't exist	
Success	||	State should save the cache file as valid json	
Success	||	State should be able to save and load state data	
Success	||	State should be able to self-heal from an invalid state file	
	
Success: 	4	
Failed : 	0	
Errors : 	0	
========================================	

Can you provide some info what you get?

@seflue
Copy link
Contributor Author

seflue commented Jan 4, 2024

Within neotest I get the following error:
image
On CLI I actually also had 0 errors, regarding the output I might have seen a gost (a couple of tests throw some output and it's quite possible, that I misread it).
To check against neotest, you would need my last state of neotest_plenary with some funky reconfiguration:
image
Or you rename the scripts/minimal_init.lua into something which isn't catched by the neovim-plenary globbing.
Background: neovim-plenary is globbing for a minimal_init.lua, and tests/minimal_init.lua in the orgmode project is the correct one. But because scripts/minimal_init.lua matches first, so the tests don't run at all with neotest. My fix makes the globbing configurable and also fixes the configurability of neotest-plenary in a general sense. Being able to run the tests from within neovim is much more convenient during development.

Comment on lines 83 to 87
vim.schedule_wrap(function()
vim.cmd.edit(cache_path)
vim.api.nvim_buf_set_lines(0, 0, -1, false, { '[ invalid json!' })
vim.cmd.write()
end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try these changes instead and see if it works?

Suggested change
vim.schedule_wrap(function()
vim.cmd.edit(cache_path)
vim.api.nvim_buf_set_lines(0, 0, -1, false, { '[ invalid json!' })
vim.cmd.write()
end)
vim.cmd(('edit %s'):format(cache_path))
vim.api.nvim_buf_set_lines(0, 0, -1, false, { '[ invalid json!' })
vim.cmd('write')

From the screenshot I see that neotest-plenary cannot figure out that vim.cmd is a table, so this might fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this actually also fixes the problem. I updated my commit with your suggestion.

@seflue seflue force-pushed the fix_state_spec_test branch from f5b7202 to 2f7f7e5 Compare January 9, 2024 06:24
Fix test on CLI AND Neotest by executing the vim commands
asynchronously.

This test was not marked as failed when it ran from the command line,
although the error was visible in the output.

In Neotest it was actually marked as failed.
@seflue seflue force-pushed the fix_state_spec_test branch from 2f7f7e5 to c53d62f Compare January 9, 2024 06:30
@kristijanhusak kristijanhusak merged commit 7e8e5fd into nvim-orgmode:master Jan 9, 2024
SlayerOfTheBad pushed a commit to SlayerOfTheBad/orgmode that referenced this pull request Aug 16, 2024
Fix test on CLI AND Neotest by executing the vim commands
asynchronously.

This test was not marked as failed when it ran from the command line,
although the error was visible in the output.

In Neotest it was actually marked as failed.

Co-authored-by: Sebastian Flügge <seflue@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants