mirror of
https://github.com/neovim/neovim.git
synced 2026-04-25 08:44:06 +00:00
test: remove remaining use of feed_command() in terminal/ (#38069)
Also deduplicate screen lines in some other tests.
This commit is contained in:
@@ -429,8 +429,7 @@ describe(':checkhealth window', function()
|
||||
checkhealth: checks done |
|
||||
## grid 4
|
||||
^ |
|
||||
|
|
||||
|
|
||||
|*2
|
||||
test_plug. |
|
||||
success1: |
|
||||
✅ |
|
||||
|
||||
@@ -54,8 +54,7 @@ describe('vim.lsp.codelens', function()
|
||||
; |
|
||||
println!("S.a: {}, S.b: {}", s.a, s.b); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|*2
|
||||
]])
|
||||
|
||||
local grid_without_lenses = dedent([[
|
||||
|
||||
@@ -114,9 +114,7 @@ describe(':terminal buffer', function()
|
||||
screen:expect([[
|
||||
^tty ready |
|
||||
appended tty ready |*2
|
||||
|
|
||||
|*2
|
||||
|
|
||||
|*4
|
||||
]])
|
||||
-- operator count is also taken into consideration
|
||||
feed('3"ap')
|
||||
@@ -134,8 +132,7 @@ describe(':terminal buffer', function()
|
||||
screen:expect([[
|
||||
^tty ready |
|
||||
appended tty ready |
|
||||
|
|
||||
|*3
|
||||
|*4
|
||||
:put a |
|
||||
]])
|
||||
-- line argument is only used to move the cursor
|
||||
@@ -143,8 +140,7 @@ describe(':terminal buffer', function()
|
||||
screen:expect([[
|
||||
tty ready |
|
||||
appended tty ready |*2
|
||||
|
|
||||
|
|
||||
|*2
|
||||
^ |
|
||||
:6put a |
|
||||
]])
|
||||
@@ -280,8 +276,7 @@ describe(':terminal buffer', function()
|
||||
feed [[:let g:x = 17]]
|
||||
screen:expect([[
|
||||
tty ready |
|
||||
|
|
||||
|*4
|
||||
|*5
|
||||
:let g:x = 17^ |
|
||||
]])
|
||||
|
||||
@@ -341,8 +336,7 @@ describe(':terminal buffer', function()
|
||||
screen:expect(([[
|
||||
tty ready |
|
||||
^%s%s|
|
||||
|*4
|
||||
|
|
||||
|*5
|
||||
]]):format(('j'):rep(i), (' '):rep(50 - i)))
|
||||
end
|
||||
feed('l') -- No partial mapping, so all pending refreshes should be processed
|
||||
|
||||
@@ -290,8 +290,7 @@ describe(':terminal cursor', function()
|
||||
screen:expect({
|
||||
grid = [[
|
||||
tty ready |
|
||||
|
|
||||
|*4
|
||||
|*5
|
||||
{5:-- TERMINAL --} |
|
||||
]],
|
||||
condition = function()
|
||||
|
||||
@@ -6,7 +6,7 @@ local assert_alive = n.assert_alive
|
||||
local clear, poke_eventloop = n.clear, n.poke_eventloop
|
||||
local testprg, source, eq, neq = n.testprg, n.source, t.eq, t.neq
|
||||
local feed = n.feed
|
||||
local feed_command, eval = n.feed_command, n.eval
|
||||
local eval = n.eval
|
||||
local fn = n.fn
|
||||
local api = n.api
|
||||
local exec_lua = n.exec_lua
|
||||
@@ -41,7 +41,7 @@ describe(':terminal', function()
|
||||
retry(nil, 4000, function()
|
||||
ok(fn.line('$') > 6)
|
||||
end)
|
||||
feed_command('messages')
|
||||
feed(':messages<CR>')
|
||||
screen:expect([[
|
||||
msg1 |
|
||||
msg2 |
|
||||
@@ -53,35 +53,35 @@ describe(':terminal', function()
|
||||
it('reads output buffer on terminal reporting #4151', function()
|
||||
skip(is_ci('cirrus') or is_os('win'))
|
||||
if is_os('win') then
|
||||
feed_command(
|
||||
command(
|
||||
[[terminal powershell -NoProfile -NoLogo -Command Write-Host -NoNewline "\"$([char]27)[6n\""; Start-Sleep -Milliseconds 500 ]]
|
||||
)
|
||||
else
|
||||
feed_command([[terminal printf '\e[6n'; sleep 0.5 ]])
|
||||
command([[terminal printf '\e[6n'; sleep 0.5 ]])
|
||||
end
|
||||
screen:expect { any = '%^%[%[1;1R' }
|
||||
end)
|
||||
|
||||
it('in normal-mode :split does not move cursor', function()
|
||||
if is_os('win') then
|
||||
feed_command(
|
||||
command(
|
||||
[[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]]
|
||||
)
|
||||
else
|
||||
feed_command([[terminal while true; do echo foo; sleep .1; done]])
|
||||
command([[terminal while true; do echo foo; sleep .1; done]])
|
||||
end
|
||||
feed([[<C-\><C-N>M]]) -- move cursor away from last line
|
||||
poke_eventloop()
|
||||
eq(3, eval("line('$')")) -- window height
|
||||
eq(2, eval("line('.')")) -- cursor is in the middle
|
||||
feed_command('vsplit')
|
||||
feed(':vsplit<CR>')
|
||||
eq(2, eval("line('.')")) -- cursor stays where we put it
|
||||
feed_command('split')
|
||||
feed(':split<CR>')
|
||||
eq(2, eval("line('.')")) -- cursor stays where we put it
|
||||
end)
|
||||
|
||||
it('Enter/Leave does not increment jumplist #3723', function()
|
||||
feed_command('terminal')
|
||||
feed(':terminal<CR>')
|
||||
local function enter_and_leave()
|
||||
local lines_before = fn.line('$')
|
||||
-- Create a new line (in the shell). For a normal buffer this
|
||||
@@ -212,63 +212,56 @@ local function test_terminal_with_fake_shell(backslash)
|
||||
|
||||
it('with no argument, acts like jobstart(…,{term=true})', function()
|
||||
command('autocmd! nvim.terminal TermClose')
|
||||
feed_command('terminal')
|
||||
command('terminal')
|
||||
screen:expect([[
|
||||
^ready $ |
|
||||
[Process exited 0] |
|
||||
|
|
||||
:terminal |
|
||||
|*2
|
||||
]])
|
||||
end)
|
||||
|
||||
it("with no argument, and 'shell' is set to empty string", function()
|
||||
api.nvim_set_option_value('shell', '', {})
|
||||
feed_command('terminal')
|
||||
screen:expect([[
|
||||
^ |
|
||||
~ |*2
|
||||
E91: 'shell' option is empty |
|
||||
]])
|
||||
eq("Vim(terminal):E91: 'shell' option is empty", t.pcall_err(command, 'terminal'))
|
||||
end)
|
||||
|
||||
it("with no argument, but 'shell' has arguments, acts like jobstart(…,{term=true})", function()
|
||||
api.nvim_set_option_value('shell', shell_path .. ' INTERACT', {})
|
||||
feed_command('terminal')
|
||||
command('terminal')
|
||||
screen:expect([[
|
||||
^interact $ |
|
||||
|*2
|
||||
:terminal |
|
||||
|*3
|
||||
]])
|
||||
end)
|
||||
|
||||
it('executes a given command through the shell', function()
|
||||
feed_command('terminal echo hi')
|
||||
command('terminal echo hi')
|
||||
screen:expect([[
|
||||
^ready $ echo hi |
|
||||
|
|
||||
[Process exited 0] |
|
||||
:terminal echo hi |
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it("executes a given command through the shell, when 'shell' has arguments", function()
|
||||
api.nvim_set_option_value('shell', shell_path .. ' -t jeff', {})
|
||||
feed_command('terminal echo hi')
|
||||
command('terminal echo hi')
|
||||
screen:expect([[
|
||||
^jeff $ echo hi |
|
||||
|
|
||||
[Process exited 0] |
|
||||
:terminal echo hi |
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('allows quotes and slashes', function()
|
||||
feed_command([[terminal echo 'hello' \ "world"]])
|
||||
command([[terminal echo 'hello' \ "world"]])
|
||||
screen:expect([[
|
||||
^ready $ echo 'hello' \ "world" |
|
||||
|
|
||||
[Process exited 0] |
|
||||
:terminal echo 'hello' \ "world" |
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
@@ -282,7 +275,7 @@ local function test_terminal_with_fake_shell(backslash)
|
||||
|
||||
it('ignores writes if the backing stream closes', function()
|
||||
command('autocmd! nvim.terminal TermClose')
|
||||
feed_command('terminal')
|
||||
command('terminal')
|
||||
feed('iiXXXXXXX')
|
||||
poke_eventloop()
|
||||
-- Race: Though the shell exited (and streams were closed by SIGCHLD
|
||||
@@ -294,23 +287,22 @@ local function test_terminal_with_fake_shell(backslash)
|
||||
|
||||
it('works with findfile()', function()
|
||||
command('autocmd! nvim.terminal TermClose')
|
||||
feed_command('terminal')
|
||||
command('terminal')
|
||||
eq('term://', string.match(eval('bufname("%")'), '^term://'))
|
||||
eq('Xsomedir/Xuniquefile', eval('findfile("Xsomedir/Xuniquefile", ".")'))
|
||||
end)
|
||||
|
||||
it('works with :find', function()
|
||||
command('autocmd! nvim.terminal TermClose')
|
||||
feed_command('terminal')
|
||||
command('terminal')
|
||||
screen:expect([[
|
||||
^ready $ |
|
||||
[Process exited 0] |
|
||||
|
|
||||
:terminal |
|
||||
|*2
|
||||
]])
|
||||
eq('term://', string.match(eval('bufname("%")'), '^term://'))
|
||||
feed([[<C-\><C-N>]])
|
||||
feed_command([[find */Xuniquefile]])
|
||||
command([[find */Xuniquefile]])
|
||||
if is_os('win') then
|
||||
eq('Xsomedir\\Xuniquefile', eval('bufname("%")'))
|
||||
else
|
||||
@@ -319,12 +311,12 @@ local function test_terminal_with_fake_shell(backslash)
|
||||
end)
|
||||
|
||||
it('works with gf', function()
|
||||
feed_command([[terminal echo "Xsomedir/Xuniquefile"]])
|
||||
command([[terminal echo "Xsomedir/Xuniquefile"]])
|
||||
screen:expect([[
|
||||
^ready $ echo "Xsomedir/Xuniquefile" |
|
||||
|
|
||||
[Process exited 0] |
|
||||
:terminal echo "Xsomedir/Xuniquefile" |
|
||||
|
|
||||
]])
|
||||
feed([[<C-\><C-N>]])
|
||||
eq('term://', string.match(eval('bufname("%")'), '^term://'))
|
||||
@@ -348,12 +340,11 @@ local function test_terminal_with_fake_shell(backslash)
|
||||
it(('with updatetime=%d'):format(ut), function()
|
||||
api.nvim_set_option_value('updatetime', ut, {})
|
||||
api.nvim_set_option_value('shellcmdflag', 'EXIT', {})
|
||||
feed_command('terminal 42')
|
||||
command('terminal 42')
|
||||
screen:expect([[
|
||||
^ |
|
||||
[Process exited 42] |
|
||||
|
|
||||
:terminal 42 |
|
||||
|*2
|
||||
]])
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -229,8 +229,7 @@ describe(':terminal window', function()
|
||||
line2 |
|
||||
line3 |
|
||||
line4 |
|
||||
|
|
||||
|
|
||||
|*2
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -5,7 +5,6 @@ local tt = require('test.functional.testterm')
|
||||
local assert_alive = n.assert_alive
|
||||
local clear = n.clear
|
||||
local feed = n.feed
|
||||
local feed_command = n.feed_command
|
||||
local command = n.command
|
||||
local eq = t.eq
|
||||
local eval = n.eval
|
||||
@@ -42,29 +41,27 @@ describe(':terminal', function()
|
||||
it('does not change size on WinEnter', function()
|
||||
feed('<c-\\><c-n>')
|
||||
feed('k')
|
||||
feed_command('2split')
|
||||
command('2split')
|
||||
screen:expect([[
|
||||
^tty ready |
|
||||
rows: 5, cols: 50 |
|
||||
========== |
|
||||
tty ready |
|
||||
rows: 5, cols: 50 |
|
||||
|
|
||||
|*2
|
||||
|*3
|
||||
========== |
|
||||
:2split |
|
||||
|
|
||||
]])
|
||||
feed_command('wincmd p')
|
||||
command('wincmd p')
|
||||
screen:expect([[
|
||||
tty ready |
|
||||
rows: 5, cols: 50 |
|
||||
========== |
|
||||
^tty ready |
|
||||
rows: 5, cols: 50 |
|
||||
|
|
||||
|*2
|
||||
|*3
|
||||
========== |
|
||||
:wincmd p |
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
@@ -102,8 +99,7 @@ describe(':terminal', function()
|
||||
screen:expect([[
|
||||
tty ready |
|
||||
rows: 7, cols: 47 |
|
||||
|
|
||||
|*3
|
||||
|*4
|
||||
^ |
|
||||
|
|
||||
]])
|
||||
|
||||
@@ -3055,8 +3055,7 @@ describe('extmark decorations', function()
|
||||
colpos = colpos+1 |
|
||||
end |
|
||||
en^d |
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|*2
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
@@ -673,8 +673,7 @@ describe('highlight', function()
|
||||
{1: }{2:01}{3:234 67}{2:89}{5: }|
|
||||
{4:~ }|*2
|
||||
{7:[No Name] [+] }|
|
||||
{1: }{6:-----------------------}|
|
||||
{1: }{6:-----------------------}|
|
||||
{1: }{6:-----------------------}|*2
|
||||
{1: } |
|
||||
{8:[No Name] }|
|
||||
|
|
||||
|
||||
@@ -227,8 +227,7 @@ describe('ext_hlstate detailed highlights', function()
|
||||
command(("enew | call jobstart(['%s'],{'term':v:true})"):format(testprg('tty-test')))
|
||||
screen:expect([[
|
||||
^tty ready |
|
||||
|
|
||||
|*5
|
||||
|*6
|
||||
{7: }|
|
||||
]])
|
||||
|
||||
@@ -242,16 +241,14 @@ describe('ext_hlstate detailed highlights', function()
|
||||
screen:expect([[
|
||||
^tty ready |
|
||||
x {5:y z} |
|
||||
|
|
||||
|*4
|
||||
|*5
|
||||
{7: }|
|
||||
]])
|
||||
else
|
||||
screen:expect([[
|
||||
^tty ready |
|
||||
x {2:y }{3:z} |
|
||||
|
|
||||
|*4
|
||||
|*5
|
||||
{7: }|
|
||||
]])
|
||||
end
|
||||
|
||||
@@ -557,8 +557,7 @@ something
|
||||
{7: }{8: 11 }^common line │{7: }{8: 14 }common line |
|
||||
{7: }{8: }{23:-------------------------------------------}│{7: }{8: 15 }{22:DEF }|
|
||||
{7: }{8: 12 }something │{7: }{8: 16 }something |
|
||||
{1:~ }│{1:~ }|
|
||||
{1:~ }│{1:~ }|
|
||||
{1:~ }│{1:~ }|*2
|
||||
{3:Xtest-functional-diff-screen-1.2 }{2:Xtest-functional-diff-screen-1 [+] }|
|
||||
:e |
|
||||
]])
|
||||
@@ -584,8 +583,7 @@ something
|
||||
{7: }{8: }{23:-------------------------------------------}│{7: }{8: 14 }{22:DEF }|
|
||||
{7: }{8: 11 }common line │{7: }{8: 15 }common line |
|
||||
{7: }{8: 12 }^something │{7: }{8: 16 }something |
|
||||
{1:~ }│{1:~ }|
|
||||
{1:~ }│{1:~ }|
|
||||
{1:~ }│{1:~ }|*2
|
||||
{3:Xtest-functional-diff-screen-1.2 }{2:Xtest-functional-diff-screen-1 [+] }|
|
||||
:e |
|
||||
]])
|
||||
|
||||
@@ -225,9 +225,7 @@ describe('messages2', function()
|
||||
command('echo "foo"')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*10
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|*12
|
||||
{1:~ }{4:foo}|
|
||||
]])
|
||||
command('mode')
|
||||
@@ -239,9 +237,7 @@ describe('messages2', function()
|
||||
command('echo "foo"')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*10
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|*12
|
||||
{1:~ }{4:foo}|
|
||||
]])
|
||||
command('echo ""')
|
||||
@@ -250,9 +246,7 @@ describe('messages2', function()
|
||||
screen:try_resize(screen._width, screen._height - 1)
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*9
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|*11
|
||||
{1:~ }{4:foo}|
|
||||
]])
|
||||
-- Moved up when opening cmdline
|
||||
|
||||
Reference in New Issue
Block a user