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-zig does not function in a native windows environment #29

Closed
MagicalBearClaw opened this issue Aug 17, 2024 · 6 comments
Closed
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@MagicalBearClaw
Copy link
Contributor

MagicalBearClaw commented Aug 17, 2024

Describe the bug
Currently neotest-zig is not supported/does not work on windows. It seems that from reading previous issues that there was some compatibility in previous versions? I don't know under what circumstances it was compatible.

Right now I am running neovim, neotest, neotest-zig on a native windows 11 x64 machine.

Steps To Reproduce

  1. Create a Windows machine 11 x64 installation
  2. Install chocolatey
  3. Using chocolatey, install neovim, zig
  4. Setup neo-test and and neo-test-zig
  5. run zig init to initialize a new project
  6. Try running tests with neo-test

Current behavior

Running tests will give an error of
C:\ProgramData\chocolatey\lib\zig\tools\zig-windows-x86_64-0.13.0\lib\std\posix.zig:101:33: error: root struct of file 'c' has no member named 'STDERR_FILENO' pub const STDERR_FILENO = system.STDERR_FILENO; ~~~~~~^~~~~~~~~~~~~~ C:\ProgramData\chocolatey\lib\zig\tools\zig-windows-x86_64-0.13.0\lib\std\c.zig:1:1: note: struct declared here const std = @import("std");

Expected behavior

I expect the test runner to run the tests in a windows environment without test runner errors.

Environment

  • OS: Windows 11 x64
  • Zig version: 0.13.0
  • Nvim version: NVIM v0.10.0
  • Neotest version: v5.4.0
  • Neotest Zig version: 1.2.0

Additional context

I looked into the error myself and have started an attempt to fix it. The current issue is because of the use of try std.posix.dup2 methods calls. They zig posix API is not supported on windows (from I understand and what I have been reading).

If you try to use std.posix.dup2 in a zig init base project will generate the same error. as mentioned above.

@MagicalBearClaw MagicalBearClaw added the bug Something isn't working label Aug 17, 2024
@lawrence-laz
Copy link
Owner

Hi,

Yes, Windows is not currently supported. As you've found out dup2 is only supported by POSIX environments. We use dup2 to redirect the stderr stream to a test result file, as Zig prints test output to stderr. Would WSL be an option for you?

There were some issues in the past with Windows that I managed to resolve, but I don't think I can support that platform alone as I don't use/have a Windows system readily available.

If you, or someone else, manages to bring Windows support, then a PR would be appreciated. I can hopefully help with some questions if there are any.

@lawrence-laz lawrence-laz added enhancement New feature or request help wanted Extra attention is needed and removed bug Something isn't working labels Aug 17, 2024
@MagicalBearClaw
Copy link
Contributor Author

Hey thanks for the quick response.

Unfortunately, do to the nature of the work I want to do(game dev, computer graphics) a windows environment would be better suited.

I would not mind looking into bringing windows support. Would you object to have Neotest-zig link against libc or is that a nonstarter?

Thanks for your time.

@lawrence-laz
Copy link
Owner

I don't mind linking against libc by itself, but due to zig code in this plugin being injected into build process via --build-file and -Dneotest-runner I'm not sure how would that affect running tests on user codebases which don't link against libc and those who already link to libc. Both scenarios should be supported. As long as there are no issues with that we could link against libc.

@lawrence-laz
Copy link
Owner

Is this now solved by #30, or is there more work needed to have Windows working?

@MagicalBearClaw
Copy link
Contributor Author

MagicalBearClaw commented Aug 18, 2024

To my knowledge and testing that should be it for now. Depending on what #9 does, it may need more support but everything else should be good.

@lawrence-laz
Copy link
Owner

I'm closing this issue then. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants