jfpedroza / neotest-elixir

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

No tests found #35

Closed treeman closed 1 week ago

treeman commented 3 weeks ago

I'm trying out neotest but I always get the "No tests found" response when run with run(). If I try to use:

require("neotest").run.run(vim.fn.expand("%"))

The tests gets a "spinner" icon in the summary split, but no tests are run and nothing is printed in the output panel.

I've tried with a fresh project from mix new with a file like this:

defmodule ExNewTest do
  use ExUnit.Case
  doctest ExNew

  test "greets the world" do
    assert ExNew.hello() == :world
  end
end

The neotest rust adapter works well. I've tried to update the treesitter grammar and tried various elixir LSPs and now I'm a bit lost.

> nvim --version
NVIM v0.10.0-dev-3135+g7acf39dda
Build type: Debug
LuaJIT 2.1.1713484068
jfpedroza commented 3 weeks ago

It may be a configuration issue. Can you share how you configured the adapter?

The adapter doesn't depend on an LSP to work.

treeman commented 3 weeks ago

I use a basic configuration:

require("neotest").setup({
  adapters = {
    require("rustaceanvim.neotest"),
    require("neotest-elixir"),
  },
})

Which is done in after/plugin/neotest.lua. I use rocks.nvim as the package manager if that matters.

jfpedroza commented 2 weeks ago

If you open the summary, does it show the list of tests?

You can also check Neotest logs, setting the log level to debug like so:

neotest.setup({
  log_level = vim.log.levels.DEBUG,
  adapters = {
    require("neotest-elixir"),
  },
})

The file can be found in ~/.local/state/nvim/neotest.log. I recommend removing it before trying.

treeman commented 2 weeks ago

The individual tests aren't listed, only the _test.exs file.

There was a treesitter error in the logs:

ERROR | 2024-06-17T06:17:43Z+0200 | ...l/share/nvim/rocks/rocks_rtp/lua/neotest/client/init.lua:309 | Couldn't find positions in path /home/tree/code/ex_new/test/ex_new_test.exs ...ee/.local/share/nvim/rocks/share/lua/5.1/nio/control.lua:145: ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:101: '' is not a valid language name
stack traceback:
    [C]: in function 'error'
    ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:101: in function 'add'
    ...l/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'get_string_parser'
    ...nvim/rocks/rocks_rtp/lua/neotest/lib/treesitter/init.lua:119: in function 'get_parse_root'
    ...nvim/rocks/rocks_rtp/lua/neotest/lib/treesitter/init.lua:160: in function 'parse_positions_from_string'
    ...nvim/rocks/rocks_rtp/lua/neotest/lib/treesitter/init.lua:207: in function 'func'
    ...hare/nvim/rocks/rocks_rtp/lua/neotest/lib/subprocess.lua:156: in function <...hare/nvim/rocks/rocks_rtp/lua/neotest/lib/subprocess.lua:155>
    [C]: in function 'xpcall'
    ...hare/nvim/rocks/rocks_rtp/lua/neotest/lib/subprocess.lua:155: in function <...hare/nvim/rocks/rocks_rtp/lua/neotest/lib/subprocess.lua:154>
stack traceback:
    [C]: in function 'error'
    ...ee/.local/share/nvim/rocks/share/lua/5.1/nio/control.lua:145: in function 'call'
    ...nvim/rocks/rocks_rtp/lua/neotest/lib/treesitter/init.lua:189: in function 'discover_positions'
    ...l/share/nvim/rocks/rocks_rtp/lua/neotest/client/init.lua:300: in function <...l/share/nvim/rocks/rocks_rtp/lua/neotest/client/init.lua:264>
    [C]: in function 'xpcall'
    ...l/share/nvim/rocks/rocks_rtp/lua/neotest/client/init.lua:264: in function '_update_positions'
    ...l/share/nvim/rocks/rocks_rtp/lua/neotest/client/init.lua:317: in function <...l/share/nvim/rocks/rocks_rtp/lua/neotest/client/init.lua:315>

neotest.log

oskar1233 commented 1 week ago

@treeman

:TSInstall elixir did the job for me.

treeman commented 1 week ago

@treeman

:TSInstall elixir did the job for me.

I've tried both :TSInstall and :TSUpdate with the same result.

I do suspect that the grammar I've got installed is somehow of a different version but I don't really know how to check that. nvim-treesitter is using the commit 71a8e8b4 at the moment which is a pretty recent one (7 days ago).

treeman commented 1 week ago

I had a suspicion that my setup was broken somehow so I tried to use lazy.nvim instead of rocks.nvim as the package manager. Did a cleanup and now it works as expected.

I'm sure the error is because a wrong version of the Elixir tree-sitter grammar somehow but I'm not sure why/how.