test(autoread): unreliable "coalesces rapid changes via debouncing"

previous: #40272

    FAILED   …/autoread_spec.lua @ 142: autoread file watcher coalesces rapid changes via debouncing
    Expected values to be equal.
    Expected:
    1
    Actual:
    2
    stack traceback:
    …/autoread_spec.lua:169: in function <…/autoread_spec.lua:142>
This commit is contained in:
Justin M. Keyes
2026-07-12 15:14:57 +02:00
parent 83ced05984
commit 88b627d72d

View File

@@ -163,10 +163,13 @@ describe('autoread file watcher', function()
eq({ 'final' }, api.nvim_buf_get_lines(0, 0, -1, true))
end)
-- Let any late-arriving event flush (> debounce window), then assert all 4 writes coalesced.
-- Every fs_event restarts the debounce timer, so the timer fires exactly once.
-- Debouncing collapses 4 writes into (ideally) 1 reload. But we assert "<=2" bc OS filewatch
-- events may arrive in multiple batches under CI load => a straggler may arrive after the
-- debounce window and trigger a second reload.
-- The buffer already holds "final" (checked above); without debouncing each write would reload.
sleep(250)
eq(1, n.exec_lua('return _G.reloads'))
local reloads = n.exec_lua('return _G.reloads')
t.ok(reloads >= 1 and reloads <= 2, '1 or 2 reloads (4 writes coalesced)', reloads)
end)
it("bumps 'busy' on each watched buffer while a reload is pending", function()