Skip to content
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

Async test exit directly without any error #20

Open
AbaoFromCUG opened this issue Apr 8, 2024 · 1 comment · May be fixed by #21
Open

Async test exit directly without any error #20

AbaoFromCUG opened this issue Apr 8, 2024 · 1 comment · May be fixed by #21

Comments

@AbaoFromCUG
Copy link

AbaoFromCUG commented Apr 8, 2024

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
Copy link
Author

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

it = busted.it
describe = busted.describe
busted.run(file)
local results_file = assert(io.open(args.results, "w"))
results_file:write(vim.json.encode({ results = results, locations = func_locations }))
results_file:close()
os.exit(code)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant