fredrikaverpil / neotest-golang

Reliable Neotest adapter for running Go tests in Neovim.
MIT License
96 stars 8 forks source link

bug: debugger does not start #135

Closed asfaltboy closed 1 month ago

asfaltboy commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

macOS 14.5

Describe the bug

neotest-golang runs a single test, but cannot start debugger for the same test.

Note: neotest-go starts the debugger (though it runs for all tests in the module 😢 ), but neotest-golang fails with an error:

neotest-golang: ...vchenko/.local/share/nvim/lazy/nvim-nio/lua/nio/init.lua:119: The coroutine failed with this message: 
...nvim/lazy/neotest/lua/neotest/client/strategies/init.lua:57: attempt to index local 'instance' (a nil value)
stack traceback:
    ...nvim/lazy/neotest/lua/neotest/client/strategies/init.lua: in function 'run'
    ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:130: in function '_run_spec'
    ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:89: in function <...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:88>
stack traceback:
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:89: in function <...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:88>
    [C]: in function 'error'
    ...vchenko/.local/share/nvim/lazy/nvim-nio/lua/nio/init.lua:119: in function 'gather'
    ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:94: in function '_run_tree'
    ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:65: in function <...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:22>
    [C]: in function 'xpcall'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:84: in function 'run_tree'
    ...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:85: in function 'func'
    ...chenko/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:173: in function <...chenko/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:172>

Steps To Reproduce

  1. Start a debugger for a test case
  2. An error occurs

Expected Behavior

Should run the debugger

Your Lua setup

Using LazyVim I configure:

return {
  "nvim-neotest/neotest",
  opts = {
    adapters = {
      -- "neotest-go",
      "neotest-golang",
    },
  },
  dependencies = {
    {
      -- {
      --   "nvim-neotest/neotest-go",
      --   extra_args = { "-vet=off" }
      -- },
      {
        "fredrikaverpil/neotest-golang",
        args = { "-vet=off" }
      },
    },
  },
}
fredrikaverpil commented 1 month ago

Please provide a minimal reproducible Go test example.

asfaltboy commented 1 month ago

Check out https://github.com/golang-jwt/jwt , run go build ./... to make sure it builds, then run neovim in the dir and execute a debug test.

fredrikaverpil commented 1 month ago

I cloned down the repo, found a test at random and tried to both run it and then debug it. Works on my machine 😄

Screenshot 2024-07-15 at 15 08 18 Screenshot 2024-07-15 at 15 08 53

It feels like this could be a configuration issue on your end...?

Since LazyVim is already using neotest-golang, I could quite easily try it out here too, and it works for me:

Screenshot 2024-07-15 at 15 14 44 Screenshot 2024-07-15 at 15 15 01
fredrikaverpil commented 1 month ago

Could it be that you haven't enabled debugging in your neotest-golang config with dap_go_enabled = true?

What happens if you run :checkhealth neotest-golang?