fix(tests): some how i now i need to run vim.treesitter.start() to make it work

This commit is contained in:
Oleksandr Smirnov 2025-03-23 18:40:57 +02:00
parent 47bdebe67d
commit 867d57cfbc
No known key found for this signature in database
3 changed files with 9 additions and 2 deletions

View file

@ -44,12 +44,16 @@ T["struct_tags"]["should add more than one tag"] = function()
--- with comma, like gomodifytags
child.cmd("silent edit " .. tmp)
child.lua "vim.treesitter.start()"
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
child.cmd "GoTagAdd test4,test5"
child.cmd "write"
-- without comma
child.cmd("silent edit " .. tmp)
child.lua "vim.treesitter.start()"
child.fn.setpos(".", { child.fn.bufnr(tmp), 3, 1 })
child.cmd "GoTagAdd test1 test2"
child.cmd "write"

View file

@ -69,6 +69,7 @@ end
---@class gopher.TestUtilsSetup
---@field tmp string
---@field fixtures gopher.TestUtilsFixtures
---@field bufnr number
---@param fixture string
---@param child MiniTest.child
@ -80,13 +81,16 @@ function testutils.setup_test(fixture, child, pos)
testutils.writefile(tmp, fixtures.input)
child.cmd("silent edit " .. tmp)
child.lua "vim.treesitter.start()"
local bufnr = child.fn.bufnr(tmp)
if pos then
child.fn.setpos(".", { child.fn.bufnr(tmp), unpack(pos) })
child.fn.setpos(".", { bufnr, unpack(pos) })
end
return {
tmp = tmp,
bufnr = bufnr,
fixtures = fixtures,
}
end