From 9e283f273b2bece25c1602fb4d26b1dff76ec105 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 7 Aug 2026 22:38:32 +0200 Subject: [PATCH] test(terminal): unreliable "spawns in CWD effective at time of invocation" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FAILED …/terminal/ex_terminal_spec.lua @ 270: :terminal (fake shell) spawns in CWD effective at time of invocation Expected values to differ. Value: "~/work/neovim/neovim/build/Xtest_xdg_terminal" stack traceback: …/terminal/ex_terminal_spec.lua:276: in function <…/terminal/ex_terminal_spec.lua:270> --- test/functional/terminal/ex_terminal_spec.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 95e2079aef..c9f8fc8859 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -268,13 +268,13 @@ local function test_terminal_with_fake_shell(backslash) end) it('spawns in CWD effective at time of invocation', function() - command('terminal') + -- Run "echo" so the default TermClose handler does not auto-delete an exitcode=0 shell. + command('terminal echo') local dir = fn.bufname():match('^term://(.-)//') - command('bcd ..') -- :terminal should use this CWD. - command('terminal') - local parent = fn.bufname():match('^term://(.-)//') - neq(dir, parent) - eq(fn.fnamemodify(dir, ':h'), parent) + local parentdir = fn.fnamemodify(fn.getcwd(), ':h') -- Absolute, so 'cdpath' cannot interfere. + command(('bcd %s'):format(fn.fnameescape(parentdir))) -- :terminal should use this CWD. + command('terminal echo') + eq(fn.fnamemodify(dir, ':h'), fn.bufname():match('^term://(.-)//')) end) it('allows quotes and slashes', function()