mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 11:55:34 +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 helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local eq, ok = helpers.eq, helpers.ok
|
local eq, ok = helpers.eq, helpers.ok
|
||||||
|
local funcs = helpers.funcs
|
||||||
local buffer, command, eval, nvim, next_msg = helpers.buffer,
|
local buffer, command, eval, nvim, next_msg = helpers.buffer,
|
||||||
helpers.command, helpers.eval, helpers.nvim, helpers.next_msg
|
helpers.command, helpers.eval, helpers.nvim, helpers.next_msg
|
||||||
local nvim_prog = helpers.nvim_prog
|
local nvim_prog = helpers.nvim_prog
|
||||||
@@ -832,7 +833,10 @@ describe('API: buffer events:', function()
|
|||||||
it('when :terminal lines change', function()
|
it('when :terminal lines change', function()
|
||||||
local buffer_lines = {}
|
local buffer_lines = {}
|
||||||
local expected_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')
|
local b = nvim('get_current_buf')
|
||||||
ok(buffer('attach', b, true, {}))
|
ok(buffer('attach', b, true, {}))
|
||||||
|
|
||||||
|
|||||||
@@ -2396,7 +2396,11 @@ describe('API', function()
|
|||||||
eq(info, meths.get_chan_info(3))
|
eq(info, meths.get_chan_info(3))
|
||||||
|
|
||||||
-- :terminal with args + running process.
|
-- :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?
|
eq(-1, eval('jobwait([&channel], 0)[0]')) -- Running?
|
||||||
local expected2 = {
|
local expected2 = {
|
||||||
stream = 'job',
|
stream = 'job',
|
||||||
@@ -2406,11 +2410,11 @@ describe('API', function()
|
|||||||
eval('&shell'),
|
eval('&shell'),
|
||||||
'/s',
|
'/s',
|
||||||
'/c',
|
'/c',
|
||||||
fmt('"%s -u NONE -i NONE"', eval('shellescape(v:progpath)')),
|
fmt('"%s -u NONE -i NONE"', progpath_esc),
|
||||||
} or {
|
} or {
|
||||||
eval('&shell'),
|
eval('&shell'),
|
||||||
eval('&shellcmdflag'),
|
eval('&shellcmdflag'),
|
||||||
fmt('%s -u NONE -i NONE', eval('shellescape(v:progpath)')),
|
fmt('%s -u NONE -i NONE', progpath_esc),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
mode = 'terminal',
|
mode = 'terminal',
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ describe('oldtests', function()
|
|||||||
funcs.writefile(funcs.split(content, "\n"), fname)
|
funcs.writefile(funcs.split(content, "\n"), fname)
|
||||||
|
|
||||||
funcs.delete('Xout')
|
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'))
|
eq(1, funcs.filereadable('Xout'))
|
||||||
|
|
||||||
funcs.delete('Xxx1')
|
funcs.delete('Xxx1')
|
||||||
|
|||||||
@@ -1162,11 +1162,12 @@ describe("pty process teardown", function()
|
|||||||
it("does not prevent/delay exit. #4798 #4900", function()
|
it("does not prevent/delay exit. #4798 #4900", function()
|
||||||
skip(is_os('win'))
|
skip(is_os('win'))
|
||||||
-- Use a nested nvim (in :term) to test without --headless.
|
-- Use a nested nvim (in :term) to test without --headless.
|
||||||
feed_command(":terminal '"..helpers.nvim_prog
|
funcs.termopen({
|
||||||
.."' -u NONE -i NONE --cmd '"..nvim_set.."' "
|
helpers.nvim_prog, '-u', 'NONE', '-i', "NONE", '--cmd', nvim_set,
|
||||||
-- Use :term again in the _nested_ nvim to get a PTY process.
|
-- Use :term again in the _nested_ nvim to get a PTY process.
|
||||||
-- Use `sleep` to simulate a long-running child of the PTY.
|
-- 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, ...).
|
-- Exiting should terminate all descendants (PTY, its children, ...).
|
||||||
screen:expect([[
|
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
|
-- Need to explicitly pipe to stdin so that the embedded Nvim instance doesn't try to read
|
||||||
-- data from the terminal #18181
|
-- 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([[
|
screen:expect([[
|
||||||
{1:^ }|
|
{1:^ }|
|
||||||
{2:~ }|
|
{2:~ }|
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ describe("preserve and (R)ecover with custom 'directory'", function()
|
|||||||
local screen0 = Screen.new()
|
local screen0 = Screen.new()
|
||||||
screen0:attach()
|
screen0:attach()
|
||||||
local child_server = new_pipename()
|
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.
|
screen0:expect({any = pesc('[No Name]')}) -- Wait for the child process to start.
|
||||||
local child_session = helpers.connect(child_server)
|
local child_session = helpers.connect(child_server)
|
||||||
set_session(child_session)
|
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()
|
it('(Q)uit at first file argument', function()
|
||||||
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
||||||
'--cmd', init_dir, '--cmd', init_set,
|
'--cmd', init_dir, '--cmd', init_set,
|
||||||
testfile})
|
testfile}, {
|
||||||
|
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||||
|
})
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
||||||
eval("getline('$')->trim(' ', 2)"))
|
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()
|
it('(A)bort at second file argument with -p', function()
|
||||||
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
||||||
'--cmd', init_dir, '--cmd', init_set,
|
'--cmd', init_dir, '--cmd', init_set,
|
||||||
'-p', otherfile, testfile})
|
'-p', otherfile, testfile}, {
|
||||||
|
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
|
||||||
|
})
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
||||||
eval("getline('$')->trim(' ', 2)"))
|
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))
|
third %s /^ \zsthird$/]]):format(testfile, testfile, testfile))
|
||||||
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE',
|
||||||
'--cmd', init_dir, '--cmd', init_set,
|
'--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()
|
retry(nil, nil, function()
|
||||||
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:',
|
||||||
eval("getline('$')->trim(' ', 2)"))
|
eval("getline('$')->trim(' ', 2)"))
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ describe('vim.ui_attach', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not crash on exit', function()
|
it('does not crash on exit', function()
|
||||||
helpers.funcs.system({
|
funcs.system({
|
||||||
helpers.nvim_prog,
|
helpers.nvim_prog,
|
||||||
'-u', 'NONE',
|
'-u', 'NONE',
|
||||||
'-i', 'NONE',
|
'-i', 'NONE',
|
||||||
|
|||||||
Reference in New Issue
Block a user