Skip to content

Commit 0995ce5

Browse files
committed
test: shenanigans
1 parent 5a4125a commit 0995ce5

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

tests/bootstrap.lua

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,19 @@ for _, lang in ipairs(parsers) do
2323
if vim.fn.filereadable(parser_file) ~= 1 then
2424
print('Installing ' .. lang .. '...')
2525

26-
-- Start async installation and wait for completion
26+
-- Start async installation
2727
local task = install.install({ lang }, { summary = false })
2828

29-
if task and task.pwait then
30-
local ok, err = task:pwait(30000) -- Max 30 seconds per parser (way more than needed)
31-
if not ok then
32-
error(string.format('Failed to install %s parser: %s', lang, err or 'unknown error'))
33-
end
34-
end
35-
36-
-- Give the event loop one tick to flush any pending file writes
37-
vim.wait(100)
29+
-- pwait() just waits for the task to "complete", but the task completes
30+
-- when compilation STARTS, not when it finishes. So we can't trust it.
31+
-- Instead, just poll for the .so file to appear (which means compilation finished)
32+
local timeout = 30000 -- 30 seconds should be way more than needed
33+
local ok = vim.wait(timeout, function()
34+
return vim.fn.filereadable(parser_file) == 1
35+
end, 100)
3836

39-
-- Verify the file exists
40-
if vim.fn.filereadable(parser_file) ~= 1 then
41-
error(string.format('%s parser .so file not found at %s', lang, parser_file))
37+
if not ok then
38+
error(string.format('%s parser .so file not found after %ds', lang, timeout / 1000))
4239
end
4340

4441
print(lang .. ' parser installed')

0 commit comments

Comments
 (0)