jfpedroza / neotest-elixir

Neotest adapter for Elixir
MIT License
38 stars 10 forks source link

IEx strategy #14

Closed jfpedroza closed 10 months ago

jfpedroza commented 1 year ago

Adds a strategy for running tests in the same OS process every time.

The first time a test is run, the process starts. From there, other runs communicate with the same process.

Still WIP, but mostly complete.

Closes #12

scottming commented 1 year ago
image

I found a small bug that won't clear past test result records, above contains 4 times records.

scottming commented 1 year ago

Another small bug is that the output cannot be displayed when the test passes. The left side is the result of iex test, the right side is the result of mix test

image
scottming commented 1 year ago

Also, does this strategy require the project to rely on {:ex_unit_notifier, "~> 1.2", only: :test}?

image
scottming commented 1 year ago

Running the test on the summary tree(by key r), it seems that the strategy used is still mix test:

image
scottming commented 1 year ago

Finally, I would like to say that the speed really Awesome.

jfpedroza commented 1 year ago

I found a small bug that won't clear past test result records, above contains 4 times records.

Got it, should be easy to fix.

Another small bug is that the output cannot be displayed when the test passes. The left side is the result of iex test, the right side is the result of mix test

This is not related to this PR. It's because there is no output for successful tests. Maybe it could be set to something like "Test passed in 50ms".

Also, does this strategy require the project to rely on {:ex_unit_notifier, "~> 1.2", only: :test}?

No, if you are seeing that error, it is because you have that formatter listed in extra_formatters.

Running the test on the summary tree(by key r), it seems that the strategy used is still mix test:

The summary doesn't support specifying the strategy. You probably need to change the default strategy for the project in neotest.setup_project(). If you do, you won't need to pass it anymore in neotest.run.run() either.

jfpedroza commented 1 year ago

@scottming Just fixed the two reported issues.

scottming commented 1 year ago

hi, Jhon, seems like the strategy field does not work in the setup.

        require("neotest-elixir")({
            args = { "--trace" },
      strategy = "iex",
        }),

but this lua require('neotest').run.run({strategy = 'iex'}) config will works

jfpedroza commented 1 year ago

seems like the strategy field does not work in the setup.

Wrong place. It's a setting of the project in Neotest, not of the adapter.

require("neotest").setup_project(vim.loop.cwd(), {
  adapters = {...},
  default_strategy = "iex"
})
scottming commented 1 year ago

~still not work~

require("neotest").setup_project(vim.loop.cwd(), {
    adapters = { require("neotest-elixir") },
    default_strategy = "iex",
})

~seems like this line does not send the project strategy to the client~

~https://github.com/nvim-neotest/neotest/blob/master/lua/neotest/client/runner.lua#L64~

~args = vim.tbl_extend("keep", args or {}, { strategy = config.default_strategy })~

fixed here: https://github.com/nvim-neotest/neotest/commit/fbd806c92e4486f56926837541532c93ab8dcd0f

scottming commented 1 year ago

Another usage scenario we need to consider is that sometimes the loop of the iex strategy will hang, so we need to provide a function to end the process.

Currently lua require('neotest').run.stop() does not work

This problem can be reproduced when you type r at the file cursor of the side tree.

image
scottming commented 1 year ago

Another bug is that if a test running in the sidebar encounters an error, the whole process crashes.

image