mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
test: use termopen() instead of :terminal more (#26462)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear = helpers.clear
|
||||
local eq, ok = helpers.eq, helpers.ok
|
||||
local funcs = helpers.funcs
|
||||
local buffer, command, eval, nvim, next_msg = helpers.buffer,
|
||||
helpers.command, helpers.eval, helpers.nvim, helpers.next_msg
|
||||
local nvim_prog = helpers.nvim_prog
|
||||
@ -832,7 +833,10 @@ describe('API: buffer events:', function()
|
||||
it('when :terminal lines change', function()
|
||||
local buffer_lines = {}
|
||||
local expected_lines = {}
|
||||
command('terminal "'..nvim_prog..'" -u NONE -i NONE -n -c "set shortmess+=A"')
|
||||
funcs.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '-n', '-c', 'set shortmess+=A' }, {
|
||||
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||
})
|
||||
|
||||
local b = nvim('get_current_buf')
|
||||
ok(buffer('attach', b, true, {}))
|
||||
|
||||
|
@ -2396,7 +2396,11 @@ describe('API', function()
|
||||
eq(info, meths.get_chan_info(3))
|
||||
|
||||
-- :terminal with args + running process.
|
||||
command(':exe "terminal" shellescape(v:progpath) "-u NONE -i NONE"')
|
||||
command('enew')
|
||||
local progpath_esc = eval('shellescape(v:progpath)')
|
||||
funcs.termopen(('%s -u NONE -i NONE'):format(progpath_esc), {
|
||||
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||
})
|
||||
eq(-1, eval('jobwait([&channel], 0)[0]')) -- Running?
|
||||
local expected2 = {
|
||||
stream = 'job',
|
||||
@ -2406,11 +2410,11 @@ describe('API', function()
|
||||
eval('&shell'),
|
||||
'/s',
|
||||
'/c',
|
||||
fmt('"%s -u NONE -i NONE"', eval('shellescape(v:progpath)')),
|
||||
fmt('"%s -u NONE -i NONE"', progpath_esc),
|
||||
} or {
|
||||
eval('&shell'),
|
||||
eval('&shellcmdflag'),
|
||||
fmt('%s -u NONE -i NONE', eval('shellescape(v:progpath)')),
|
||||
fmt('%s -u NONE -i NONE', progpath_esc),
|
||||
}
|
||||
),
|
||||
mode = 'terminal',
|
||||
|
@ -75,7 +75,7 @@ describe('oldtests', function()
|
||||
funcs.writefile(funcs.split(content, "\n"), fname)
|
||||
|
||||
funcs.delete('Xout')
|
||||
funcs.system(string.format('%s -u NORC -i NONE -N -S %s', meths.get_vvar('progpath'), fname))
|
||||
funcs.system(string.format('%s --clean -N -S %s', meths.get_vvar('progpath'), fname))
|
||||
eq(1, funcs.filereadable('Xout'))
|
||||
|
||||
funcs.delete('Xxx1')
|
||||
|
@ -676,7 +676,7 @@ describe('jobs', function()
|
||||
on_stderr = function(chan, data, name) stderr = data end,
|
||||
on_stdout = function(chan, data, name) stdout = data end,
|
||||
}
|
||||
local j1 = vim.fn.jobstart({ vim.v.progpath, '-es', '-V1',( '+echo "%s="..getenv("%s")'):format(envname, envname), '+qa!' }, opt)
|
||||
local j1 = vim.fn.jobstart({ vim.v.progpath, '-es', '-V1',('+echo "%s="..getenv("%s")'):format(envname, envname), '+qa!' }, opt)
|
||||
vim.fn.jobwait({ j1 }, 10000)
|
||||
return join({ join(stdout), join(stderr) })
|
||||
]],
|
||||
@ -1162,11 +1162,12 @@ describe("pty process teardown", function()
|
||||
it("does not prevent/delay exit. #4798 #4900", function()
|
||||
skip(is_os('win'))
|
||||
-- Use a nested nvim (in :term) to test without --headless.
|
||||
feed_command(":terminal '"..helpers.nvim_prog
|
||||
.."' -u NONE -i NONE --cmd '"..nvim_set.."' "
|
||||
funcs.termopen({
|
||||
helpers.nvim_prog, '-u', 'NONE', '-i', "NONE", '--cmd', nvim_set,
|
||||
-- Use :term again in the _nested_ nvim to get a PTY process.
|
||||
-- Use `sleep` to simulate a long-running child of the PTY.
|
||||
.."+terminal +'!(sleep 300 &)' +qa")
|
||||
'+terminal', '+!(sleep 300 &)', '+qa',
|
||||
}, { env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } })
|
||||
|
||||
-- Exiting should terminate all descendants (PTY, its children, ...).
|
||||
screen:expect([[
|
||||
|
@ -68,7 +68,9 @@ describe('command-line option', function()
|
||||
|
||||
-- Need to explicitly pipe to stdin so that the embedded Nvim instance doesn't try to read
|
||||
-- data from the terminal #18181
|
||||
funcs.termopen(string.format([[echo "" | %s]], table.concat(args, " ")))
|
||||
funcs.termopen(string.format([[echo "" | %s]], table.concat(args, " ")), {
|
||||
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||
})
|
||||
screen:expect([[
|
||||
{1:^ }|
|
||||
{2:~ }|
|
||||
|
@ -115,7 +115,9 @@ describe("preserve and (R)ecover with custom 'directory'", function()
|
||||
local screen0 = Screen.new()
|
||||
screen0:attach()
|
||||
local child_server = new_pipename()
|
||||
funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server})
|
||||
funcs.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server }, {
|
||||
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||
})
|
||||
screen0:expect({any = pesc('[No Name]')}) -- Wait for the child process to start.
|
||||
local child_session = helpers.connect(child_server)
|
||||
set_session(child_session)
|
||||
@ -452,7 +454,9 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
|
||||
it('(Q)uit at first file argument', function()
|
||||
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
||||
'--cmd', init_dir, '--cmd', init_set,
|
||||
testfile})
|
||||
testfile}, {
|
||||
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||
})
|
||||
retry(nil, nil, function()
|
||||
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
||||
eval("getline('$')->trim(' ', 2)"))
|
||||
@ -467,7 +471,9 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
|
||||
it('(A)bort at second file argument with -p', function()
|
||||
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
||||
'--cmd', init_dir, '--cmd', init_set,
|
||||
'-p', otherfile, testfile})
|
||||
'-p', otherfile, testfile}, {
|
||||
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||
})
|
||||
retry(nil, nil, function()
|
||||
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
||||
eval("getline('$')->trim(' ', 2)"))
|
||||
@ -487,7 +493,9 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
|
||||
third %s /^ \zsthird$/]]):format(testfile, testfile, testfile))
|
||||
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
||||
'--cmd', init_dir, '--cmd', init_set,
|
||||
'--cmd', 'set tags='..otherfile, '-tsecond'})
|
||||
'--cmd', 'set tags='..otherfile, '-tsecond'}, {
|
||||
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||
})
|
||||
retry(nil, nil, function()
|
||||
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
||||
eval("getline('$')->trim(' ', 2)"))
|
||||
|
@ -101,7 +101,7 @@ describe('vim.ui_attach', function()
|
||||
end)
|
||||
|
||||
it('does not crash on exit', function()
|
||||
helpers.funcs.system({
|
||||
funcs.system({
|
||||
helpers.nvim_prog,
|
||||
'-u', 'NONE',
|
||||
'-i', 'NONE',
|
||||
|
Reference in New Issue
Block a user