aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada/shada_spec.lua
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/shada_spec.lua
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/shada_spec.lua')
-rw-r--r--test/functional/shada/shada_spec.lua82
1 files changed, 42 insertions, 40 deletions
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)