From f8f82901cdd0ccd5308e05c73af6deb7d083720f Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 1 Feb 2023 12:54:22 +0100 Subject: fix(tests): fixes for using vim.mpack and more ASAN --- test/functional/shada/shada_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/shada') diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua index 88a99d9b55..7b1ce5d0ca 100644 --- a/test/functional/shada/shada_spec.lua +++ b/test/functional/shada/shada_spec.lua @@ -126,11 +126,11 @@ 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) -- cgit From 7d58de11f49c574a8a305e28e96b9ff810493012 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 18:25:01 +0800 Subject: fix(rpc)!: preseve files when stdio channel is closed (#22137) BREAKING CHANGE: Unsaved changes are now preserved rather than discarded when stdio channel is closed. --- test/functional/shada/helpers.lua | 1 + test/functional/shada/history_spec.lua | 1 - test/functional/shada/shada_spec.lua | 38 ++++++++++++++++++---------------- 3 files changed, 21 insertions(+), 19 deletions(-) (limited to 'test/functional/shada') 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..aa4106ad63 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', diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua index 7b1ce5d0ca..24bd363e95 100644 --- a/test/functional/shada/shada_spec.lua +++ b/test/functional/shada/shada_spec.lua @@ -136,24 +136,6 @@ describe('ShaDa support code', function() 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 = {} @@ -263,3 +245,23 @@ describe('ShaDa support code', function() meths.set_option('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, 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) +end) -- cgit From 743860de40502227b3f0ed64317eb937d24d4a36 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 4 Apr 2023 21:59:06 +0200 Subject: test: replace lfs with luv and vim.fs test: replace lfs with luv luv already pretty much does everything lfs does, so this duplication of dependencies isn't needed. --- test/functional/shada/shada_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/shada') diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua index 24bd363e95..cc21d08620 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() @@ -251,8 +251,8 @@ describe('ShaDa support code', 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')) + eq(nil, luv.fs_stat('NONE')) + eq(nil, luv.fs_stat('NONE.tmp.a')) end) it('does not read NONE file', function() -- cgit From bfb28b62dab756ec76a73506c2070ddf491a0cdd Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Thu, 13 Apr 2023 15:29:13 -0600 Subject: refactor: remove modelines from Lua files Now that we have builtin EditorConfig support and a formatting check in CI, these are not necessary. --- test/functional/shada/merging_spec.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'test/functional/shada') 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 -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- test/functional/shada/buffers_spec.lua | 8 ++++---- test/functional/shada/history_spec.lua | 8 ++++---- test/functional/shada/shada_spec.lua | 34 +++++++++++++++++----------------- 3 files changed, 25 insertions(+), 25 deletions(-) (limited to 'test/functional/shada') diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua index 26a4569fce..2740eeeca6 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, {buf=0}) 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', {buf=0}) expect_exit(nvim_command, 'qall') reset('set shada+=%') eq(2, funcs.bufnr('$')) diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua index aa4106ad63..433db3171e 100644 --- a/test/functional/shada/history_spec.lua +++ b/test/functional/shada/history_spec.lua @@ -106,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('.')) @@ -121,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/shada_spec.lua b/test/functional/shada/shada_spec.lua index cc21d08620..3a3238eb34 100644 --- a/test/functional/shada/shada_spec.lua +++ b/test/functional/shada/shada_spec.lua @@ -196,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() @@ -237,12 +237,12 @@ 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) -- cgit From 576dddb46168e81aa0f78c28816082c662dedea1 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Mon, 22 May 2023 12:47:10 +0600 Subject: test: don't unnecessarily specify win/buf for `nvim_(get|set)_option_value` `nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter. --- test/functional/shada/buffers_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/shada') diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua index 2740eeeca6..b1c4ded541 100644 --- a/test/functional/shada/buffers_spec.lua +++ b/test/functional/shada/buffers_spec.lua @@ -48,7 +48,7 @@ describe('shada support code', function() reset('set shada+=%') nvim_command('edit ' .. testfilename) nvim_command('edit ' .. testfilename_2) - meths.set_option_value('buflisted', false, {buf=0}) + 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) - meths.set_option_value('buftype', 'quickfix', {buf=0}) + meths.set_option_value('buftype', 'quickfix', {}) expect_exit(nvim_command, 'qall') reset('set shada+=%') eq(2, funcs.bufnr('$')) -- cgit From ee56daebb6468075e743db0d605cb3f2a1699419 Mon Sep 17 00:00:00 2001 From: Maria José Solano Date: Wed, 30 Aug 2023 19:15:49 -0700 Subject: fix(shada): update deleted marks (#24936) Fix #4295 Close #16067 Co-authored-by: chentau --- test/functional/shada/marks_spec.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/functional/shada') diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index a91be18841..07364382e8 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,24 @@ describe('ShaDa support code', function() eq('', funcs.system(argv)) eq(0, exc_exec('rshada')) end) + + it('updates deleted marks', 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') + nvim_command('wshada') + nvim_command('normal! `A`a`.') + + nvim_command('delmarks A a .') + nvim_command('wshada') + + reset() + 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) end) -- cgit From bc43575c521ab822efc8c25439dbad59aa119188 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 2 Sep 2023 10:23:43 +0800 Subject: test(shada/marks_spec): load the file with the marks (#24979) --- test/functional/shada/marks_spec.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test/functional/shada') diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index 07364382e8..a73e9a244d 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -250,7 +250,7 @@ describe('ShaDa support code', function() eq(0, exc_exec('rshada')) end) - it('updates deleted marks', function() + it('updates deleted marks with :delmarks', function() nvim_command('edit ' .. testfilename) nvim_command('mark A') @@ -259,12 +259,15 @@ describe('ShaDa support code', function() -- since it can't be set via :mark feed('ggifoobar') nvim_command('wshada') - nvim_command('normal! `A`a`.') + 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! `.')) -- cgit From 517dfdf0fcf5c9c88c83dbb77a931b8e940b7472 Mon Sep 17 00:00:00 2001 From: Maria José Solano Date: Sat, 2 Sep 2023 19:34:09 -0700 Subject: fix(shada): update marks when using delmarks! (#24978) --- test/functional/shada/marks_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/shada') diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index a73e9a244d..7f03022ab8 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -272,4 +272,26 @@ describe('ShaDa support code', function() 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') + 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) -- cgit