mirror of
https://github.com/neovim/neovim.git
synced 2024-12-26 14:11:15 -07:00
168a46fd31
During test setup, we used to call a vimscript function(BeforeEachTest) that attempted to restore Nvim to it's initial state as much as possible in order to provide a clean environment for running new tests. This approach has proven to be unreliable, as some tests leave state that can affect other tests, eventually causing failures that are difficult to debug. This commit changes the 'clear' function so it will restart Nvim every time it is called, which is a slower, but more reliable solution that will simplify spotting bugs in the future. Some other improvements/fixes were also performed: - Whenever an error is detected in a handler passed to "run()", the event loop will be stopped and the error will be propagated to the main thread. - Errors and the "cleanup()" function will always send a quit command to the current Nvim instance. This should prevent memory starvation when running tests under valgrind(where each Nvim instance can consume a lot of memory). - Fixed a wrong assertion in server_requests_spec.lua. Previously the failure was undetected in a notification handler. - Fixed some tests to expect fully clean registers. The deleted cleanup function used to put an empty string in every register, but that resulted in a extra line being added.
82 lines
1.9 KiB
Lua
82 lines
1.9 KiB
Lua
-- Test for autocommand that redefines the argument list, when doing ":all".
|
||
|
||
local helpers = require('test.functional.helpers')
|
||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||
local execute, dedent, eq = helpers.execute, helpers.dedent, helpers.eq
|
||
local curbuf_contents = helpers.curbuf_contents
|
||
|
||
describe('argument list', function()
|
||
setup(clear)
|
||
|
||
it('is working', function()
|
||
insert([[
|
||
start of test file Xxx
|
||
this is a test
|
||
this is a test
|
||
this is a test
|
||
this is a test
|
||
end of test file Xxx]])
|
||
|
||
execute('au BufReadPost Xxx2 next Xxx2 Xxx1')
|
||
execute('/^start of')
|
||
|
||
-- Write test file Xxx1
|
||
feed('A1<Esc>:.,/end of/w! Xxx1<cr>')
|
||
|
||
-- Write test file Xxx2
|
||
feed('$r2:.,/end of/w! Xxx2<cr>')
|
||
|
||
-- Write test file Xxx3
|
||
feed('$r3:.,/end of/w! Xxx3<cr>')
|
||
|
||
-- Redefine arglist; go to Xxx1
|
||
execute('next! Xxx1 Xxx2 Xxx3')
|
||
|
||
-- Open window for all args
|
||
execute('all')
|
||
|
||
-- Write contents of Xxx1
|
||
execute('%yank A')
|
||
|
||
-- Append contents of last window (Xxx1)
|
||
feed('')
|
||
execute('%yank A')
|
||
|
||
-- should now be in Xxx2
|
||
execute('rew')
|
||
|
||
-- Append contents of Xxx2
|
||
execute('%yank A')
|
||
|
||
execute('%d')
|
||
execute('0put=@a')
|
||
execute('$d')
|
||
|
||
eq(dedent([[
|
||
start of test file Xxx1
|
||
this is a test
|
||
this is a test
|
||
this is a test
|
||
this is a test
|
||
end of test file Xxx
|
||
start of test file Xxx1
|
||
this is a test
|
||
this is a test
|
||
this is a test
|
||
this is a test
|
||
end of test file Xxx
|
||
start of test file Xxx2
|
||
this is a test
|
||
this is a test
|
||
this is a test
|
||
this is a test
|
||
end of test file Xxx]]), curbuf_contents())
|
||
end)
|
||
|
||
teardown(function()
|
||
os.remove('Xxx1')
|
||
os.remove('Xxx2')
|
||
os.remove('Xxx3')
|
||
end)
|
||
end)
|