jbyuki / one-small-step-for-vimkind

Debug adapter for Neovim plugins
MIT License
395 stars 10 forks source link

Connect OSV to Plenary test harness #48

Closed seflue closed 2 months ago

seflue commented 3 months ago

Is it possible to connect OSV to a plenary test harness? I played around a little bit with the "run_this" method and also with "PlenaryBustedFile" but I was only able to hit a breakpoint outside of a busted describe closure. Breakpoints within the functions passed to describe or it are not hit.

Did anyone got this to work? Is plenary test debugging in the scope of OSV?

jbyuki commented 3 months ago

Yes this is currently out of the scope of osv. Debugging tests with plenary.nvim will not work as-is unfortunately.

There is this good blog article describing a setup to use busted directly by using nvim as an interpreter.

seflue commented 3 months ago

Thanks, good to know. And thanks for the article - I didn't find it in my research.

Just out of curiosity (my knowledge about debugging with Neovim is currently rather superficial) - would you mind to elaborate a bit on the technical details, why test debugging with plenary is currently not possible and what makes it hard to integrate it into OSV?

jbyuki commented 3 months ago

Sure, this relates to how plenary does its test. It will spawn a neovim subprocess and execute the tests in there. When you call launch to start the debugging, it will just debug the main process not the subprocess. To work properly the debugging server needs to be launched in the subprocess.

Hypothetically, one possible way is to launch the server in the test itself so that it attaches to the subprocess.

describe("some basics", function()
    require"osv".launch({port=8086})
    require"osv".wait_connect()

    -- rest of test
end)

This does not work currently, the function wait_connect is not implemented, and wouldn't be very convenient as the debug code will need to be written each time. Why not just put print statements in that case. Some code needs to be upstreamed to plenary.nvim in order to make it work with osv seamlessly.

Hopefully you get the gist of the issue with this. So technically possible, but needs further implementation as of now.