-
Notifications
You must be signed in to change notification settings - Fork 0
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 basic lua tests #7
Conversation
Was just trying to run the lua tests I added via github workflow, and realized that the existing tests don't get far enough to run the ones I added:
Will look into it, but if you have any ideas let me know. |
Yeah I broke the neovim CI a few days ago and haven't gotten around to fixing it yet sorry. I can have a look |
That's amazing. Added a few comments in the code. One drawback of having the unit tests inside
What about adding requirements in
I have fixed the neovim tests to work on CI in the nvim-talon branch. Can you rebase to the latest version so we confirm the lua unit tests work on CI?
What do you want to clean up? |
@fidgetingbits It might be worth rebasing it to nvim-talon too to confirm the tests pass |
I did the rebase as a warning. @fidgetingbits I would be curious if you know how to fix the failing tests now? |
Addressed most of the feedback, but didn't look into why the CI test is failing yet. |
I fixed the CI. The issue was that the busted action I chose to use turned out to be auto-running, so would fail before it got to the commands I had to manually run. I spent quite awhile trying to make it work, using There are at least a few options for cleaning it up a bit, so I figured I'd ask you before doing it:
|
Nice one :)
I think leaving it as-is is good.
I am happy with the PR and it is close to be merged imho, only a few minor feedbacks and we are ready to go! |
@fidgetingbits Just to let you know I have fixed Cursorless tests in neovim again on CI so merging nvim-talon into this PR will fix the tests here too. |
@fidgetingbits Do you mind documenting the architecture of the lua tests in https://github.com/saidelike/cursorless/blob/nvim-talon/docs/contributing/architecture/tests.md too? |
I took a stab at it. |
Tests are passing and is easier to read now (imo), so hopefully mostly good to go |
Great stuff. I've changed a bit the tests documentation based on my understanding, hopefully you agree with my changes 3bef660 feel free to review/tweak otherwise. cc @fidgetingbits |
Updated to address some of the feedback. Still no launch.json, but tests output are improved: ❯ busted --run unit
ok 1 - cursorless.nvim tests window_get_visible_lines() Can read one visible line
ok 2 - cursorless.nvim tests window_get_visible_lines() Can read all lines visible on the window
ok 3 - cursorless.nvim tests select_range() Selects the specified range
ok 4 - cursorless.nvim tests buffer_get_selection() Can get the forward selection in a format expected by cursorless
ok 5 - cursorless.nvim tests buffer_get_selection() Can get the backward selection in a format expected by cursorless
1..5 I also added I didn't review the documentation changes yet. Also fwiw regarding being unable to test, I suspect you could run busted from wsl on windows no problem, assuming you actually want to try it. I suppose we should file an issue so that we don't rely on the XDG environment to run busted under in the future, and that way those tests can be run on windows, mac, etc. |
Now that I know how this output looks, I'll tweak it to be even more concise/clean, but didn't have time today. |
You might want to merge main into nvim-talon before doing so as Pokey has modified its contents a bit. See cursorless-dev@ee52d25 |
Note sure how you can improve it but I like already way more how it is now, nice one :) Is it possible to simulate a failure to see how it renders? |
I had put it in a response here #7 (comment) already |
This adds basic lua testing capabilities to fix cursorless-dev#2374, by using busted. Mostly followed along https://hiphish.github.io/blog/2024/01/29/testing-neovim-plugins-with-busted/
One thing I'm not sure about is that this will require busted and/or luarocks to be installed, so I don't know exactly where you want those to be listed as prerequisites and/or added to some developer setup script. I plan to use the flake.nix dev shell to get them for myself.
I plan to rewrite
buffer_get_selection()
entirely, but that doesn't need to be part of this PR. Having some existing tests for it lets me compare the new function behaves the same.Something else I haven't done yet is adding a way to run it in CI, but that's partially because I'm not sure about the install part of luarocks, etc. I can do the CI part as part of this PR, or in a follow up.
Lastly I'll likely clean up the tests a little bit, as I can re-use some code in a few places, but figured I'd post this up anyway.