nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.42k stars 123 forks source link

Neotest with dap strategy in very large repo causing nvim to freeze #453

Open dbatten5 opened 2 months ago

dbatten5 commented 2 months ago

NeoVim Version NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478

Describe the bug Apologies for the vagueness but I'm not really sure how to pinpoint this issue.

I work in a very large monorepo at work. I've previously been able to run neotest DAP with nvim-dap without any issues to debug the application. Since upgrading neotest to version that required neotest-nio, whenever I try to run neotest with DAP strategy my neovim freezes and I end up having to close the tab in my terminal. I can see the neovim process at around 99% CPU. I'm not sure if this is an issue with neotest or nvim-dap or a combination of the two. I'm also not sure how to provide any useful information here

Logs The log file is 1.8m lines long. A huge amount the lines have this form:

DEBUG | 2024-09-11T10:44:26Z+0100 | ...al/share/nvim/lazy/neotest/lua/neotest/lib/file/find.lua:26 | Scanning directory: path/in/monorepo

I can also see that it's scanning through e.g. node_modules that are buried within the monorepo. Is there a config option I can be setting to to make sure I don't scan the entire monorepo here?

My setup looks like this:

    neotest.setup({
      adapters = {
        neotest_python({
          args = { "-vv" },
        }),
      },
      output = { open_on_run = true },
      discovery = {
        enabled = false,
      },
    })
asmodeus812 commented 1 month ago
                                                      *neotest.Config.discovery*
Fields~
{enabled} `(boolean)`
{concurrent} `(integer)` Number of workers to parse files concurrently. 0
automatically assigns number based on CPU. Set to 1 if experiencing lag.
{filter_dir} `(nil)` | fun(name: string, rel_path: string, root: string):
boolean A function to filter directories when searching for test files.
Receives the name, path relative to project root and project root path

Checkout this

fredrikaverpil commented 1 month ago

Already mentioned above, but yes, you can make neotest only query the opened buffer for tests, which likely will help you out here:


{
  "nvim-neotest/neotest",
  opts = {
    -- See all config options with :h neotest.Config
    discovery = {
      -- Drastically improve performance in ginormous projects by
      -- only AST-parsing the currently opened buffer.
      enabled = false,
      -- Number of workers to parse files concurrently.
      -- A value of 0 automatically assigns number based on CPU.
      -- Set to 1 if experiencing lag.
      concurrent = 1,
    },
    running = {
      -- Run tests concurrently when an adapter provides multiple commands to run.
      concurrent = true,
    },
    summary = {
      -- Enable/disable animation of icons.
      animated = false,
    },
  },
}

I feel this kind of info should be more prominently explained in the main README.