nvim-neotest / neotest

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

[BUG] CMD Neotest Summary freezes Neovim #441

Open b0lle opened 1 month ago

b0lle commented 1 month ago

NeoVim Version NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478 Run "nvim -V1 -v" for more info

Describe the bug In 90% of my cases, the execution of the Neotest Summary command freezes my Neovim. There is no option to quit neovim anymore.

To Reproduce Sorry I can not provide a minimal example, because sometimes it works just fine ...

My neotest-config:

return {
  'nvim-neotest/neotest',
  dependencies = {
    'nvim-neotest/nvim-nio',
    'nvim-lua/plenary.nvim',
    'antoinemadec/FixCursorHold.nvim',
    'nvim-treesitter/nvim-treesitter',
  },
  config = function()
    require('neotest').setup {
      adapters = {
        require 'neotest-python' {
          dap = { justMyCode = false },
          args = { '-vv', '-s' },
          runner = 'pytest',
        },
      },
    }
  end,
  keys = {
    { '<leader>ta', "<cmd>lua require('neotest').run.run(vim.fn.getcwd())<cr>", desc = '[T]est [a]ll' },
    { '<leader>tf', "<cmd>lua require('neotest').run.run(vim.fn.expand('%'))<cr>", desc = '[T]est current [f]ile' },
    { '<leader>tn', "<cmd>lua require('neotest').run.run()<cr>", desc = '[T]est nearest test' },
    { '<leader>tx', "<cmd>lua require('neotest').run.stop()<cr>", desc = 'Stop test' },
    { '<leader>tl', "<cmd>lua require('neotest').run.run_last()<cr>", desc = 'Run last test' },
    { '<leader>tdn', "<cmd>lua require('neotest').run.run({strategy = 'dap'})<cr>", desc = '[T]est debug nearest test' },
    { '<leader>ts', "<cmd>lua require('neotest').summary.toggle({ enter = true })<cr>", desc = 'toggle summary' },
    { '<leader>to', "<cmd>lua require('neotest').output_panel.toggle()<cr>", desc = 'toggle output panel' },
  },
}

Steps to reproduce the behavior: lua require('neotest').summary.toggle({ enter = true })

Logs Log of a failed run. It seems that somehow the connection to the child process could not be established.

INFO | 2024-07-21T14:52:35Z+0200 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:33 | Starting child process
INFO | 2024-07-21T14:52:35Z+0200 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:36 | Parent address: localhost:64986
INFO | 2024-07-21T14:52:35Z+0200 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:42 | Starting child process with command: /opt/homebrew/Cellar/neovim/0.10.0/bin/nvim --embed --headless -n

here is a log file of a successful run:

INFO | 2024-07-21T14:50:32Z+0200 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:33 | Starting child process
INFO | 2024-07-21T14:50:32Z+0200 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:36 | Parent address: localhost:64927
INFO | 2024-07-21T14:50:32Z+0200 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:42 | Starting child process with command: /opt/homebrew/Cellar/neovim/0.10.0/bin/nvim --embed --headless -n
ERROR | 2024-07-21T14:50:33Z+0200 | ...l/share/nvim/lazy/neotest/lua/neotest/lib/subprocess.lua:57 | Child process is waiting for input at startup. Aborting.
INFO | 2024-07-21T14:50:33Z+0200 | ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:378 | Initialising client
INFO | 2024-07-21T14:50:33Z+0200 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:48 | Emitting starting event
DEBUG | 2024-07-21T14:50:33Z+0200 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:50 | Calling listener summary for event starting
INFO | 2024-07-21T14:50:33Z+0200 | ...al/share/nvim/lazy/neotest/lua/neotest/adapters/init.lua:18 | Found 1 adapters for directory /Users/xxx/Code/xxx/main
DEBUG | 2024-07-21T14:50:33Z+0200 | ...al/share/nvim/lazy/neotest/lua/neotest/adapters/init.lua:19 | Adapters: { {
    adapter = {
      build_spec = <function 1>,
      discover_positions = <function 2>,
      filter_dir = <function 3>,
      is_test_file = <function 4>,
      name = "neotest-python",
      results = <function 5>,
      root = <function 6>,
      <metatable> = {
        __call = <function 7>
      }
    },
    root = "/Users/xxx/xxx/main"
  } }
INFO | 2024-07-21T14:50:33Z+0200 | ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:279 | Searching /Users/xxx/Code/xxx/main for test files
...

Additional context neotest-python 0.07ms  start dir /Users/julianfrenzel/.local/share/nvim/lazy/neotest-python url https://github.com/nvim-neotest/neotest-python branch master commit 2e83d2b readme README.md

neotest  ts  to  ta  tf  tn  tx  tl  tdn dir /Users/julianfrenzel/.local/share/nvim/lazy/neotest url https://github.com/nvim-neotest/neotest version 5.4.0 tag v5.4.0 branch master commit 32ff2ac readme README.md help |neotest.txt|

chuan2984 commented 1 month ago

i have the same problem, in fact, i have been having this problem since I installed neotest. As much as I like using it, i just had to disable it this week because of the amount of restarts that i have to do since it just hangs. Sometimes you can quit by repeatedly hitting ctrl+c, and im usually presented with some error message pointing to nio

trobrock commented 2 weeks ago

@chuan2984 I'm having the same issue, it freezes a few times daily.

chuan2984 commented 6 days ago

@trobrock i havent bothered digging into it. I could do a git bisect or start fresh to see if its a compatibility issue, but i have not bothered. I mainly run my tests inside docker, the only parts that I find myself missing are: test treeview, and the ability to run a test where my cursor is at. Im just planning on writing a small script that would use wezterm to split the pane and run some bash commands to get the test result for accomplishing the test running part which might just suffice.