Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neotest hangs when running Go tests #106

Open
goropikari opened this issue Jan 1, 2025 · 3 comments
Open

neotest hangs when running Go tests #106

goropikari opened this issue Jan 1, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@goropikari
Copy link

goropikari commented Jan 1, 2025

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

@goropikari goropikari added the bug Something isn't working label Jan 1, 2025
@willothy
Copy link
Owner

willothy commented Jan 1, 2025

Ahh this is probably due to Neotest running in a nested Neovim session. I'll see if I can get this fixed today :)

@goropikari
Copy link
Author

Thank you for the quick response. For now, as long as I'm using v0.5.1, there's no issue, so there's no need to rush. Wishing you a Happy New Year!

@willothy
Copy link
Owner

willothy commented Jan 2, 2025

Sounds good! Happy new year to you as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants