mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test(exit_spec): make sure that autocommands are triggered (#22188)
Previously, if the autocommands are not triggered, the tests may still pass because no assertion is done. Add an assertion so that the tests will fail if the autocommands aren't triggered.
This commit is contained in:
parent
ad00b03426
commit
1b379ce430
@ -25,30 +25,34 @@ describe('v:exiting', function()
|
|||||||
eq(1, eval('v:exiting is v:null'))
|
eq(1, eval('v:exiting is v:null'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is 0 on normal exit', function()
|
local function test_exiting(setup_fn)
|
||||||
local function on_setup()
|
local function on_setup()
|
||||||
command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
|
command('autocmd VimLeavePre * call rpcrequest('..cid..', "exit", "VimLeavePre")')
|
||||||
command('autocmd VimLeave * call rpcrequest('..cid..', "")')
|
command('autocmd VimLeave * call rpcrequest('..cid..', "exit", "VimLeave")')
|
||||||
command('quit')
|
setup_fn()
|
||||||
end
|
end
|
||||||
local function on_request()
|
local requests_args = {}
|
||||||
|
local function on_request(name, args)
|
||||||
|
eq('exit', name)
|
||||||
|
table.insert(requests_args, args)
|
||||||
eq(0, eval('v:exiting'))
|
eq(0, eval('v:exiting'))
|
||||||
return ''
|
return ''
|
||||||
end
|
end
|
||||||
run(on_request, nil, on_setup)
|
run(on_request, nil, on_setup)
|
||||||
|
eq({{'VimLeavePre'}, {'VimLeave'}}, requests_args)
|
||||||
|
end
|
||||||
|
|
||||||
|
it('is 0 on normal exit', function()
|
||||||
|
test_exiting(function()
|
||||||
|
command('quit')
|
||||||
end)
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
it('is 0 on exit from Ex mode involving try-catch vim-patch:8.0.0184', function()
|
it('is 0 on exit from Ex mode involving try-catch vim-patch:8.0.0184', function()
|
||||||
local function on_setup()
|
test_exiting(function()
|
||||||
command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
|
|
||||||
command('autocmd VimLeave * call rpcrequest('..cid..', "")')
|
|
||||||
feed('gQ')
|
feed('gQ')
|
||||||
feed_command('try', 'call NoFunction()', 'catch', 'echo "bye"', 'endtry', 'quit')
|
feed_command('try', 'call NoFunction()', 'catch', 'echo "bye"', 'endtry', 'quit')
|
||||||
end
|
end)
|
||||||
local function on_request()
|
|
||||||
eq(0, eval('v:exiting'))
|
|
||||||
return ''
|
|
||||||
end
|
|
||||||
run(on_request, nil, on_setup)
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user