lawrence-laz / neotest-zig Goto Github PK
View Code? Open in Web Editor NEWTest runner for Zig in Neovim using Neotest backend.
License: MIT License
Test runner for Zig in Neovim using Neotest backend.
License: MIT License
Describe the bug
The video in the README (
https://github.com/lawrence-laz/neotest-zig/assets/8823448/2e959ca5-db2a-4eee-a422-48c11e853595) is not playable.
The video does not play unless I am using Chrome.
The video should play in all browsers, or when downloaded.
We may want to look at another format.
Note: this is a docs-only issue.
Describe the bug
Inside a repository containing no zig file (and there are no zig files in any of its parent directories either), invoking neotest.run.run()
hangs forever.
Minimal setup:
require('neotest').setup {
adapters = {
require('neotest-go'),
require('neotest-zig'),
},
}
neotest
hangs on Parsing tests step. There is no log when debug logging is enabled. This seems to be caused by this line here
neotest-zig/lua/neotest-zig/init.lua
Line 12 in 5cdcd36
I changed the match pattern to just *.zig
, and everything seems fine. It might hang because of the recursive searching inside each parent directory.
neotest-zig
shouldn't block other adapters from running.
Neotest supports DAP debugging for tests.
Need to set it up either with lldb or gdb, depending on what's available.
Describe the bug
Running lua require("neotest").run.run()
gives the output No tests found
.
Running lua require("neotest").run.run(vim.fn.expand("%"))
results in a forever pending result (see screenshot)
A report of how many tests passed/failed
The file was called main.zig
and it was the only file in the folder
Installation using packer.nvim:
use {
"nvim-neotest/neotest",
requires = {
"lawrence-laz/neotest-zig",
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"antoinemadec/FixCursorHold.nvim"
},
config = function()
require("neotest").setup({
adapters = {
require("neotest-zig"), -- Registration
}
})
end
}
The config option actually didnt seem to work so i made a file called /after/plugin/neotest.lua
and put this in it:
local nt = require("neotest")
nt.setup({
adapters = {
require("neotest-zig"), -- Registration
}
})
which actually runs
My :TSConfigInfo
command gives this under ensure_installed
: { "c", "lua", "vim", "query", "javascript", "rust", "zig", "cpp" }
The adapter can now run single test files, but if they have dependencies on other modules, the tests will never pass.
An example can be found in nested container tests from zig docs.
Ideally the user should not have to do anything else, and the tests should import required modules.
Describe the bug
When neotest-zig adapter is enabled, alongside another plugin, such as neotest-go, it's can get selected incorrectly if it's the earlier adapter that is being tested first.
I believe the adapter selection may happen due to the root definition at
Neotest returns the root if any of the matches are found (source). And, since .git
is a directory that will exist in any git repo, it always matches, which is incorrect.
As far as I understand, neotest should run for .zig
files even if they aren't detected in a project. So if the root dir does not have any .zig
files, then the root dir will not be detected as a zig project, but zig tests can still run in individual files (see docs)
zig
.Using the zig adapter alongside another neotest adapter takes away the ability to use the other adapter.
One should be able to use neotest-zig alongside any neotest-* adapter without this unexpected side effect.
No neotest-zig logs should actually be emitted for this issue, so I didn't bother enabling logging and running those. But, here's the relevant neotest.log excerpt from when neotest ran in a Go test module:
INFO | 2024-04-02T16:00:14Z+0100 | ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:380 | Initialising client
INFO | 2024-04-02T16:00:14Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:48 | Emitting starting event
DEBUG | 2024-04-02T16:00:14Z+0100 | ...are/nvim/lazy/neotest/lua/neotest/client/events/init.lua:50 | Calling listener summary for event starting
INFO | 2024-04-02T16:00:14Z+0100 | ...al/share/nvim/lazy/neotest/lua/neotest/adapters/init.lua:18 | Found 1 adapters for directory /home/asfaltboy/Code/learning/gophercises/ex-01-quiz
DEBUG | 2024-04-02T16:00:14Z+0100 | ...al/share/nvim/lazy/neotest/lua/neotest/adapters/init.lua:19 | Adapters: { {
adapter = {
_debug_log_path = "/home/asfaltboy/.local/share/nvim/neotest-zig.log",
_does_file_contain_tests = <function 1>,
_enable_debug_log = <function 2>,
_is_debug_log_enabled = false,
_test_treesitter_query = "\t;;query\n\t(TestDecl\n\t\t[(IDENTIFIER) (STRINGLITERALSINGLE)] @test.name\n\t) @test.definition\n",
build_spec = <function 3>,
discover_positions = <function 4>,
get_strategy_config = <function 5>,
get_test_node_by_runspec = <function 6>,
is_test_file = <function 7>,
name = "neotest-zig",
results = <function 8>,
root = <function 9>,
setup = <function 10>,
version = "v1.0.5",
<metatable> = {
__call = <function 11>
}
},
root = "/home/asfaltboy/Code/learning/gophercises/ex-01-quiz"
} }
test "add"
works, but the other two tests don't.
fn add(a: anytype, b: anytype) @TypeOf(a, b) {
return a + b;
}
test "add" {
try std.testing.expectEqual(3, add(1, 2));
}
test add {
try std.testing.expectEqual(3, add(1, 2));
}
test {
try std.testing.expectEqual(3, add(1, 2));
}
We can get test add
working just by changing this line:
@@ -61,7 +61,7 @@ function M.discover_positions(path)
local query = [[
;;query
(TestDecl
- (STRINGLITERALSINGLE) @test.name
+ [(IDENTIFIER) (STRINGLITERALSINGLE)] @test.name
) @test.definition
]]
log.debug("Running query", query)
I couldn't figure out a way to capture unnamed tests, but that's mainly because I'm unfamiliar with the system, I'm sure its doable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.