mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test/termclose: Avoid indeterminism (#6281)
This commit is contained in:
parent
297e8d0fda
commit
40cc49c5da
@ -1,46 +1,46 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
|
||||||
|
|
||||||
local clear, execute, feed, nvim, nvim_dir = helpers.clear,
|
local clear, command, nvim, nvim_dir =
|
||||||
helpers.execute, helpers.feed, helpers.nvim, helpers.nvim_dir
|
helpers.clear, helpers.command, helpers.nvim, helpers.nvim_dir
|
||||||
local eval, eq = helpers.eval, helpers.eq
|
local eval, eq, retry =
|
||||||
|
helpers.eval, helpers.eq, helpers.retry
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
if helpers.pending_win32(pending) then return end
|
||||||
|
|
||||||
describe('TermClose event', function()
|
describe('TermClose event', function()
|
||||||
local screen
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
nvim('set_option', 'shell', nvim_dir .. '/shell-test')
|
nvim('set_option', 'shell', nvim_dir .. '/shell-test')
|
||||||
nvim('set_option', 'shellcmdflag', 'EXE')
|
nvim('set_option', 'shellcmdflag', 'EXE')
|
||||||
screen = Screen.new(20, 4)
|
|
||||||
screen:attach({rgb=false})
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works as expected', function()
|
local function eq_err(expected, actual)
|
||||||
execute('autocmd TermClose * echomsg "TermClose works!"')
|
if expected ~= actual then
|
||||||
execute('terminal')
|
error('expected: '..tostring(expected)..', actual: '..tostring(actual))
|
||||||
feed('<c-\\><c-n>')
|
end
|
||||||
screen:expect([[
|
end
|
||||||
^ready $ |
|
|
||||||
[Process exited 0] |
|
it('triggers when terminal job ends', function()
|
||||||
|
|
command('autocmd TermClose * let g:test_termclose = 23')
|
||||||
TermClose works! |
|
command('terminal')
|
||||||
]])
|
command('call jobstop(b:terminal_job_id)')
|
||||||
|
retry(nil, nil, function() eq_err(23, eval('g:test_termclose')) end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('reports the correct <abuf>', function()
|
it('reports the correct <abuf>', function()
|
||||||
execute('set hidden')
|
command('set hidden')
|
||||||
execute('autocmd TermClose * let g:abuf = expand("<abuf>")')
|
command('autocmd TermClose * let g:abuf = expand("<abuf>")')
|
||||||
execute('edit foo')
|
command('edit foo')
|
||||||
execute('edit bar')
|
command('edit bar')
|
||||||
eq(2, eval('bufnr("%")'))
|
eq(2, eval('bufnr("%")'))
|
||||||
execute('terminal')
|
|
||||||
feed('<c-\\><c-n>')
|
command('terminal')
|
||||||
eq(3, eval('bufnr("%")'))
|
retry(nil, nil, function() eq_err(3, eval('bufnr("%")')) end)
|
||||||
execute('buffer 1')
|
|
||||||
eq(1, eval('bufnr("%")'))
|
command('buffer 1')
|
||||||
execute('3bdelete!')
|
retry(nil, nil, function() eq_err(1, eval('bufnr("%")')) end)
|
||||||
eq('3', eval('g:abuf'))
|
|
||||||
|
command('3bdelete!')
|
||||||
|
retry(nil, nil, function() eq_err('3', eval('g:abuf')) end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user