aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
commit1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch)
treecd08258054db80bb9a11b1061bb091c70b76926a /test/functional/shada
parenteaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-aucmd_textputpost.tar.gz
rneovim-aucmd_textputpost.tar.bz2
rneovim-aucmd_textputpost.zip
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'test/functional/shada')
-rw-r--r--test/functional/shada/buffers_spec.lua8
-rw-r--r--test/functional/shada/helpers.lua1
-rw-r--r--test/functional/shada/history_spec.lua9
-rw-r--r--test/functional/shada/marks_spec.lua46
-rw-r--r--test/functional/shada/merging_spec.lua2
-rw-r--r--test/functional/shada/shada_spec.lua82
6 files changed, 97 insertions, 51 deletions
diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua
index 26a4569fce..b1c4ded541 100644
--- a/test/functional/shada/buffers_spec.lua
+++ b/test/functional/shada/buffers_spec.lua
@@ -1,7 +1,7 @@
-- shada buffer list saving/reading support
local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, funcs, eq, curbufmeths =
- helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths
+local nvim_command, funcs, eq, curbufmeths, meths =
+ helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths, helpers.meths
local expect_exit = helpers.expect_exit
local shada_helpers = require('test.functional.shada.helpers')
@@ -48,7 +48,7 @@ describe('shada support code', function()
reset('set shada+=%')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
- curbufmeths.set_option('buflisted', false)
+ meths.set_option_value('buflisted', false, {})
expect_exit(nvim_command, 'qall')
reset('set shada+=%')
eq(2, funcs.bufnr('$'))
@@ -60,7 +60,7 @@ describe('shada support code', function()
reset('set shada+=%')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
- curbufmeths.set_option('buftype', 'quickfix')
+ meths.set_option_value('buftype', 'quickfix', {})
expect_exit(nvim_command, 'qall')
reset('set shada+=%')
eq(2, funcs.bufnr('$'))
diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/helpers.lua
index fb3ec4a87c..cd99d38345 100644
--- a/test/functional/shada/helpers.lua
+++ b/test/functional/shada/helpers.lua
@@ -33,6 +33,7 @@ local function reset(o)
end
local clear = function()
+ helpers.expect_exit(helpers.command, 'qall!')
os.remove(tmpname)
end
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
index d1daf6c7cc..433db3171e 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -32,7 +32,6 @@ describe('ShaDa support code', function()
nvim_command('rshada')
eq('" Test 2', funcs.histget(':', -1))
eq('" Test', funcs.histget(':', -2))
- expect_exit(nvim_command, 'qall')
end)
it('respects &history when dumping',
@@ -107,13 +106,13 @@ describe('ShaDa support code', function()
end)
it('dumps and loads last search pattern with offset', function()
- meths.set_option('wrapscan', false)
+ meths.set_option_value('wrapscan', false, {})
funcs.setline('.', {'foo', 'bar--'})
nvim_feed('gg0/a/e+1\n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
nvim_command('wshada')
reset()
- meths.set_option('wrapscan', false)
+ meths.set_option_value('wrapscan', false, {})
funcs.setline('.', {'foo', 'bar--'})
nvim_feed('gg0n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
@@ -122,13 +121,13 @@ describe('ShaDa support code', function()
it('dumps and loads last search pattern with offset and backward direction',
function()
- meths.set_option('wrapscan', false)
+ meths.set_option_value('wrapscan', false, {})
funcs.setline('.', {'foo', 'bar--'})
nvim_feed('G$?a?e+1\n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
nvim_command('wshada')
reset()
- meths.set_option('wrapscan', false)
+ meths.set_option_value('wrapscan', false, {})
funcs.setline('.', {'foo', 'bar--'})
nvim_feed('G$n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index a91be18841..7f03022ab8 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local meths, curwinmeths, curbufmeths, nvim_command, funcs, eq =
helpers.meths, helpers.curwinmeths, helpers.curbufmeths, helpers.command,
helpers.funcs, helpers.eq
+local feed = helpers.feed
local exc_exec, exec_capture = helpers.exc_exec, helpers.exec_capture
local expect_exit = helpers.expect_exit
@@ -248,4 +249,49 @@ describe('ShaDa support code', function()
eq('', funcs.system(argv))
eq(0, exc_exec('rshada'))
end)
+
+ it('updates deleted marks with :delmarks', function()
+ nvim_command('edit ' .. testfilename)
+
+ nvim_command('mark A')
+ nvim_command('mark a')
+ -- create a change to set the '.' mark,
+ -- since it can't be set via :mark
+ feed('ggifoobar<esc>')
+ nvim_command('wshada')
+
+ reset()
+ nvim_command('edit ' .. testfilename)
+ nvim_command('normal! `A`a`.')
+ nvim_command('delmarks A a .')
+ nvim_command('wshada')
+
+ reset()
+ nvim_command('edit ' .. testfilename)
+ eq('Vim(normal):E20: Mark not set', exc_exec('normal! `A'))
+ eq('Vim(normal):E20: Mark not set', exc_exec('normal! `a'))
+ eq('Vim(normal):E20: Mark not set', exc_exec('normal! `.'))
+ end)
+
+ it('updates deleted marks with :delmarks!', function()
+ nvim_command('edit ' .. testfilename)
+
+ nvim_command('mark A')
+ nvim_command('mark a')
+ feed('ggifoobar<esc>')
+ nvim_command('wshada')
+
+ reset()
+ nvim_command('edit ' .. testfilename)
+ nvim_command('normal! `A`a`.')
+ nvim_command('delmarks!')
+ nvim_command('wshada')
+
+ reset()
+ nvim_command('edit ' .. testfilename)
+ eq('Vim(normal):E20: Mark not set', exc_exec('normal! `a'))
+ eq('Vim(normal):E20: Mark not set', exc_exec('normal! `.'))
+ -- Make sure that uppercase marks aren't deleted.
+ nvim_command('normal! `A')
+ end)
end)
diff --git a/test/functional/shada/merging_spec.lua b/test/functional/shada/merging_spec.lua
index da2fbbe029..dad7aa851d 100644
--- a/test/functional/shada/merging_spec.lua
+++ b/test/functional/shada/merging_spec.lua
@@ -1115,5 +1115,3 @@ describe('ShaDa changes support code', function()
eq(found, 100)
end)
end)
-
--- vim: ts=2 sw=2
diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua
index 88a99d9b55..3a3238eb34 100644
--- a/test/functional/shada/shada_spec.lua
+++ b/test/functional/shada/shada_spec.lua
@@ -8,7 +8,7 @@ local write_file, spawn, set_session, nvim_prog, exc_exec =
local is_os = helpers.is_os
local skip = helpers.skip
-local lfs = require('lfs')
+local luv = require('luv')
local paths = require('test.cmakeconfig.paths')
local mpack = require('mpack')
@@ -29,7 +29,7 @@ describe('ShaDa support code', function()
after_each(function()
clear()
clean()
- lfs.rmdir(dirname)
+ luv.fs_rmdir(dirname)
end)
it('preserves `s` item size limit with unknown entries', function()
@@ -81,7 +81,7 @@ describe('ShaDa support code', function()
wshada('Some text file')
eq(0, exc_exec('wshada! ' .. shada_fname))
eq(1, read_shada_file(shada_fname)[1].type)
- eq(nil, lfs.attributes(shada_fname .. '.tmp.a'))
+ eq(nil, luv.fs_stat(shada_fname .. '.tmp.a'))
end)
it('leaves .tmp.b in-place when there is error in original ShaDa and it has .tmp.a', function()
@@ -126,34 +126,16 @@ describe('ShaDa support code', function()
wshada(s .. table.concat(msgpack, e .. s) .. e)
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
- local typ = mpack.unpack(s)
+ local typ = mpack.decode(s)
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == typ then
found = found + 1
- eq(mpack.unpack(msgpack[found]), v.timestamp)
+ eq(mpack.decode(msgpack[found]), v.timestamp)
end
end
eq(#msgpack, found)
end)
- it('does not write NONE file', function()
- local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
- '--headless', '--cmd', 'qall'}, true)
- session:close()
- eq(nil, lfs.attributes('NONE'))
- eq(nil, lfs.attributes('NONE.tmp.a'))
- end)
-
- it('does not read NONE file', function()
- write_file('NONE', '\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
- local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
- '--headless'}, true)
- set_session(session)
- eq('', funcs.getreg('a'))
- session:close()
- os.remove('NONE')
- end)
-
local marklike = {[7]=true, [8]=true, [10]=true, [11]=true}
local find_file = function(fname)
local found = {}
@@ -214,30 +196,30 @@ describe('ShaDa support code', function()
end)
it('is able to set &shada after &viminfo', function()
- meths.set_option('viminfo', '\'10')
- eq('\'10', meths.get_option('viminfo'))
- eq('\'10', meths.get_option('shada'))
- meths.set_option('shada', '')
- eq('', meths.get_option('viminfo'))
- eq('', meths.get_option('shada'))
+ meths.set_option_value('viminfo', '\'10', {})
+ eq('\'10', meths.get_option_value('viminfo', {}))
+ eq('\'10', meths.get_option_value('shada', {}))
+ meths.set_option_value('shada', '', {})
+ eq('', meths.get_option_value('viminfo', {}))
+ eq('', meths.get_option_value('shada', {}))
end)
it('is able to set all& after setting &shada', function()
- meths.set_option('shada', '\'10')
- eq('\'10', meths.get_option('viminfo'))
- eq('\'10', meths.get_option('shada'))
+ meths.set_option_value('shada', '\'10', {})
+ eq('\'10', meths.get_option_value('viminfo', {}))
+ eq('\'10', meths.get_option_value('shada', {}))
nvim_command('set all&')
- eq('!,\'100,<50,s10,h', meths.get_option('viminfo'))
- eq('!,\'100,<50,s10,h', meths.get_option('shada'))
+ eq('!,\'100,<50,s10,h', meths.get_option_value('viminfo', {}))
+ eq('!,\'100,<50,s10,h', meths.get_option_value('shada', {}))
end)
it('is able to set &shada after &viminfo using :set', function()
nvim_command('set viminfo=\'10')
- eq('\'10', meths.get_option('viminfo'))
- eq('\'10', meths.get_option('shada'))
+ eq('\'10', meths.get_option_value('viminfo', {}))
+ eq('\'10', meths.get_option_value('shada', {}))
nvim_command('set shada=')
- eq('', meths.get_option('viminfo'))
- eq('', meths.get_option('shada'))
+ eq('', meths.get_option_value('viminfo', {}))
+ eq('', meths.get_option_value('shada', {}))
end)
it('setting &shada gives proper error message on missing number', function()
@@ -255,11 +237,31 @@ describe('ShaDa support code', function()
funcs.mkdir(dirname, '', 0)
eq(0, funcs.filewritable(dirname))
reset{shadafile=dirshada, args={'--cmd', 'set shada='}}
- meths.set_option('shada', '\'10')
+ meths.set_option_value('shada', '\'10', {})
eq('Vim(wshada):E886: System error while opening ShaDa file '
.. 'Xtest-functional-shada-shada.d/main.shada for reading to merge '
.. 'before writing it: permission denied',
exc_exec('wshada'))
- meths.set_option('shada', '')
+ meths.set_option_value('shada', '', {})
+ end)
+end)
+
+describe('ShaDa support code', function()
+ it('does not write NONE file', function()
+ local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
+ '--headless', '--cmd', 'qall'}, true)
+ session:close()
+ eq(nil, luv.fs_stat('NONE'))
+ eq(nil, luv.fs_stat('NONE.tmp.a'))
+ end)
+
+ it('does not read NONE file', function()
+ write_file('NONE', '\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
+ local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
+ '--headless'}, true)
+ set_session(session)
+ eq('', funcs.getreg('a'))
+ session:close()
+ os.remove('NONE')
end)
end)