aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-06-08 23:22:50 +0200
committerbfredl <bjorn.linse@gmail.com>2022-06-13 10:15:44 +0200
commite3281d992e1b9366d67a4b4399e3b5e11bb6c1cc (patch)
treefe0a8377115e946faf1c0328285331b4fd6c8a4c /test/functional/shada
parentdd8b6094c03362cc60d627ce709a4a0f9825b86a (diff)
downloadrneovim-e3281d992e1b9366d67a4b4399e3b5e11bb6c1cc.tar.gz
rneovim-e3281d992e1b9366d67a4b4399e3b5e11bb6c1cc.tar.bz2
rneovim-e3281d992e1b9366d67a4b4399e3b5e11bb6c1cc.zip
fix(tests): check for EOF on exit of nvim properly
Diffstat (limited to 'test/functional/shada')
-rw-r--r--test/functional/shada/buffers_spec.lua15
-rw-r--r--test/functional/shada/history_spec.lua21
-rw-r--r--test/functional/shada/marks_spec.lua15
-rw-r--r--test/functional/shada/registers_spec.lua29
-rw-r--r--test/functional/shada/variables_spec.lua7
5 files changed, 46 insertions, 41 deletions
diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua
index 04c9c01d7c..26a4569fce 100644
--- a/test/functional/shada/buffers_spec.lua
+++ b/test/functional/shada/buffers_spec.lua
@@ -2,6 +2,7 @@
local helpers = require('test.functional.helpers')(after_each)
local nvim_command, funcs, eq, curbufmeths =
helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths
+local expect_exit = helpers.expect_exit
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -15,7 +16,7 @@ describe('shada support code', function()
reset('set shada+=%')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset('set shada+=%')
eq(3, funcs.bufnr('$'))
eq('', funcs.bufname(1))
@@ -27,7 +28,7 @@ describe('shada support code', function()
reset('set shada+=%')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq(1, funcs.bufnr('$'))
eq('', funcs.bufname(1))
@@ -37,7 +38,7 @@ describe('shada support code', function()
reset()
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset('set shada+=%')
eq(1, funcs.bufnr('$'))
eq('', funcs.bufname(1))
@@ -48,7 +49,7 @@ describe('shada support code', function()
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
curbufmeths.set_option('buflisted', false)
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset('set shada+=%')
eq(2, funcs.bufnr('$'))
eq('', funcs.bufname(1))
@@ -60,7 +61,7 @@ describe('shada support code', function()
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
curbufmeths.set_option('buftype', 'quickfix')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset('set shada+=%')
eq(2, funcs.bufnr('$'))
eq('', funcs.bufname(1))
@@ -73,7 +74,7 @@ describe('shada support code', function()
nvim_command('enew')
curbufmeths.set_lines(0, 1, true, {'bar'})
eq(2, funcs.bufnr('$'))
- nvim_command('qall!')
+ expect_exit(nvim_command, 'qall!')
reset('set shada+=% hidden')
eq(1, funcs.bufnr('$'))
eq('', funcs.bufname(1))
@@ -83,7 +84,7 @@ describe('shada support code', function()
reset('set shada+=%1')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset('set shada+=%1')
eq(2, funcs.bufnr('$'))
eq('', funcs.bufname(1))
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
index 84cc34c7cc..d1daf6c7cc 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local nvim_command, funcs, meths, nvim_feed, eq =
helpers.command, helpers.funcs, helpers.meths, helpers.feed, helpers.eq
local assert_alive = helpers.assert_alive
+local expect_exit = helpers.expect_exit
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -25,13 +26,13 @@ describe('ShaDa support code', function()
nvim_command('set shada=\'0 history=2')
nvim_feed(':" Test\n')
nvim_feed(':" Test 2\n')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
nvim_command('set shada=\'0 history=2')
nvim_command('rshada')
eq('" Test 2', funcs.histget(':', -1))
eq('" Test', funcs.histget(':', -2))
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
end)
it('respects &history when dumping',
@@ -138,7 +139,7 @@ describe('ShaDa support code', function()
nvim_command('set hlsearch shada-=h')
nvim_feed('/test\n')
eq(1, meths.get_vvar('hlsearch'))
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq(1, meths.get_vvar('hlsearch'))
end)
@@ -147,7 +148,7 @@ describe('ShaDa support code', function()
nvim_command('set hlsearch shada-=h')
nvim_feed('/test\n')
nvim_command('nohlsearch')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq(0, meths.get_vvar('hlsearch'))
end)
@@ -156,7 +157,7 @@ describe('ShaDa support code', function()
nvim_command('set hlsearch')
nvim_feed('/test\n')
eq(1, meths.get_vvar('hlsearch'))
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq(0, meths.get_vvar('hlsearch'))
end)
@@ -175,7 +176,7 @@ describe('ShaDa support code', function()
it('dumps and loads history with UTF-8 characters', function()
reset()
nvim_feed(':echo "«"\n')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq('echo "«"', funcs.histget(':', -1))
end)
@@ -183,7 +184,7 @@ describe('ShaDa support code', function()
it('dumps and loads replacement with UTF-8 characters',
function()
nvim_command('substitute/./«/ge')
- nvim_command('qall!')
+ expect_exit(nvim_command, 'qall!')
reset()
funcs.setline('.', {'.'})
nvim_command('&')
@@ -193,7 +194,7 @@ describe('ShaDa support code', function()
it('dumps and loads substitute pattern with UTF-8 characters',
function()
nvim_command('substitute/«/./ge')
- nvim_command('qall!')
+ expect_exit(nvim_command, 'qall!')
reset()
funcs.setline('.', {'«\171'})
nvim_command('&')
@@ -204,7 +205,7 @@ describe('ShaDa support code', function()
function()
nvim_command('silent! /«/')
nvim_command('set shada+=/0')
- nvim_command('qall!')
+ expect_exit(nvim_command, 'qall!')
reset()
funcs.setline('.', {'\171«'})
nvim_command('~&')
@@ -217,7 +218,7 @@ describe('ShaDa support code', function()
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
nvim_command('silent! /\171/')
nvim_command('set shada+=/0')
- nvim_command('qall!')
+ expect_exit(nvim_command, 'qall!')
reset()
funcs.setline('.', {'\171«'})
nvim_command('~&')
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index 153a1c346f..a91be18841 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -4,6 +4,7 @@ local meths, curwinmeths, curbufmeths, nvim_command, funcs, eq =
helpers.meths, helpers.curwinmeths, helpers.curbufmeths, helpers.command,
helpers.funcs, helpers.eq
local exc_exec, exec_capture = helpers.exc_exec, helpers.exec_capture
+local expect_exit = helpers.expect_exit
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -79,7 +80,7 @@ describe('ShaDa support code', function()
nvim_command('mark a')
nvim_command('2')
nvim_command('kb')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
nvim_command('edit ' .. testfilename)
nvim_command('normal! `a')
@@ -92,7 +93,7 @@ describe('ShaDa support code', function()
it('is able to dump and read back mark "', function()
nvim_command('edit ' .. testfilename)
nvim_command('2')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
nvim_command('edit ' .. testfilename)
nvim_command('normal! `"')
@@ -104,7 +105,7 @@ describe('ShaDa support code', function()
nvim_command('tabedit ' .. testfilename_2)
nvim_command('2')
nvim_command('q!')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
nvim_command('edit ' .. testfilename_2)
nvim_command('normal! `"')
@@ -116,7 +117,7 @@ describe('ShaDa support code', function()
local tf_full = curbufmeths.get_name()
nvim_command('edit ' .. testfilename_2)
local tf_full_2 = curbufmeths.get_name()
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
local oldfiles = meths.get_vvar('oldfiles')
table.sort(oldfiles)
@@ -145,7 +146,7 @@ describe('ShaDa support code', function()
nvim_command('enew')
nvim_command('normal! gg')
local saved = exec_capture('jumps')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq(saved, exec_capture('jumps'))
end)
@@ -176,7 +177,7 @@ describe('ShaDa support code', function()
nvim_command('normal! G')
nvim_command('sleep 2')
nvim_command('normal! gg')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
nvim_command('redraw')
nvim_command('edit ' .. testfilename)
@@ -200,7 +201,7 @@ describe('ShaDa support code', function()
nvim_command('edit ' .. testfilename)
nvim_command('normal! Gra')
nvim_command('normal! ggrb')
- nvim_command('qall!')
+ expect_exit(nvim_command, 'qall!')
reset()
nvim_command('edit ' .. testfilename)
nvim_command('normal! Gg;')
diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua
index 1f06cbe350..6aaa54cce8 100644
--- a/test/functional/shada/registers_spec.lua
+++ b/test/functional/shada/registers_spec.lua
@@ -4,6 +4,7 @@ local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear = shada_helpers.reset, shada_helpers.clear
+local expect_exit = helpers.expect_exit
local setreg = function(name, contents, typ)
if type(contents) == 'string' then
@@ -27,7 +28,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -39,7 +40,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{}, ''}, getreg('c'))
eq({{}, ''}, getreg('l'))
@@ -50,7 +51,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset('set shada=\'0,<0')
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -62,7 +63,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{}, ''}, getreg('c'))
eq({{}, ''}, getreg('l'))
@@ -73,7 +74,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset('set shada=\'0,\\"0')
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -85,7 +86,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -96,7 +97,7 @@ describe('ShaDa support code', function()
nvim_command('set shada=\'0,<2')
setreg('o', {'d'}, 'c')
setreg('t', {'a', 'b', 'cde'}, 'l')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
eq({{}, ''}, getreg('t'))
@@ -106,7 +107,7 @@ describe('ShaDa support code', function()
nvim_command('set shada=\'0,\\"2')
setreg('o', {'d'}, 'c')
setreg('t', {'a', 'b', 'cde'}, 'l')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
eq({{}, ''}, getreg('t'))
@@ -117,7 +118,7 @@ describe('ShaDa support code', function()
setreg('o', {'d'}, 'c')
setreg('t', {'a', 'b', 'cde'}, 'l')
setreg('h', {'abc', 'acb', 'bac', 'bca', 'cab', 'cba'}, 'b3')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('t'))
@@ -128,7 +129,7 @@ describe('ShaDa support code', function()
function()
reset()
setreg('e', {'«'}, 'c')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'«'}, 'v'}, getreg('e'))
end)
@@ -138,7 +139,7 @@ describe('ShaDa support code', function()
reset()
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
setreg('e', {'\171«'}, 'c')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'\171«'}, 'v'}, getreg('e'))
end)
@@ -148,7 +149,7 @@ describe('ShaDa support code', function()
setreg('1', {'one'}, 'c')
setreg('2', {'two'}, 'c')
setreg('a', {'a'}, 'c')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{}, ''}, getreg('0'))
eq({{'one'}, 'v'}, getreg('1'))
@@ -161,7 +162,7 @@ describe('ShaDa support code', function()
setreg('0', {'zero'}, 'c')
setreg('1', {'one'}, 'c')
setreg('2', {'two'}, 'c')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'zero'}, 'v'}, getreg('0'))
eq({{'one'}, 'v'}, getreg('1'))
@@ -173,7 +174,7 @@ describe('ShaDa support code', function()
setreg('0', {'zero'}, 'c')
setreg('1', {'one'}, 'cu')
setreg('2', {'two'}, 'c')
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq({{'zero'}, 'v'}, getreg('0'))
eq({{'one'}, 'v'}, getreg('1'))
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua
index 854add1363..a91b7eb193 100644
--- a/test/functional/shada/variables_spec.lua
+++ b/test/functional/shada/variables_spec.lua
@@ -2,6 +2,7 @@
local helpers = require('test.functional.helpers')(after_each)
local meths, funcs, nvim_command, eq, eval =
helpers.meths, helpers.funcs, helpers.command, helpers.eq, helpers.eval
+local expect_exit = helpers.expect_exit
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -33,7 +34,7 @@ describe('ShaDa support code', function()
local vartype = eval('type(g:' .. varname .. ')')
-- Exit during `reset` is not a regular exit: it does not write shada
-- automatically
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset('set shada+=!')
eq(vartype, eval('type(g:' .. varname .. ')'))
eq(varval, meths.get_var(varname))
@@ -98,7 +99,7 @@ describe('ShaDa support code', function()
meths.set_var('LSTVAR', {'«'})
meths.set_var('DCTVAR', {['«']='«'})
meths.set_var('NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq('«', meths.get_var('STRVAR'))
eq({'«'}, meths.get_var('LSTVAR'))
@@ -116,7 +117,7 @@ describe('ShaDa support code', function()
meths.set_var('DCTVAR', {['«\171']='«\171'})
meths.set_var('NESTEDVAR', {['\171']={{'\171«'}, {['\171']='\171'},
{a='Test'}}})
- nvim_command('qall')
+ expect_exit(nvim_command, 'qall')
reset()
eq('\171', meths.get_var('STRVAR'))
eq({'\171'}, meths.get_var('LSTVAR'))