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

feat: windows support #149

Merged
merged 19 commits into from
Jul 23, 2024
Merged

feat: windows support #149

merged 19 commits into from
Jul 23, 2024

Conversation

fredrikaverpil
Copy link
Owner

@fredrikaverpil fredrikaverpil commented Jul 21, 2024

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

@fredrikaverpil fredrikaverpil self-assigned this Jul 21, 2024
@fredrikaverpil fredrikaverpil mentioned this pull request Jul 21, 2024
2 tasks
@fredrikaverpil fredrikaverpil marked this pull request as draft July 21, 2024 19:37
look for backslashes on windows, forward slashes on unix
@fredrikaverpil fredrikaverpil marked this pull request as ready for review July 23, 2024 07:48
@fredrikaverpil fredrikaverpil merged commit 956ba1b into main Jul 23, 2024
8 checks passed
@fredrikaverpil fredrikaverpil deleted the windows branch July 23, 2024 07:50
@fang2hou
Copy link

It is not only Windows Powershell, I also met the problem in macOS.
But after I set the runner to gotestsum, everything works great!

@fredrikaverpil
Copy link
Owner Author

It is not only Windows Powershell, I also met the problem in macOS.

But after I set the runner to gotestsum, everything works great!

Out of curiosity, which terminal are you on?

@fang2hou
Copy link

It is not only Windows Powershell, I also met the problem in macOS.
But after I set the runner to gotestsum, everything works great!

Out of curiosity, which terminal are you on?

I am using Wezterm in macOS.
And I am working with a project with many Japanese characters in the code (test name, comment, some t.Error message, etc.).

@fredrikaverpil
Copy link
Owner Author

Aha, I see. I would assume it's the Japanese characters that might be causing this. I've been using Wezterm for a long time without any issues, but never with Japanese characters. 😅

Anyway, I'm happy to hear you can use the adapter with the help of gotestsum!

@fredrikaverpil
Copy link
Owner Author

By the way, if you have the possibility, would you mind trying setting the environment variable LC_ALL=C (before starting Neovim, so that any go test command it spawns will use it) and see if that makes a difference?

@fredrikaverpil
Copy link
Owner Author

By the way, if you have the time and possibility, would you mind trying setting the environment variable LC_ALL=C (before starting Neovim, so that any go test command it spawns will use it) and see if that makes a difference?

export LC_ALL=C

@fang2hou
Copy link

@fredrikaverpil
The LC_ALL is actually not working in my MacBook.
However I also found the following comment, after setting alias gcc="gcc-14", everything works fine.
#193 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: windows not supported
2 participants