From e2c6a0f67433b2b58a97e1e4fa9555218409ea47 Mon Sep 17 00:00:00 2001 From: Masaaki Hirotsu Date: Wed, 3 Jun 2026 10:55:10 +0900 Subject: [PATCH] test(persist): stabilize flaky session write fixture on nightly CI The write_and_wait helper drove the async store.write path (libuv fs_open/fs_write/fs_rename callback chain), which intermittently failed on the nightly CI job with "Store write failed" during before_each and after_each cleanup writes. Switch the fixture to the synchronous store.write_sync so setup/teardown writes are deterministic and no longer subject to the transient async-fs race. The async write path stays covered by the save_current and "async save write fails" tests. --- tests/persist_sessions_spec.lua | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/persist_sessions_spec.lua b/tests/persist_sessions_spec.lua index fe0b083..f8fb7c9 100644 --- a/tests/persist_sessions_spec.lua +++ b/tests/persist_sessions_spec.lua @@ -64,21 +64,15 @@ describe("peekstack.persist.sessions", function() return { path = path, model = model } end + ---Write store data synchronously for deterministic test setup/teardown. + ---The async `store.write` path is exercised separately by the save/restore + ---tests below; using the sync path for fixture writes avoids a transient + ---libuv fs race (`fs_open`/`fs_write`/`fs_rename` callback chain) that made + ---the nightly CI job flaky during `before_each`/`after_each` cleanup writes. ---@param scope string ---@param data PeekstackStoreData local function write_and_wait(scope, data) - local done = false - local success = false - store.write(scope, data, { - on_done = function(ok) - done = true - success = ok - end, - }) - local ok = vim.wait(wait_timeout_ms, function() - return done - end, wait_interval_ms) - assert.is_true(ok, "Timed out waiting for store write") + local success = store.write_sync(scope, data) assert.is_true(success, "Store write failed") end