Closed hexdigest closed 2 years ago
You need to have at least 0.7 so 0.6 won't work.
I'm not sure why you're getting this issue, can you use the following minimal init.lua to reproduce?
nvim --clean -u minimal.lua
-- 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"))
-- 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)
-- Packer can manage itself
use("wbthomason/packer.nvim")
use("vim-test/vim-test")
use({
"nvim-neotest/neotest",
requires = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/neotest-vim-test",
"nvim-neotest/neotest-python",
},
config = function()
require("neotest").setup({
adapters = {
require("neotest-vim-test"),
require("neotest-python"),
},
})
end,
})
if install_plugins then
packer.sync()
end
end)
Hi @rcarriga,
Thank you for the quick reply!
You need to have at least 0.7 so 0.6 won't work.
I'm not sure why you're getting this issue, can you use the following minimal init.lua to reproduce?
I tried the minimal.lua it and there are no lua related errors if I execute:
:lua require("neotest").run.run(vim.fn.expand("%"))
However I see red crosses near the Go tests while tests are actually passing.
Is that with neotest-go or neotest-vim-test that you are running?
In a clean setup that you suggested there's neotest-vim-test In my original setup it was neotest-go (but It's not working because of these lua errors)
OK for neotest-vim-test can you see the error in the output? Also can you add neotest-go and test with that?
With neotest-go plugged in I can reproduce the initial problem I had:
E5108: Error executing lua [string ":lua"]:1: attempt to index field 'run' (a nil value)
stack traceback:
[string ":lua"]:1: in main chunk
When running
:lua require("neotest").run.run(vim.fn.expand("%"))
and
:lua require("neotest").run(vim.fn.expand("%"))
The first one is correct, the second is not. I can't seem to reproduce with neotest-go. Do you have a repo I can try on?
@rcarriga do you mean a go repo with test or a repo with nvim configs?
I spent some time carefully looking at my config and managed to get a different error (doesn't seem related to neotest itself):
E5108: Error executing lua ...m/dein/.cache/init.vim/.dein/lua/plenary/async/async.lua:14: The coroutine failed with this message: Vim:E117: Unknown function: test#test_file
stack traceback:
[C]: in function 'error'
...m/dein/.cache/init.vim/.dein/lua/plenary/async/async.lua:14: in function 'callback_or_next'
...m/dein/.cache/init.vim/.dein/lua/plenary/async/async.lua:40: in function 'step'
...m/dein/.cache/init.vim/.dein/lua/plenary/async/async.lua:43: in function 'execute'
...m/dein/.cache/init.vim/.dein/lua/plenary/async/async.lua:103: in function 'run'
...dein/.cache/init.vim/.dein/lua/neotest/consumers/run.lua:30: in function 'run'
[string ":lua"]:1: in main chunk
This happens when I run:
:lua require("neotest").run.run(vim.fn.expand("%"))
Here are two major pieces of my init.vim:
" neotest requirements
call dein#add("nvim-lua/plenary.nvim")
call dein#add("nvim-treesitter/nvim-treesitter")
call dein#add("antoinemadec/FixCursorHold.nvim")
call dein#add("nvim-neotest/neotest")
call dein#add("nvim-neotest/neotest-vim-test")
call dein#add("nvim-neotest/neotest-go")
call dein#add("nvim-neotest/neotest-plenary")
" end neotest requirements
lua <<EOF
require("neotest").setup({
adapters = {
require("neotest-plenary"),
require("neotest-vim-test")({
ignore_file_types = { "python", "vim", "lua" },
}),
require("neotest-go"),
},
})
EOF
I guess I have latest versions of all plugins because I just updated them with: dein#update()
E5108: Error executing lua ...m/dein/.cache/init.vim/.dein/lua/plenary/async/async.lua:14: The coroutine failed with this message: Vim:E117: Unknown function: test#test_file
You don't have vim-test installed which is causing the issue. Also add go
to the ignored file types for neotest-vim-test to prevent it being used.
E5108: Error executing lua ...m/dein/.cache/init.vim/.dein/lua/plenary/async/async.lua:14: The coroutine failed with this message: Vim:E117: Unknown function: test#test_file
You don't have vim-test installed which is causing the issue. Also add
go
to the ignored file types for neotest-vim-test to prevent it being used.
This indeed eliminated all errors I had but now when I run: :lua require("neotest").run.run(vim.fn.expand("%"))
nothing happens.
When I run :lua require("neotest").run.run()
while the test file is open and a cursor pointing to the very beginning of the file I see "No tests found" message in a status line. The file clearly contains some tests and these tests are passing when being called via go test ./...
from the concole.
Here is the example of the name of the test func:
func TestRule_Compile(t *testing.T) {
When I run :lua require("neotest").output.open()
I see a bit different message in a status line saying the same thing:
"No tests found in file"
OK this now sounds like a neotest-go issue. Could you provide the contents of the log file? It's in stdpath("log")
or stdpath("cache")
@rcarriga here is the piece of log:
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event discover_positions
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event discover_positions
ERROR | 2022-06-17T11:44:56Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /home/max/dev/github.com/project/path>
ERROR | 2022-06-17T11:44:56Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /home/max/dev/github.com/project/path>
ERROR | 2022-06-17T11:44:56Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /home/max/dev/github.com/project/path>
ERROR | 2022-06-17T11:44:56Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /home/max/dev/github.com/project/path>
DEBUG | 2022-06-17T11:44:56Z+0400 | ...dein/.cache/init.vim/.dein/lua/neotest/lib/file/find.lua:46 | Searching for files using command { "find", "/home/max/dev/github.com/>
DEBUG | 2022-06-17T11:44:56Z+0400 | ...dein/.cache/init.vim/.dein/lua/neotest/lib/file/find.lua:72 | Searching for files finished
DEBUG | 2022-06-17T11:44:56Z+0400 | .../.cache/init.vim/.dein/lua/neotest/client/state/init.lua:54 | New positions at ID /home/max/dev/github.com/project/pathe-staki>
INFO | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting discover_positions event
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event discover_positions
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event discover_positions
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event discover_positions
ERROR | 2022-06-17T11:44:56Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /home/max/dev/github.com/project/path>
INFO | 2022-06-17T11:44:56Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:572 | Initialisation finished in 0 seconds
INFO | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting test_file_focused event
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event test_file_focused
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event test_file_focused
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event test_file_focused
DEBUG | 2022-06-17T11:44:56Z+0400 | .../.cache/init.vim/.dein/lua/neotest/client/state/init.lua:78 | Setting positions to running /home/max/dev/github.com/project/path>
INFO | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting run event
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event run
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event run
DEBUG | 2022-06-17T11:44:56Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event run
INFO | 2022-06-17T11:44:56Z+0400 | ...he/init.vim/.dein/lua/neotest/client/strategies/init.lua:30 | Starting process neotest-go-/home/max/dev/github.com/project/path>
DEBUG | 2022-06-17T11:44:56Z+0400 | ...he/init.vim/.dein/lua/neotest/client/strategies/init.lua:31 | Strategy spec {
command = "go test -v -json /project/path/matcher/matcher_test.go",
context = {
file = "/project/path/matcher/matcher_test.go",
results_path = "/tmp/nvimafHvc5/2"
},
strategy = {
height = 40,
width = 120
}
}
INFO | 2022-06-17T11:44:57Z+0400 | ...he/init.vim/.dein/lua/neotest/client/strategies/init.lua:35 | Process for position neotest-go-/home/max/dev/github.com/project/path>
DEBUG | 2022-06-17T11:44:57Z+0400 | ...he/init.vim/.dein/lua/neotest/client/strategies/init.lua:37 | Output of process /tmp/nvimafHvc5/3
ERROR | 2022-06-17T11:44:57Z+0400 | .../nvim/dein/.cache/init.vim/.dein/lua/neotest-go/init.lua:85 | Failed to parse test output:
Expected value but found invalid token at character 1
table: 0x4129b020 /tmp/nvimafHvc5/3
DEBUG | 2022-06-17T11:44:57Z+0400 | .../.cache/init.vim/.dein/lua/neotest/client/state/init.lua:65 | New results for adapter neotest-go
INFO | 2022-06-17T11:44:57Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting results event
DEBUG | 2022-06-17T11:44:57Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event results
DEBUG | 2022-06-17T11:44:57Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event results
DEBUG | 2022-06-17T11:44:57Z+0400 | ...ache/init.vim/.dein/lua/neotest/consumers/diagnostic.lua:57 | Setting diagnostics for /home/max/dev/github.com/project/pathe-s>
DEBUG | 2022-06-17T11:44:57Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener output for event results
ERROR | 2022-06-17T11:44:56Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /home/max/dev/github.com/project/path>
It looks like the lines are cut off. Can you share the full file please. You can delete and rerun with dummy repo if it has sensitive info in it
Oh, I apologize, copy-pasted it from the less output, here are full lines:
INFO | 2022-06-17T13:11:28Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:517 | Initialising client
DEBUG | 2022-06-17T13:11:28Z+0400 | ...dein/.cache/init.vim/.dein/lua/neotest/lib/file/find.lua:46 | Searching for files using command { "find", "/project/path", "-type", "f" }
DEBUG | 2022-06-17T13:11:28Z+0400 | ...dein/.cache/init.vim/.dein/lua/neotest/lib/file/find.lua:72 | Searching for files finished
DEBUG | 2022-06-17T13:11:28Z+0400 | .../.cache/init.vim/.dein/lua/neotest/client/state/init.lua:54 | New positions at ID /project/path
INFO | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting discover_positions event
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event discover_positions
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event discover_positions
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event discover_positions
ERROR | 2022-06-17T13:11:28Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /project/path/calculator/rules/cache/aggregator_test.go /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: no parser for 'go' language, see :help treesitter-parsers
ERROR | 2022-06-17T13:11:28Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /project/path/calculator/rules/mux_test.go /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: no parser for 'go' language, see :help treesitter-parsers
ERROR | 2022-06-17T13:11:28Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /project/path/storage/postgres/postgres_test.go /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: no parser for 'go' language, see :help treesitter-parsers
ERROR | 2022-06-17T13:11:28Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /project/path/matcher/matcher_test.go /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: no parser for 'go' language, see :help treesitter-parsers
DEBUG | 2022-06-17T13:11:28Z+0400 | ...dein/.cache/init.vim/.dein/lua/neotest/lib/file/find.lua:46 | Searching for files using command { "find", "/project/path/matcher", "-type", "f" }
DEBUG | 2022-06-17T13:11:28Z+0400 | ...dein/.cache/init.vim/.dein/lua/neotest/lib/file/find.lua:72 | Searching for files finished
DEBUG | 2022-06-17T13:11:28Z+0400 | .../.cache/init.vim/.dein/lua/neotest/client/state/init.lua:54 | New positions at ID /project/path/matcher
INFO | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting discover_positions event
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event discover_positions
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event discover_positions
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event discover_positions
ERROR | 2022-06-17T13:11:28Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:415 | Couldn't find positions in path /project/path/matcher/matcher_test.go /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: no parser for 'go' language, see :help treesitter-parsers
INFO | 2022-06-17T13:11:28Z+0400 | ...m/dein/.cache/init.vim/.dein/lua/neotest/client/init.lua:572 | Initialisation finished in 0 seconds
INFO | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting test_file_focused event
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event test_file_focused
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event test_file_focused
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event test_file_focused
DEBUG | 2022-06-17T13:11:28Z+0400 | .../.cache/init.vim/.dein/lua/neotest/client/state/init.lua:78 | Setting positions to running /project/path/matcher/matcher_test.go
INFO | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting run event
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event run
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event run
DEBUG | 2022-06-17T13:11:28Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event run
INFO | 2022-06-17T13:11:28Z+0400 | ...he/init.vim/.dein/lua/neotest/client/strategies/init.lua:30 | Starting process neotest-go-/project/path/matcher/matcher_test.go with strategy integrated
DEBUG | 2022-06-17T13:11:28Z+0400 | ...he/init.vim/.dein/lua/neotest/client/strategies/init.lua:31 | Strategy spec {
command = "go test -v -json /project/path/matcher/matcher_test.go",
context = {
file = "/project/path/matcher/matcher_test.go",
results_path = "/tmp/nvimqdUyFp/2"
},
strategy = {
height = 40,
width = 120
}
}
INFO | 2022-06-17T13:11:29Z+0400 | ...he/init.vim/.dein/lua/neotest/client/strategies/init.lua:35 | Process for position neotest-go-/project/path/matcher/matcher_test.go exited with code 2
DEBUG | 2022-06-17T13:11:29Z+0400 | ...he/init.vim/.dein/lua/neotest/client/strategies/init.lua:37 | Output of process /tmp/nvimqdUyFp/3
ERROR | 2022-06-17T13:11:29Z+0400 | .../nvim/dein/.cache/init.vim/.dein/lua/neotest-go/init.lua:85 | Failed to parse test output:
Expected value but found invalid token at character 1
table: 0x40db5fe0 /tmp/nvimqdUyFp/3
DEBUG | 2022-06-17T13:11:29Z+0400 | .../.cache/init.vim/.dein/lua/neotest/client/state/init.lua:65 | New results for adapter neotest-go
INFO | 2022-06-17T13:11:29Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:46 | Emitting results event
DEBUG | 2022-06-17T13:11:29Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener status for event results
DEBUG | 2022-06-17T13:11:29Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event results
DEBUG | 2022-06-17T13:11:29Z+0400 | ...ache/init.vim/.dein/lua/neotest/consumers/diagnostic.lua:57 | Setting diagnostics for /project/path/matcher/matcher_test.go {}
DEBUG | 2022-06-17T13:11:29Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener output for event results
DEBUG | 2022-06-17T13:11:29Z+0400 | ....cache/init.vim/.dein/lua/neotest/client/events/init.lua:48 | Calling listener summary for event results
It seem's like I had to run:
:TSInstall go
first
Now it seems like neotest is able to find tests in the file and the :lua require("neotest").output.open()
works but shows nothing:
1 package matcher
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 "github.com/stretchr/testify/require"
8 )
9
ﰸ 10 func TestRule_Compile(t *testing.T) {
11 tests := []struct╭────────────────────────────────────────────────────────────────────────────────╮
12 name string │ │
13 init func(t │ │
14 inspect func(r │ │
15 │ │
16 env interface{}│ │
17 ╰────────────────────────────────────────────────────────────────────────────────╯
18 wantErr bool
19 inspectErr func(err error, t *testing.T)
Ok, It seems like it works after restart:
1 package matcher
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 "github.com/stretchr/testify/require"
8 )
9
✖ 10 func TestRule_Compile(t *testing.T) {
11 tests := []struct ╭────────────────────────────────────────────────────────────────────────────────╮
12 name string │=== RUN TestRule_Compile │
13 init func(t *│=== RUN TestRule_Compile/error │
14 inspect func(r *│ matcher_test.go:62: │
15 │ Error Trace:matcher_test.go:62 │
16 env interface{} │ Error: Received unexpected error: │
17 │ unexpected token Operator("=") (1:5) │
18 wantErr bool │ | a.b = b.c │
19 inspectErr func(│ | ....^ │
20 }{ │ expr.Compile("a.b = b.c") │
21 { │ Test: TestRule_Compile/error │
22 name: "error",│=== RUN TestRule_Compile/success │
23 init: func(t *│--- FAIL: TestRule_Compile (0.00s) │
24 return &Rule│ --- FAIL: TestRule_Compile/error (0.00s) │
25 Name: │ --- PASS: TestRule_Compile/success (0.00s) │
26 Expression│ │
27 } ╰────────────────────────────────────────────────────────────────────────────────╯
28 },
29 wantErr: false,
30 },
Ok I think I have the last problem:
:lua require("neotest").run.run(vim.fn.expand("%"))
doesn't seem to work. When I run it it does nothing but
:lua require("neotest").run.run()
works as expected
I'm going to ask you to move these issues to neotest-go because I'm afraid I have no idea why that would not work and I didn't write neotest-go.
@rcarriga Ok, no problem, thanks for you help.
Going to close this as I believe there are no issues in the core repo to address
Can't get this working. First I tried latest stable version from ubuntu ppa, 0.6.x Then I updated neovim from unstable ppa to 0.8.0-dev and non of examples working, but giving a bit different output.