nvim-neotest / neotest-go

MIT License
124 stars 43 forks source link

Neotest watch does not work in a large Go repo #93

Open asfaltboy opened 1 month ago

asfaltboy commented 1 month ago

I've got a large repo with hundreds of packages, and thousands of files, and test watcher seems to not run any test on change.

Debug logs shows a lot of continuous messages such as:

DEBUG | 2024-05-20T14:55:11Z+0100 | ...vim/lazy/neotest/lua/neotest/consumers/watch/watcher.lua:79 | Found 1 linked files for
file1.go
DEBUG | 2024-05-20T14:55:11Z+0100 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:140 | Waiting for result 910
INFO | 2024-05-20T14:55:11Z+0100 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:153 | CHILD | Received remote call 910 <function 1>
DEBUG | 2024-05-20T14:55:11Z+0100 | ...vim/lazy/neotest/lua/neotest/consumers/watch/watcher.lua:19 | CHILD | Parsing symbols for file2.go
DEBUG | 2024-05-20T14:55:11Z+0100 | ...al/share/nvim/lazy/neotest/lua/neotest/lib/file/init.lua:22 | CHILD | Reading file: file2.go
DEBUG | 2024-05-20T14:55:11Z+0100 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:91 | Result registed for callback 910
DEBUG | 2024-05-20T14:55:11Z+0100 | ...vim/lazy/neotest/lua/neotest/consumers/watch/watcher.lua:50 | Getting symbol definitions for file2.go

Where the file names alternate between different files, and seem to be repeating. (note that 'registed' message is mis-typed in the actual code)

When saving a change in the test module, I see this emitted in the debug log:

DEBUG | 2024-05-20T15:03:18Z+0100 | ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:305 | Found { {
    id = "test_file.go",
    name = "test_file.go",
    path = "test_file.go",
    range = { 0, 0, 75, 0 },
    type = "file"
  }, { {
      id = "test_file.go::TestRepository_List",
      name = "TestRepository_List",
      path = "test_file.go",
      range = { 17, 0, 41, 1 },
      type = "test"
    } }, { {
      id = "test_file.go::TestRepository_ListWithFilter",
      name = "TestRepository_ListWithFilter",
      path = "test_file.go",
      range = { 43, 0, 74, 1 },
      type = "test"
    } } }
DEBUG | 2024-05-20T15:03:18Z+0100 | ...hare/nvim/lazy/neotest/lua/neotest/client/state/init.lua:54 | New positions at ID test_file.go
INFO | 2024-05-20T15:03:18Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:48 | Emitting discover_positions event
DEBUG | 2024-05-20T15:03:18Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:50 | Calling listener diagnostic for event discover_positions
DEBUG | 2024-05-20T15:03:18Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:50 | Calling listener status for event discover_positions
DEBUG | 2024-05-20T15:03:18Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:50 | Calling listener state for event discover_positions
DEBUG | 2024-05-20T15:03:18Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:50 | Calling listener summary for event discover_positions
INFO | 2024-05-20T15:03:19Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:48 | Emitting test_focused event
DEBUG | 2024-05-20T15:03:19Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:50 | Calling listener summary for event test_focused

Note: I shortened and obfuscated file/path to protect the identity of the code owner.

fredrikaverpil commented 1 month ago

@asfaltboy would you mind giving neotest-golang a go and report back if you experience similar issues with that adapter? (I'm the developer of it) I'd be curious to see how it performs on a project of the size you are describing.

asfaltboy commented 1 month ago

It seems to behave exactly the same, in terms of not running any watched tests, and emitting similar / same log messages.

Is there anything I could add or try, to narrow down the root cause? I'm actually not convinced it's just about the size of the repo, maybe there are other factors at play?

I also see this notification once when starting a test, but I think it might be a red-herring:

2024-05-20T22:15:39 Error  ERROR Error detected while processing User Autocommands for "LspDynamicCapability":
2024-05-20T22:15:39 Messages  INFO Error executing lua callback: .../.local/share/nvim/lazy/LazyVim/lua/lazyvim/util/lsp.lua:64: attempt to call field 'supports_method' (a nil value)
stack traceback:
    .../.local/share/nvim/lazy/LazyVim/lua/lazyvim/util/lsp.lua:64: in function <.../.local/share/nvim/lazy/LazyVim/lua/lazyvim/util/lsp.lua:60>
    [builtin#36]: at 0x0103858820
    ...llar/neovim/0.9.5/share/nvim/runtime/lua/vim/lsp/rpc.lua:433: in function <...llar/neovim/0.9.5/share/nvim/runtime/lua/vim/lsp/rpc.lua:393>
fredrikaverpil commented 1 month ago

Hmm. I think I would start with just some sort of elimination strategy, so to see if the size of the repo can be considered either part of the problem or not part of the problem. Like for example, you could try to start fresh in a new folder, then add in files and folders from the actual project gradually and retry in-between copying, until something causes this behavior you are experiencing.

You should be able to see files being watched and then at some point no longer being watched (with that continuous logging you mentioned).

Have you made sure you can watch a test in a minimal go test file?

In regards to the LazyVim error, are you on the latest LazyVim and Neovim 0.10.? The method mentioned is used here: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/lsp/init.lua