lawrence-laz / neotest-zig

Test runner for Zig in Neovim using Neotest backend.
MIT License
27 stars 7 forks source link

Deprecation error on compile #23

Closed ziontee113 closed 5 months ago

ziontee113 commented 5 months ago

Describe the bug I updated Zig and ZLS today both to version 0.13, I tried to run tests on a file and got this error:

test
└─ run test
   └─ zig test Debug native 1 errors
/usr/lib/zig/std/debug.zig:101:5: error: deprecated. call std.debug.lockStdErr() and st
d.debug.unlockStdErr() instead which will integrate properly with std.Progress
    @compileError("deprecated. call std.debug.lockStdErr() and std.debug.unlockStdErr()
 instead which will integrate properly with std.Progress");
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    runnerLogFn__anon_9759: /home/ziontee113/.local/share/nvim/lazy/neotest-zig/zig/neo
test_runner.zig:27:20
    log__anon_9409: /usr/lib/zig/std/log.zig:125:22
    remaining reference traces hidden; use '-freference-trace' to see all reference tra
ces
error: the following command failed with 1 compilation errors:
/usr/bin/zig test -ODebug -Mroot=/mnt/136gb_SSD/learn-zig/hello-zig/src/main.zig --test
-runner /home/ziontee113/.local/share/nvim/lazy/neotest-zig/zig/neotest_runner.zig --ca
che-dir /mnt/136gb_SSD/learn-zig/hello-zig/.zig-cache --global-cache-dir /home/ziontee1
13/.cache/zig --name test --listen=- 
test
└─ run test
   └─ zig test Debug native 1 errors
/usr/lib/zig/std/debug.zig:101:5: error: deprecated. call std.debug.lockStdErr() and st
d.debug.unlockStdErr() instead which will integrate properly with std.Progress
    @compileError("deprecated. call std.debug.lockStdErr() and std.debug.unlockStdErr()
 instead which will integrate properly with std.Progress");
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    runnerLogFn__anon_9651: /home/ziontee113/.local/share/nvim/lazy/neotest-zig/zig/neo
test_runner.zig:27:20
    log__anon_8980: /usr/lib/zig/std/log.zig:125:22
    remaining reference traces hidden; use '-freference-trace' to see all reference tra
ces
error: the following command failed with 1 compilation errors:
/usr/bin/zig test -ODebug -Mroot=/mnt/136gb_SSD/learn-zig/hello-zig/src/root.zig --test
-runner /home/ziontee113/.local/share/nvim/lazy/neotest-zig/zig/neotest_runner.zig --ca
che-dir /mnt/136gb_SSD/learn-zig/hello-zig/.zig-cache --global-cache-dir /home/ziontee1
13/.cache/zig --name test --listen=- 
Build Summary: 0/5 steps succeeded; 2 failed (disable with --summary none)

Solution

In neotest_runner.zig:

  1. Replace defer std.debug.getStderrMutex().unlock(); with defer std.debug.unlockStdErr();
  2. Replace std.debug.getStderrMutex().lock(); with std.debug.lockStdErr();
  3. Everything works fine.
lawrence-laz commented 5 months ago

Are you sure you are using the latest main of neotest-zig and don't have any local changes?

This commit https://github.com/lawrence-laz/neotest-zig/commit/72a508ae56862419a04aac3723176c82ff6ca49b addressed this issue for both Zig v0.13 and v0.12.

Looking at stack trace it seems like the new function, which was introduced in the mentioned commit, was not called in your case.

ziontee113 commented 5 months ago

Sorry it's my bad. I only removed the commit lock option in my config without actually update the plugin :sweat_smile:. I updated neotest-zig properly and everything's working. Thank you very much!