aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/ex_terminal_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:18 +0100
committerJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:29 +0100
commit04f2f864e270e772c6326cefdf24947f0130e492 (patch)
tree46f83f909b888a66c741032ab955afc6eab84292 /test/functional/terminal/ex_terminal_spec.lua
parent59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff)
downloadrneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip
refactor: format test/*
Diffstat (limited to 'test/functional/terminal/ex_terminal_spec.lua')
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua88
1 files changed, 46 insertions, 42 deletions
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 927c021a23..68d206c177 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -19,10 +19,10 @@ describe(':terminal', function()
before_each(function()
clear()
screen = Screen.new(50, 4)
- screen:attach({rgb=false})
+ screen:attach({ rgb = false })
end)
- it("does not interrupt Press-ENTER prompt #2748", function()
+ it('does not interrupt Press-ENTER prompt #2748', function()
-- Ensure that :messages shows Press-ENTER.
source([[
echomsg "msg1"
@@ -30,14 +30,14 @@ describe(':terminal', function()
echomsg "msg3"
]])
-- Invoke a command that emits frequent terminal activity.
- feed([[:terminal "]]..testprg('shell-test')..[[" REP 9999 !terminal_output!<cr>]])
+ feed([[:terminal "]] .. testprg('shell-test') .. [[" REP 9999 !terminal_output!<cr>]])
feed([[<C-\><C-N>]])
poke_eventloop()
-- Wait for some terminal activity.
retry(nil, 4000, function()
ok(funcs.line('$') > 6)
end)
- feed_command("messages")
+ feed_command('messages')
screen:expect([[
msg1 |
msg2 |
@@ -46,30 +46,34 @@ describe(':terminal', function()
]])
end)
- it("reads output buffer on terminal reporting #4151", 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([[terminal powershell -NoProfile -NoLogo -Command Write-Host -NoNewline "\"$([char]27)[6n\""; Start-Sleep -Milliseconds 500 ]])
+ feed_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 ]])
end
- screen:expect{any='%^%[%[1;1R'}
+ screen:expect { any = '%^%[%[1;1R' }
end)
- it("in normal-mode :split does not move cursor", function()
+ it('in normal-mode :split does not move cursor', function()
if is_os('win') then
- feed_command([[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]])
+ feed_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]])
end
- feed([[<C-\><C-N>M]]) -- move cursor away from last line
+ 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
+ eq(3, eval("line('$')")) -- window height
+ eq(2, eval("line('.')")) -- cursor is in the middle
feed_command('vsplit')
- eq(2, eval("line('.')")) -- cursor stays where we put it
+ eq(2, eval("line('.')")) -- cursor stays where we put it
feed_command('split')
- eq(2, eval("line('.')")) -- cursor stays where we put it
+ eq(2, eval("line('.')")) -- cursor stays where we put it
end)
it('Enter/Leave does not increment jumplist #3723', function()
@@ -92,7 +96,7 @@ describe(':terminal', function()
enter_and_leave()
enter_and_leave()
enter_and_leave()
- ok(funcs.line('$') > 6) -- Verify assumption.
+ ok(funcs.line('$') > 6) -- Verify assumption.
local jumps = funcs.split(funcs.execute('jumps'), '\n')
eq(' jump line col file/text', jumps[1])
eq(3, #jumps)
@@ -100,30 +104,30 @@ describe(':terminal', function()
it('nvim_get_mode() in :terminal', function()
command('terminal')
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 'nt' }, nvim('get_mode'))
feed('i')
- eq({ blocking=false, mode='t' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 't' }, nvim('get_mode'))
feed([[<C-\><C-N>]])
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 'nt' }, nvim('get_mode'))
end)
it(':stopinsert RPC request exits terminal-mode #7807', function()
command('terminal')
feed('i[tui] insert-mode')
- eq({ blocking=false, mode='t' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 't' }, nvim('get_mode'))
command('stopinsert')
- feed('<Ignore>') -- Add input to separate two RPC requests
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ feed('<Ignore>') -- Add input to separate two RPC requests
+ eq({ blocking = false, mode = 'nt' }, nvim('get_mode'))
end)
- it(':stopinsert in normal mode doesn\'t break insert mode #9889', function()
+ it(":stopinsert in normal mode doesn't break insert mode #9889", function()
command('terminal')
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 'nt' }, nvim('get_mode'))
command('stopinsert')
- feed('<Ignore>') -- Add input to separate two RPC requests
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ feed('<Ignore>') -- Add input to separate two RPC requests
+ eq({ blocking = false, mode = 'nt' }, nvim('get_mode'))
feed('a')
- eq({ blocking=false, mode='t' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 't' }, nvim('get_mode'))
end)
it('switching to terminal buffer in Insert mode goes to Terminal mode #7164', function()
@@ -134,10 +138,10 @@ describe(':terminal', function()
command('autocmd InsertLeave * let g:events += ["InsertLeave"]')
command('autocmd TermEnter * let g:events += ["TermEnter"]')
command('inoremap <F2> <Cmd>wincmd p<CR>')
- eq({ blocking=false, mode='i' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 'i' }, nvim('get_mode'))
feed('<F2>')
- eq({ blocking=false, mode='t' }, nvim('get_mode'))
- eq({'InsertLeave', 'TermEnter'}, eval('g:events'))
+ eq({ blocking = false, mode = 't' }, nvim('get_mode'))
+ eq({ 'InsertLeave', 'TermEnter' }, eval('g:events'))
end)
end)
@@ -153,7 +157,7 @@ local function test_terminal_with_fake_shell(backslash)
before_each(function()
clear()
screen = Screen.new(50, 4)
- screen:attach({rgb=false})
+ screen:attach({ rgb = false })
nvim('set_option_value', 'shell', shell_path, {})
nvim('set_option_value', 'shellcmdflag', 'EXE', {})
nvim('set_option_value', 'shellxquote', '', {})
@@ -163,7 +167,7 @@ local function test_terminal_with_fake_shell(backslash)
command('autocmd! nvim_terminal TermClose')
feed_command('terminal')
retry(nil, 4 * screen.timeout, function()
- screen:expect([[
+ screen:expect([[
^ready $ |
[Process exited 0] |
|
@@ -183,7 +187,7 @@ local function test_terminal_with_fake_shell(backslash)
end)
it("with no argument, but 'shell' has arguments, acts like termopen()", function()
- nvim('set_option_value', 'shell', shell_path ..' INTERACT', {})
+ nvim('set_option_value', 'shell', shell_path .. ' INTERACT', {})
feed_command('terminal')
screen:expect([[
^interact $ |
@@ -193,7 +197,7 @@ local function test_terminal_with_fake_shell(backslash)
end)
it('executes a given command through the shell', function()
- command('set shellxquote=') -- win: avoid extra quotes
+ command('set shellxquote=') -- win: avoid extra quotes
feed_command('terminal echo hi')
screen:expect([[
^ready $ echo hi |
@@ -204,8 +208,8 @@ local function test_terminal_with_fake_shell(backslash)
end)
it("executes a given command through the shell, when 'shell' has arguments", function()
- nvim('set_option_value', 'shell', shell_path ..' -t jeff', {})
- command('set shellxquote=') -- win: avoid extra quotes
+ nvim('set_option_value', 'shell', shell_path .. ' -t jeff', {})
+ command('set shellxquote=') -- win: avoid extra quotes
feed_command('terminal echo hi')
screen:expect([[
^jeff $ echo hi |
@@ -216,7 +220,7 @@ local function test_terminal_with_fake_shell(backslash)
end)
it('allows quotes and slashes', function()
- command('set shellxquote=') -- win: avoid extra quotes
+ command('set shellxquote=') -- win: avoid extra quotes
feed_command([[terminal echo 'hello' \ "world"]])
screen:expect([[
^ready $ echo 'hello' \ "world" |
@@ -230,7 +234,7 @@ local function test_terminal_with_fake_shell(backslash)
source([[
autocmd BufNew * set shell=foo
terminal]])
- -- Verify that BufNew actually fired (else the test is invalid).
+ -- Verify that BufNew actually fired (else the test is invalid).
eq('foo', eval('&shell'))
end)
@@ -249,7 +253,7 @@ local function test_terminal_with_fake_shell(backslash)
it('works with findfile()', function()
command('autocmd! nvim_terminal TermClose')
feed_command('terminal')
- eq('term://', string.match(eval('bufname("%")'), "^term://"))
+ eq('term://', string.match(eval('bufname("%")'), '^term://'))
eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")'))
end)
@@ -262,7 +266,7 @@ local function test_terminal_with_fake_shell(backslash)
|
:terminal |
]])
- eq('term://', string.match(eval('bufname("%")'), "^term://"))
+ eq('term://', string.match(eval('bufname("%")'), '^term://'))
feed([[<C-\><C-N>]])
feed_command([[find */shadacat.py]])
if is_os('win') then
@@ -273,10 +277,10 @@ local function test_terminal_with_fake_shell(backslash)
end)
it('works with gf', function()
- command('set shellxquote=') -- win: avoid extra quotes
+ command('set shellxquote=') -- win: avoid extra quotes
feed_command([[terminal echo "scripts/shadacat.py"]])
retry(nil, 4 * screen.timeout, function()
- screen:expect([[
+ screen:expect([[
^ready $ echo "scripts/shadacat.py" |
|
[Process exited 0] |
@@ -284,7 +288,7 @@ local function test_terminal_with_fake_shell(backslash)
]])
end)
feed([[<C-\><C-N>]])
- eq('term://', string.match(eval('bufname("%")'), "^term://"))
+ eq('term://', string.match(eval('bufname("%")'), '^term://'))
feed([[ggf"lgf]])
eq('scripts/shadacat.py', eval('bufname("%")'))
end)