-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add adapter for C assuming Meson build system and Criterion unit testing framework #1
Conversation
@oyvindaakre looks great! Ready for merge? |
@oyvindaakre also, could add please example to test dir, like I did for go - |
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. |
0e3a69e
to
f559b31
Compare
Btw, I reload plugin while developing with this command, could be helpful for you:
So, what I usually do:
|
I made some breaking changes in API. Changes are not so much, please check Readme 🙂 |
b5731e2
to
fc8a1c9
Compare
@quolpr Should this PR update the |
@oyvindaakre the doc will be generated from Readme once PR is merged to main. So, please, mention your adapter in Readme 🙂 |
fc8a1c9
to
1aef5c1
Compare
@quolpr Finally, I think the adapter is ready. I have two questions though:
$ 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
======================================== |
ea9396b
to
2904c89
Compare
@oyvindaakre as for
Yep, I think the best way will be to make your plugin to work like this:
You can do this with meta table, check example here 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 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
Ha-ha, I didn't make tests for quicktet 😄 So only manual tests for now |
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? a3bb0b6 |
This is assuming the test executable is named after the test file, so: test_something.c -> exe == test_something So that the command line becomes meson test -C build test_something
…data Uses 'meson introspect --targets' to find the test executable that contains the source file in the currently open buffer. This fixes an issue with the existing implementation that assumed the name of the test executable from the name of the buffer. However this is not bullet proof. It is possible that the source file is used in multiple test executables, for instance to run with different parameters and flags.
Try to keep meson specific interaction in its own module for reusing later
Use empty parameter table to signal that the test can't be run
Update API for capturing JSOn Store result in M
Locate line number with error and update diagnostics UI
…d of through `meson test` Should have done this all along. This adapter is all about criterion, not meson. We still use meson introspect to find the link between the source file and the test exectuable. The primary difference is that we now call the test executable directly instead of through `meson test -C build test_exe`. This allows for some simplifications: - Depend only on how the test executable behaves - Test output can be read directly instead of being captured in the output stream of meson (lots of text + some json + lots of text) - Simpler command line since test arguments don't have to be wrapped with meson's --test-args="" - Perhaps slighly easier to modify adapter later if we need to support a different build system delete test_parser
Let util parse the results and return the error messages.
Update diagnostics namespace Update adapter path Update adatper name
Replace the external json5 decoder with the built-in vim.json module. During development I had been testing vim.fn.json_decode whichs turns out to be a vimscript function that cannot be used in lua loop callbacks. I did not know there was also a module called vim.json which I'm using now...
The criterion and util modules return an empty string instead of nil value when a test exe was not found or if a test was not found in the buffer
Realized that M.can_run is not called by quicktest, so need to call internally to make sure error handling still works
The comment was valid when running the test through `meson test` which would automatically compile. Now we run the test executable directly and need to do compilation ourselves (which we do anyway).
26cdd9f
to
84f23f1
Compare
Looks good! Copied your steps. Does it look okay? |
bcdadcb
to
b32b337
Compare
@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