test(terminal): unreliable "spawns in CWD effective at time of invocation"

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>
This commit is contained in:
Justin M. Keyes
2026-08-07 22:38:32 +02:00
parent eecc4b73ff
commit 9e283f273b

View File

@@ -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()