fix(test): resolve trash_spec.lua flakes from leaked mutation state
Problem: `mutation_in_progress` and `buffers_locked` are module-level locals in `mutator/init.lua` and `view.lua`. When a trash test times out mid-mutation, these flags stay true and `reset_editor()` never clears them. Subsequent tests' `save()` calls bail on `mutation_in_progress`, silently skipping mutations so `OilMutationComplete` never fires — causing cascading 10s timeouts. Solution: Add `mutator.reset()` to clear leaked mutation state, and call it from `reset_editor()` when `is_mutating()` is true. A 50ms event loop drain lets in-flight libuv callbacks settle before the reset. Baseline: 4/10 sequential passes. After fix: 49/50 parallel passes with zero timing overhead on the happy path (~2.4s). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5d5a8a4eba
commit
d783703ad3
2 changed files with 12 additions and 0 deletions
|
|
@ -510,6 +510,10 @@ M.is_mutating = function()
|
|||
return mutation_in_progress
|
||||
end
|
||||
|
||||
M.reset = function()
|
||||
mutation_in_progress = false
|
||||
end
|
||||
|
||||
---@param confirm nil|boolean
|
||||
---@param cb? fun(err: nil|string)
|
||||
M.try_write_changes = function(confirm, cb)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,14 @@ M.reset_editor = function()
|
|||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
vim.api.nvim_buf_delete(bufnr, { force = true })
|
||||
end
|
||||
local mutator = require('oil.mutator')
|
||||
if mutator.is_mutating() then
|
||||
vim.wait(50, function()
|
||||
return not mutator.is_mutating()
|
||||
end, 10)
|
||||
mutator.reset()
|
||||
require('oil.view').unlock_buffers()
|
||||
end
|
||||
cache.clear_everything()
|
||||
test_adapter.test_clear()
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue