Skip to content

Commit ca28e16

Browse files
committed
fix(test): make Windows terminal lifecycle deterministic
1 parent ef4f1eb commit ca28e16

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎tests/e2e/astrocore_spec.lua‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,21 @@ T["AUTOCMD-03 tracks valid unique buffers across tabs deletion and terminal clos
242242
vim.t.bufs = { second, stale }
243243
vim.api.nvim_exec_autocmds("BufEnter", astronvim_test_autocmd_options(second))
244244
245-
vim.g.astronvim_test_terminal_closed = false
246-
vim.api.nvim_create_autocmd("TermClose", {
247-
once = true,
248-
callback = function() vim.g.astronvim_test_terminal_closed = true end,
249-
})
250245
vim.cmd "botright new"
251-
vim.cmd "terminal %s"
252246
local terminal = vim.api.nvim_get_current_buf()
247+
vim.g.astronvim_test_terminal_closed = false
248+
vim.api.nvim_create_autocmd(
249+
"TermClose",
250+
astronvim_test_autocmd_options(terminal, {
251+
once = true,
252+
callback = function() vim.g.astronvim_test_terminal_closed = true end,
253+
})
254+
)
253255
_G.astronvim_test_terminal_before_close = { count = count(vim.t.bufs, terminal) }
254256
_G.astronvim_test_terminal_event_start = #_G.astronvim_test_buffer_events
255257
_G.astronvim_test_terminal_redraw_start = _G.astronvim_test_redraws
256-
vim.fn.jobstop(vim.b[terminal].terminal_job_id)
258+
local terminal_job = vim.fn.termopen(%s)
259+
vim.fn.jobstop(terminal_job)
257260
258261
_G.astronvim_test_tracking = {
259262
first = first,
@@ -264,7 +267,7 @@ T["AUTOCMD-03 tracks valid unique buffers across tabs deletion and terminal clos
264267
stale = stale,
265268
terminal = terminal,
266269
}
267-
]=]):format(terminal_sleep_command()))
270+
]=]):format(vim.inspect(terminal_sleep_command())))
268271

269272
helpers.wait_until(child, "vim.g.astronvim_test_terminal_closed == true", "terminal close")
270273

‎tests/helpers.lua‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ local function with_child_environment(case, child_environment, callback)
163163
ASTRONVIM_TEST_LAZY_PATH = config.lazy_path,
164164
ASTRONVIM_TEST_PLUGIN_ROOT = config.plugin_root,
165165
ASTRONVIM_TEST_LOCKFILE = config.lockfile,
166+
ASTRONVIM_TEST_NVIM = vim.env.ASTRONVIM_TEST_NVIM,
166167
}, child_environment or {}, deterministic_environment, fixture_git_environment(case))
167168
local previous = {}
168169

0 commit comments

Comments
 (0)