Skip to content

Commit 593ff07

Browse files
committed
fix(test): clean Windows DAP fixtures reliably
1 parent b40715b commit 593ff07

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎tests/e2e/dap_spec.lua‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ T["DAP-E2E-03 runs and terminates a hermetic adapter through AstroNvim mappings"
9090
type = "executable",
9191
command = nvim,
9292
args = { "--headless", "--clean", "-u", "NONE", "-l", %s },
93+
options = { detached = false },
9394
}
9495
local source = %s
9596
local launch_path = vim.fs.joinpath(vim.fs.dirname(source), ".vscode", "launch.json")

‎tests/helpers.lua‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ local function initialize_fixture_repository(case)
9696
end
9797

9898
local function delete_fixture_root(root)
99-
if vim.fn.delete(root, "rf") == 0 then return end
100-
if vim.uv.fs_lstat and vim.uv.fs_lstat(root) then
101-
vim.wait(100)
99+
for attempt = 1, 20 do
102100
if vim.fn.delete(root, "rf") == 0 then return end
101+
if not vim.uv.fs_lstat or not vim.uv.fs_lstat(root) then break end
102+
if attempt < 20 then vim.wait(100) end
103103
end
104104
return "Failed to delete test fixture root: " .. root
105105
end

‎tests/unit/e2e_helpers_spec.lua‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ local function with_helpers(options, callback)
8888
fn = {
8989
delete = function(path)
9090
table.insert(state.deleted_roots, path)
91+
if type(options.delete_result) == "function" then return options.delete_result(path, #state.deleted_roots) end
9192
return options.delete_result or 0
9293
end,
9394
fnameescape = function(path) return path end,
@@ -133,6 +134,7 @@ local function with_helpers(options, callback)
133134
table.insert(state.copied_files, { source, destination })
134135
return true
135136
end,
137+
fs_lstat = function() return options.fs_lstat_result end,
136138
fs_mkdtemp = function(template)
137139
state.mkdtemp_template = template
138140
return root
@@ -336,6 +338,19 @@ T["TEST-05 reports root deletion failures after releasing child state"] = functi
336338
end)
337339
end
338340

341+
T["TEST-05 retries fixture deletion while a Windows handle is released"] = function()
342+
with_helpers({
343+
fs_lstat_result = { type = "directory" },
344+
delete_result = function(_, attempt) return attempt < 3 and 1 or 0 end,
345+
}, function(helpers, state, root)
346+
local child = helpers.start_child()
347+
helpers.stop_child(child)
348+
349+
assert.same({ root, root, root }, state.deleted_roots)
350+
assert.equals(2, state.wait_calls)
351+
end)
352+
end
353+
339354
T["TEST-05 aggregates startup and cleanup errors"] = function()
340355
with_helpers({
341356
delete_result = 1,

0 commit comments

Comments
 (0)