nvim-neotest / neotest-plenary

MIT License
32 stars 11 forks source link

Async test exit directly without any error #20

Open AbaoFromCUG opened 2 months ago

AbaoFromCUG commented 2 months ago

Here is a test case modified from https://github.com/nvim-lua/plenary.nvim/blob/master/TESTS_README.md, it is expected failed after 10 seconds

describe("test", function()
    it("async", function()
        local co = coroutine.running()
        vim.defer_fn(function()
            assert(false, "should error")
            coroutine.resume(co)
        end, 10000)
        coroutine.yield()
    end)
end)

I run with neotest +neotest-plenary, which just exist without any error, here is output


========================================
Testing:        /tmp/nvim/xxx_spec.lua

[Terminal closed]

Maybe a issue related to coroutine or api-fast, I am a little confused with them

AbaoFromCUG commented 2 months ago

yeah, I found the cause of this issue, busted.run(file) will run a a file and return immediately, regardless of whether it really completed or not. But neotest-plenary assumes that it has been completed

https://github.com/nvim-neotest/neotest-plenary/blob/dcaf5ed67a9e28a246e9783319e5aa6c9ea1c584/run_tests.lua#L84-L91

In busted.run(), just wrap and run the file in a coroutine.wrap

https://github.com/nvim-lua/plenary.nvim/blob/8aad4396840be7fc42896e3011751b7609ca4119/lua/plenary/busted.lua#L237-L240

A solution is to hack the busted.run…… such a hell