Skip to content

neotest hangs when running Go testsΒ #106

@goropikari

Description

@goropikari

Describe the bug
Using the latest flatten.nvim (b17a3e6) causes neotest to hang.
When running tests written in Go with neotest, the process hangs.
After performing a git bisect, I identified that the issue occurs from commit ffb2979 onward.
Commits before this do not exhibit the issue.

Expected behavior
neotest should not hang.

To Reproduce
Steps to reproduce the behavior:

  1. Install the latest flatten.nvim (HEAD).
  2. Use neotest to run the provided Go test file.
  3. Execute lua require('neotest').run.run() on the test file.
  4. Observe that neotest hangs.
package main

import (
	"fmt"
	"testing"
)

func TestHoge(t *testing.T) {
	t.Run("hoge", func(t *testing.T) {
		x := 123
		x++
		fmt.Println(x)
	})
	t.Run("piyo", func(t *testing.T) {
		x := 123
		x++
		fmt.Println(x)
	})
}

Expected behavior
neotest should execute the tests without hanging.

Screenshots
N/A

Minimal Init

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  local out = vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--branch=stable",
    lazyrepo,
    lazypath,
  })
  if vim.v.shell_error ~= 0 then
    vim.api.nvim_echo({
      { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
      { out, "WarningMsg" },
      { "\nPress any key to exit..." },
    }, true, {})
    vim.fn.getchar()
    os.exit(1)
  end
end
vim.opt.rtp:prepend(lazypath)

-- Setup lazy.nvim
require("lazy").setup({
  spec = {
    {
      "nvim-neotest/neotest",
      version = "v5.7.0",
      dependencies = {
        "nvim-neotest/nvim-nio",
        "nvim-lua/plenary.nvim",
        "antoinemadec/FixCursorHold.nvim",
        "nvim-treesitter/nvim-treesitter",
        { "fredrikaverpil/neotest-golang", version = "v1.7.1" }, -- Installation
      },
      config = function()
        require("neotest").setup({
          adapters = {
            require("neotest-golang"), -- Registration
          },
        })
      end,
    },
    {
      "willothy/flatten.nvim",
      opts = {},
      lazy = false,
    },
    {

      "nvim-treesitter/nvim-treesitter",
      version = "*",
      event = "VeryLazy",
      dependencies = {
        "nvim-treesitter/nvim-treesitter-textobjects",
      },
      build = ":TSUpdate",
      config = function()
        vim.defer_fn(function()
          require("nvim-treesitter.configs").setup({
            ensure_installed = { "go" },
            auto_install = true,
            sync_install = false,
            ignore_install = {},
            modules = {},
            highlight = { enable = true },
            indent = { enable = true },
          })
        end, 0)
      end,
    },
  },
  checker = { enabled = true },
})

Desktop (please complete the following information):

  • OS: Ubuntu 24.04 and 24.10
  • Terminal emulator: Alacritty
  • Neovim version: 0.10.3

Additional context

The issue might be related to the recent major refactoring, so this behavior could be intentional. However, I am reporting it in case it is not expected.
I have only tested this issue with Go and have not investigated its behavior with other programming languages.

The investigation was conducted in a devcontainer environment. The full configuration of the environment can be found at the following link:
https://github.com/goropikari/flatten.nvim/tree/neotest/.devcontainer

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions