Closed pczora closed 8 months ago
I have the same problem. I have tested this with nvim v0.9.1 and v0.9.0 as I thought they have somehow changed the API. However none of them worked. This is basically a blocker.
Same here too
Will take a look soon
Actually, @pczora , it perfectly works for me.
I have created new droplet on Digital Ocean:
1 GB Memory / 25 GB Disk / LON1 - Ubuntu 22.04 (LTS) x64
I called go file that you provided main_test.go
and changed package to main
.
I put your config to lua/init.lua and run:
nvim -u lua/init.lua main_test.go
then
:lua require("neotest").run.run()
My nvim --version
:
NVIM v0.10.0-dev-530+g8376e8700
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_TS_HAS_SET_MAX_START_DEPTH -I/build/nvim/parts/nvim/build/.deps/usr/include/luajit-2.1 -I/usr/include -I/build/nvim/parts/nvim/build/.deps/usr/include -I/build/nvim/parts/nvim/build/build/src/nvim/auto -I/build/nvim/parts/nvim/build/build/include -I/build/nvim/parts/nvim/build/build/cmake.config -I/build/nvim/parts/nvim/build/src
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
For me still no luck. I have used the @pczora config:
-- ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))
vim.opt.termguicolors = true
-- append test directory
local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))
-- install packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
vim.cmd("packadd packer.nvim")
install_plugins = true
end
local packer = require("packer")
packer.init({
package_root = test_dir .. "/pack",
compile_path = test_dir .. "/plugin/packer_compiled.lua",
})
packer.startup(function(use)
use("wbthomason/packer.nvim")
use({
"nvim-neotest/neotest",
requires = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/neotest-go",
-- Your other test adapters here
},
config = function()
-- get neotest namespace (api call creates or returns namespace)
local neotest_ns = vim.api.nvim_create_namespace("neotest")
vim.diagnostic.config({
virtual_text = {
format = function(diagnostic)
local message =
diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
return message
end,
},
}, neotest_ns)
require("neotest").setup({
-- your neotest config here
adapters = {
require("neotest-go"),
},
})
end,
})
if install_plugins then
packer.sync()
end
end)
vim.cmd([[
command! NeotestSummary lua require("neotest").summary.toggle()
command! NeotestFile lua require("neotest").run.run(vim.fn.expand("%"))
command! Neotest lua require("neotest").run.run(vim.fn.getcwd())
command! NeotestNearest lua require("neotest").run.run()
command! NeotestDebug lua require("neotest").run.run({ strategy = "dap" })
command! NeotestAttach lua require("neotest").run.attach()
command! NeotestOutput lua require("neotest").output.open()
]])
placed it to ~/.config/init.lua
as usual.
Then used this test file:
package main
import "testing"
func Test_a(t *testing.T) {
tests := []struct {
name string
want int
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := a()
if (err != nil) != tt.wantErr {
t.Errorf("a() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("a() = %v, want %v", got, tt.want)
}
})
}
}
func Test_main(t *testing.T) {
tests := []struct {
name string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
main()
})
}
}
Then placed cursor on the line func Test_a
ran: :NeotestNearest<cr>
... nothing happens, ran it again, got No tests found
in the status line.
neovim version: `NVIM v0.9.1 Build type: Release LuaJIT 2.1.0-beta3
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/__w/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
Run :checkhealth for more info`
lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy
I'm also on Nvim 0.9.1 and it's broken. I noticed that @sergii4 you are on 0.10.0 is it maybe some treesitter thing that only works on the nightly?
I'm also on Nvim 0.9.1 and it's broken. I noticed that @sergii4 you are on 0.10.0 is it maybe some treesitter thing that only works on the nightly?
Yes that was my idea as well as treesitter API is changing a lot. That was the reason I tried both 0.9.0 and 0.9.1, but none of them worked.
@Zeioth what the point in overriding that function? There is name convention for test files in Go and we must follow it:
To write a new test suite, create a file that contains the TestXxx functions as described here, and give that file a name ending in "_test.go". The file will be excluded from regular package builds but will be included when the "go test" command is run.
Hi @jan-xyz, @msvitok77 there were some breaking changes introduced, however it isn't related to neotest
/neotest-go
. Probably an issue need to be opened for nvim-treesotter
.
It doesn't work on my machine as well:
$ uname -a
Darwin Sergiis-MacBook-Pro.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64
@msvitok77 what's the name of test file you run test against?
@msvitok77 what's the name of test file you run test against?
example_test.go... it's a standard golang convention.
@sergii4 ... for the moment I'm using vim-test
(as a workaround) as I need to do my work and it works with that plugin 🤷🏻♂️ . However I like neotest more.
@msvitok77 Thanks! I am asking because not everybody follows that convention.
I assume minimal config is not enough to blame neotest/neotest-go. We need some minimal environment. I assume I can spend some time later on playing with some basic Ubuntu image.
But my experiment with Digital Ocean image shows that neotest/neotest-go are doing just fine.
@msvitok77 Thanks! I am asking because not everybody follows that convention.
I assume minimal config is not enough to blame neotest/neotest-go. We need some minimal environment. I assume I can spend some time later on playing with some basic Ubuntu image.
But my experiment with Digital Ocean image shows that neotest/neotest-go are doing just fine.
Thanks @sergii4. Did you try to use the v0.9.1 (which is the latest stable version of neovim)?
@msvitok77 I didn't. As you can see I tried:
NVIM v0.10.0-dev-530+g8376e8700
@msvitok77 I didn't. As you can see I tried:
NVIM v0.10.0-dev-530+g8376e8700
Yes I read about that. But IMHO the plugin should work with the latest stable version as well. What do you think?
@msvitok77 It indicates that the latest nightly can have something that latest stable build doesn't have if neotest/netest-go version the same. There is a high probability that problem is beyond neotest/netest-go but in neovim/tree-sitter for example
@msvitok77 It indicates that the latest nightly can have something that latest stable build doesn't have if neotest/netest-go version the same. There is a high probability that problem is beyond neotest/netest-go but in neovim/tree-sitter for example
Well yes that's possible. But if I recall correctly, I was using neotest-go with the previous versions of neovim successfully. What I can do is to use the v0.8.3 or v0.8.2 which for sure worked with neotest-go
Well yes that's possible. But if I recall correctly, I was using neotest-go with the previous versions of neovim successfully. What I can do is to use the v0.8.3 or v0.8.2 which for sure worked with neotest-go
But if it works on v0.8.3 or v0.8.2, doesn't work on v0.9.1, works again v0.10.0-dev-530+g8376e8700 why is neotest-go to blame if it haven't changed? 🙂 It doesn't seem logical to me 🤷♂️
Well yes that's possible. But if I recall correctly, I was using neotest-go with the previous versions of neovim successfully. What I can do is to use the v0.8.3 or v0.8.2 which for sure worked with neotest-go
But if it works on v0.8.3 or v0.8.2, doesn't work on v0.9.1, works again v0.10.0-dev-530+g8376e8700 why is neotest-go to blame if it haven't changed? slightly_smiling_face It doesn't seem logical to me man_shrugging
I'm not blaming anyone for the moment :-), just trying to find the problem. I was trying to write my own golang test plugin, but once I noticed how often the treesitter API changes, I gave up on this. So I can try this with older versions and will let you know.
I'm having the same issue with v0.10.0-dev-766+gef44e5972-Homebrew
(I don't expect things to work on dev releases, it's just a version I have on my personal laptop) when using a very simple test setup with main.go
and main_test.go
. Funnily enough, a much more complicated setup that I used on my work laptop worked fine as far as Friday. I'll check in the morning whether it still works.
@sergii4 I can confirm that with versions: v0.8.3 and v0.8.2 it works well. So there were definitely some breaking changes in v0.9.0 and v0.9.1. For the moment I'm sticking with vim-test
plugin as I need something working 🤷🏻♂️
Having the same issue... still no solution??? I'm using v0.9.1
Was experiencing the same problem running NVIM v0.10.0-dev-1031+gc431d820e
require('neotest').summary.open()
TSUpdate go
had no effect on either of the aboveExplicitly uninstalling then installing the go parser had solved the issue tho!
TSUninstall go
TSInstall go
Was experiencing the same problem running NVIM v0.10.0-dev-1031+gc431d820e
[...]
Explicitly uninstalling then installing the go parser had solved the issue tho!
TSUninstall go TSInstall go
Wow! Thank you! This solved it for me also on 0.9!
Was experiencing the same problem running NVIM v0.10.0-dev-1031+gc431d820e [...] Explicitly uninstalling then installing the go parser had solved the issue tho!
TSUninstall go TSInstall go
Wow! Thank you! This solved it for me also on 0.9!
Was experiencing the same problem running NVIM v0.10.0-dev-1031+gc431d820e
- observed that test files were visible but individual tests weren't
require('neotest').summary.open()
- likewise treesitter playground was blank
- running
TSUpdate go
had no effect on either of the aboveExplicitly uninstalling then installing the go parser had solved the issue tho!
TSUninstall go TSInstall go
Happens to me when i use the test_table feature and I kinda need that feature
To be more clear, when I run NeotestFile I get Tests Not Found
Was experiencing the same problem running NVIM v0.10.0-dev-1031+gc431d820e [...] Explicitly uninstalling then installing the go parser had solved the issue tho!
TSUninstall go TSInstall go
Wow! Thank you! This solved it for me also on 0.9!
Was experiencing the same problem running NVIM v0.10.0-dev-1031+gc431d820e
- observed that test files were visible but individual tests weren't
require('neotest').summary.open()
- likewise treesitter playground was blank
- running
TSUpdate go
had no effect on either of the aboveExplicitly uninstalling then installing the go parser had solved the issue tho!
TSUninstall go TSInstall go
Happens to me when i use the test_table feature and I kinda need that feature
To be more clear, when I run NeotestFile I get Tests Not Found
Yes same is happening to me when I turn on the test table feature it tells me no tests found in the whole file but without the test table it will run the tests and has the sign that it passed next to the function.
It seems to be working now after I updated neotest, neotest-go and neovim HEAD.
I currently have the following versions in my lazy-lock.json
:
"neotest": { "branch": "master", "commit": "1e67a504d03def3a6a1125d934cb511680f72555" },
"neotest-go": { "branch": "main", "commit": "1a15e1136db43775214a3e7a598f8930c29c94b7" },
And this is what nvim --version
returns:
NVIM v0.10.0-dev-1080+g676e1d490
Build type: RelWithDebInfo
LuaJIT 2.1.1694316387
Run "nvim -V1 -v" for more info
There was a problem with our queries after parsers update for nvim-treesitter. I merged fix yesterday(#60)
There was a problem with our queries after parsers update for nvim-treesitter. I merged fix yesterday(#60)
Amazing work and thanks for the response. So nice to see each individual case with the tick when it passes. Again thanks for the hard work
Thanks a lot, @vitorf7! It was difficult to understand on what side a problem since there were no breaking changes in neotest-go itself. Even after realising that parsers were updated and we have to align our queries it wasn't so straightforward to find a bug in query that just worked well before.
I am just curious if issue is still relevant or we can close it? @pczora
Thanks a lot, @vitorf7! It was difficult to understand on what side a problem since there were no breaking changes in neotest-go itself. Even after realising that parsers were updated and we have to align our queries it wasn't so straightforward to find a bug in query that just worked well before.
I am just curious if issue is still relevant or we can close it? @pczora
Hey @sergii4 I'm getting false positives here, the tests are showing no errors even when they should...
Could this be because I'm using COC instead of native LSP??? Maybe treesitter...
I'm running the tests with lua require("neotest").run.run(vim.fn.expand("%"))
This is my config:
local neotest = require("neotest")
local neotest_ns = vim.api.nvim_create_namespace("neotest")
require("neodev").setup({
library = { plugins = { "neotest" }, types = true },
})
vim.diagnostic.config({
virtual_text = {
format = function(diagnostic)
local message =
diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
return message
end,
},
}, neotest_ns)
neotest.setup({
adapters = {
require('neotest-jest')({
jestCommand = "npm test --",
jestConfigFile = "custom.jest.config.ts",
env = { CI = true },
cwd = function(path)
return vim.fn.getcwd()
end,
}),
require("neotest-go")({
experimental = {
test_table = true,
},
args = { "-count=1", "-timeout=60s" }
}),
require("neotest-plenary")
},
consumers = {
overseer = require("neotest.consumers.overseer"),
},
overseer = {
enabled = true,
-- When this is true (the default), it will replace all neotest.run.* commands
force_default = false,
},
status = { virtual_text = true },
output = { open_on_run = true },
})
vim.cmd([[
command! NeotestSummary lua require("neotest").summary.toggle()
command! NeotestFile lua require("neotest").run.run(vim.fn.expand("%"))
command! Neotest lua require("neotest").run.run(vim.fn.getcwd())
command! NeotestNearest lua require("neotest").run.run()
command! NeotestDebug lua require("neotest").run.run({ strategy = "dap" })
command! NeotestAttach lua require("neotest").run.attach()
command! NeotestOutput lua require("neotest").output.open()
]])
vim.keymap.set('n', '<space>t', vim.cmd.NeotestFile)
Hi @brianfiszman, I need to take a look closer. It will take some time.
[...] I am just curious if issue is still relevant or we can close it? @pczora
I just checked the exact some config which I provided in my original post; only with a more up to date nvim version:
NVIM v0.10.0-dev-1810+g16561dac3-Homebrew
Build type: Release
LuaJIT 2.1.1696795921
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-16561da/share/nvim"
Run :checkhealth for more info
For me, everything now works as expected. I'll close this issue.
Well funny enough this used to work for me using LazyVim and now no longer works again. When i run it nothing happens and if I try to run again it tells me that 'No tests found'
NVIM v0.10.0-dev-1413+g684e93054-Homebrew
Build type: Release
LuaJIT 2.1.1696795921
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/opt/homebrew/Cellar/neovim/HEAD-684e930/share/nvim"
Run :checkhealth for more info
Also not working for me on LazyVim. I've also tried on the minimal config from OP and that's not working for me either.
I get the same 'No tests found' response, also the summary doesn't show individual test cases and running the whole file or module doesn't actually execute anything.
I've tested the same LazyVim config on rust and that's working fine.
NVIM v0.10.0-dev-1413+g684e93054-Homebrew
Build type: Release
LuaJIT 2.1.1696795921
Run "nvim -V1 -v" for more info
I did a fresh update this morning and everything is working perfectly again. There was a treesitter update, maybe in that. Anyways, all good and love your work.
Sorry to reopen guys, but it still doesn't work for me on Neovim 0.9.4
No tests found and no test are shown in summary window, whatever I do
Tried TSUninstall
and TSInstall
without luck. Any clue?
Thanks
@testinfected make sure you invoke require('nvim-treesitter.configs').setup {..} on startup.
Hello, I'm sorry to comment again, but after reading all comments, I'm thinking this is related to Treesitter updates and it has stopped working recently.
It works if I run tests for the whole module, but for individual test I get "No tests found".
Context With my default config, I do not have problems running any tests, however, diagnostics are not set. If I can manage to reproduce this issue with a minimal config, I'll create another issue. To debug this issue, I want to run neotest-go with a minimal config.
Neovim Version I am running Neovim on macOS;
nvim --version
output:Minimal config This is the config I am using:
If I try to run the tests in this file:
I only see the message 'No tests found'.
The logs only contain this:
So, no call to
go test