fredrikaverpil / neotest-golang

Reliable Neotest adapter for running Go tests in Neovim.
MIT License
141 stars 17 forks source link

feat: windows support #149

Closed fredrikaverpil closed 4 months ago

fredrikaverpil commented 4 months ago

This PR introduces a distinction between forward slashes (unix) and backslashes (windows) in filepaths.

However, there's a huge problem with ANSI codes and other stuff is garbling up the JSON output from go test -json. Very strange. Only happens on Windows (Powershell). A workaround is to use gotestsum as runner, which will then write to JSON file without a console roundtrip:

# make gotestsum available on $PATH by installing it
go install gotest.tools/gotestsum@latest

Then set the (for now undocumented/experimental) runner option, and instruct it to use gotestsum instead of go test:

  {
    "nvim-neotest/neotest",
    dependencies = {
      "nvim-neotest/nvim-nio",
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter",
      {
        "fredrikaverpil/neotest-golang",
        branch = "windows", -- set PR branch
      },
    },
    config = function()
      require("neotest").setup({
        adapters = {
          require("neotest-golang")({ runner = "gotestsum" }), -- Registration with config
        },
      })
    end,
  },

Fixes: #147