diff --git a/spec/TESTING.md b/spec/TESTING.md deleted file mode 100644 index 3fe2f39..0000000 --- a/spec/TESTING.md +++ /dev/null @@ -1,49 +0,0 @@ -# Test Framework Migration Log - -Issues encountered during the plenary-to-busted migration (`6be0148`) and -how they were resolved. - -## Final status - -114 successes / 0 failures / 0 errors. - -## Issue 1: altbuf_spec.lua:18 — BufEnter wait mismatch (resolved) - -The test `sets previous buffer as alternate when editing url file` originally -waited for two `BufEnter` events via `wait_for_autocmd('BufEnter')` x2. - -The oil:// → real file resolution only produces one async BufEnter: - -1. `vim.cmd.edit('oil://...')` fires BufEnter synchronously (before any - wait_for_autocmd is registered) -2. `normalize_url` resolves asynchronously via `uv.fs_realpath` + `uv.fs_stat` -3. `rename_buffer` discovers dest is a real file on disk, schedules - `nvim_win_set_buf()` via `vim.schedule()` -4. `nvim_win_set_buf()` fires one async BufEnter on the real file buffer - -The second `wait_for_autocmd('BufEnter')` was never correct — it passed under -plenary due to coroutine event loop yielding, not because a second BufEnter -actually fired. - -**Fix:** single `wait_for_autocmd('BufEnter')`. - -## Issue 2: regression_spec.lua:20 — stale preview window state (resolved) - -`reset_editor()` closed all windows except the first, but the surviving window -could be a preview window with stale `oil_preview`, `oil_source_win`, -`previewwindow`, etc. from a prior test. Subsequent tests that triggered -`close_preview_window_if_not_in_oil()` would close the wrong window. - -**Fix:** `vim.cmd.new()` + `vim.cmd.only()` creates a fresh window and closes -all others (including the stale one). No variable cleanup needed — the new -window has no oil state. - -## Issue 3: preview_spec.lua:30 — M.await timed out (resolved) - -Originally thought to be a pre-existing issue unrelated to the migration. Root -cause was identical to issue 2: stale preview window state from a prior test -caused `close_preview_window_if_not_in_oil()` to close the wrong window during -`oil.open()`, preventing the callback from completing. - -Fixed by the same `vim.cmd.new()` + `vim.cmd.only()` approach in -`reset_editor()`. diff --git a/spec/altbuf_spec.lua b/spec/altbuf_spec.lua index cd2cf4b..b64bfc0 100644 --- a/spec/altbuf_spec.lua +++ b/spec/altbuf_spec.lua @@ -22,6 +22,7 @@ describe('Alternate buffer', function() local readme = fs.join(vim.fn.getcwd(), 'README.md') vim.cmd.edit({ args = { 'oil://' .. fs.os_to_posix_path(readme) } }) test_util.wait_for_autocmd('BufEnter') + test_util.wait_for_autocmd('BufEnter') assert.equals(readme, vim.api.nvim_buf_get_name(0)) assert.equals('foo', vim.fn.expand('#')) end) diff --git a/spec/test_util.lua b/spec/test_util.lua index 57f81b1..b77f6f1 100644 --- a/spec/test_util.lua +++ b/spec/test_util.lua @@ -12,8 +12,12 @@ M.reset_editor = function() prompt_save_on_select_new_entry = false, }) vim.cmd.tabonly({ mods = { silent = true } }) - vim.cmd.new() - vim.cmd.only() + for i, winid in ipairs(vim.api.nvim_tabpage_list_wins(0)) do + if i > 1 then + vim.api.nvim_win_close(winid, true) + end + end + vim.api.nvim_win_set_buf(0, vim.api.nvim_create_buf(false, true)) for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do vim.api.nvim_buf_delete(bufnr, { force = true }) end