From 88b627d72dc69d93e23cf7d891079ef2fea49340 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 12 Jul 2026 15:14:57 +0200 Subject: [PATCH] test(autoread): unreliable "coalesces rapid changes via debouncing" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- test/functional/options/autoread_spec.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/functional/options/autoread_spec.lua b/test/functional/options/autoread_spec.lua index 3b7f4310aa..be59da82ee 100644 --- a/test/functional/options/autoread_spec.lua +++ b/test/functional/options/autoread_spec.lua @@ -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()