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

No test found #37

Open
pcorbineau opened this issue Jan 28, 2025 · 2 comments
Open

No test found #37

pcorbineau opened this issue Jan 28, 2025 · 2 comments
Labels
bug Something isn't working windows

Comments

@pcorbineau
Copy link

Describe the bug
neotest-zig not working. It looks like he doesn't find my test.

Steps To Reproduce

foo.zig

const std = @import("std");

test "basic tests" {
    const expected: u32 = 4;
    try std.testing.expectEqual(expected, 2 + 2);
}

build.zig

const std = @import("std");

pub fn build(b: *std.Build) !void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const test_step = b.step("test", "run unit tests");

    const unit_tests = b.addTest(.{
        .root_source_file = b.path("foo.zig"),
        .target = target,
        .optimize = optimize,
    });

    const run_unit_tests = b.addRunArtifact(unit_tests);
    test_step.dependOn(&run_unit_tests.step);
}

Run neotest

Current behavior

Loading for few seconds :

Image
Then stucks with this :
Image

Expected behavior

Expect a green or red test result

Logs

neotest-zig.log

Environment

  • OS: Windows
  • Zig version: 0.13.0
  • Nvim version: NVIM v0.10.2
  • Neotest version: 5.8.0
  • Neotest Zig version: 1.3.1

Additional context

zig setup seems working since if I dont provide a build.zig with a test step, I got a red test result with appropriate stdout.

** I'm new to zig toolchain so I probably miss something **

zig build test works

@pcorbineau pcorbineau added the bug Something isn't working label Jan 28, 2025
@lawrence-laz
Copy link
Owner

Could not reproduce on linux:

Image

Image

Unfortunately, I don't have a windows machine to test on.

Looking at the logs you attached, it seems like things are going as expected up until the test is executed, i. e. the build.zig file is recognized, the test is found in foo.zig, but the result file is empty:

[TRACE][2025-01-28 13:07:40] ...est-zig/init.lua:509	"Found a "	"file"	"named"	"16256753171039001766"	"in results dir"
[TRACE][2025-01-28 13:07:40] ...est-zig/init.lua:518	"Trying to open results file"	"C:/Users/PCORBI~1/AppData/Local/Temp/nvim.0/npcv3A/2/16256753171039001766"
[TRACE][2025-01-28 13:07:40] ...est-zig/init.lua:527	"Decoded JSON"	{}

Notice the "Decoded JSON" {} part showing an empty object.

Which leads me to believe, that the issue is probably in neotest_runner.zig file, which is responsible for running the tests and writing out the results into a temporary json file.

@pcorbineau
Copy link
Author

As I said, I was trying the plugin while discovering zig in same time. For now, I don't need it. We should let this ticket open if someone else have same issue or if I want to dig into later 👍

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

No branches or pull requests

2 participants