Closed oyvindaakre closed 2 months ago
@oyvindaakre looks great! Ready for merge?
@oyvindaakre also, could add please example to test dir, like I did for go - test/gotest
. The implementation should be very simple, just text for like 1 + 1 == 2, or as you want
Hi @quolpr, thanks for checking in :) I'm still fixing bugs and adding functionality, so the PR is not ready just yet :) I'll change the status back to a draft to reflect that. I will also clean up the implementation and add documentation before trying to merge this :)
I have to say, kudos to you! This is the first plugin I work on and as a lua-noob I found this as a good starting point and I think it was easy to get going on my own adapter.
Btw, I reload plugin while developing with this command, could be helpful for you:
vim.api.nvim_create_user_command("C", function()
require("lazy.core.loader").reload("quicktest.nvim")
end)
So, what I usually do:
:C
command@oyvindaakre
I made some breaking changes in API. Changes are not so much, please check Readme 🙂
@quolpr Should this PR update the doc
too?
@oyvindaakre the doc will be generated from Readme once PR is merged to main. So, please, mention your adapter in Readme 🙂
@quolpr Finally, I think the adapter is ready. I have two questions though:
1) The adapter needs to know the path to the build directory. Currently I hardcode build
here: https://github.com/oyvindaakre/quicktest.nvim/blob/ea9396b6660116e220f575a5aa33743fe8a1a13a/lua/quicktest/adapters/criterion/init.lua#L12. Is it possible for users to override this and set a custom path if they want?
2) I added a sample project to tests/support/criterion
. I also added a readme in an attempt to explain how to set up the project (+ some notes on the adapter itself).
I'm not sure how to run it with the makefile. When I run make test
it only seems to run the plugin_name_spec.lua test. Is that expected?
$ make test
Starting...
Scheduling: tests/plugin_name/plugin_name_spec.lua
========================================
Testing: /home/oyvind/.local/share/nvim/lazy/quicktest.nvim/tests/plugin_name/plugin_name_spec.lua
Success || setup works with default
Success: 1
Failed : 0
Errors : 0
========================================
@oyvindaakre as for
The adapter needs to know the path to the build directory. Currently I hardcode build here: https://github.com/oyvindaakre/quicktest.nvim/blob/ea9396b6660116e220f575a5aa33743fe8a1a13a/lua/quicktest/adapters/criterion/init.lua#L12. Is it possible for users to override this and set a custom path if they want?
Yep, I think the best way will be to make your plugin to work like this:
qt.setup({
adapters = {
require("quicktest.adapters.golang")({
exec_path = function(params)
end
}),
}
})
You can do this with meta table, check example here https://github.com/fredrikaverpil/neotest-golang/blob/main/lua/neotest-golang/init.lua#L179
I will be adding the same API to other adapters too soon. Also, notice that function is supplied for param, that's how user will be able to change behaviour per project. Based on what vim.fn.bufname(params.bufnr)
(returns buffer path) contains, they will be able to dynamically configure exec_path.
Or you can support both functions and strings, like here https://github.com/olimorris/neotest-rspec?tab=readme-ov-file#setting-the-root-directory
Let me know what you think
I'm not sure how to run it with the makefile. When I run make test it only seems to run the plugin_name_spec.lua test. Is that expected?
Ha-ha, I didn't make tests for quicktet 😄 So only manual tests for now
Let me know what you think
It sounds neat to support both function and string, but I don't have enough Lua-experience under my belt to know the implications of supporting both :) Metatable is a new concept for me, so I have to read up on it, but I'm happy to take suggestions on how to implement it for this adapter.
@oyvindaakre I made config options support for golang, could you do the same way? https://github.com/quolpr/quicktest.nvim/commit/a3bb0b6bded24ba2141cda023bf9161383ac4e30
@oyvindaakre I made config options support for golang, could you do the same way? a3bb0b6
Looks good! Copied your steps. Does it look okay?
@oyvindaakre LGTM! Thank you for the contribution, merging it now :)
Add an adapter for unit tests written in C using the Criterion unit test framework and assuming the meson build system.
Note: Build directory assumptions:
build
unless set by the user when configuring the adaptermeson setup build
(the adapter will automatically build the project before each test).Dependencies
meson
installed on the systemninja
installed on the systemSupported features