aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/shada')
-rw-r--r--test/functional/shada/buffers_spec.lua12
-rw-r--r--test/functional/shada/compatibility_spec.lua16
-rw-r--r--test/functional/shada/errors_spec.lua10
-rw-r--r--test/functional/shada/history_spec.lua27
-rw-r--r--test/functional/shada/marks_spec.lua32
-rw-r--r--test/functional/shada/merging_spec.lua63
-rw-r--r--test/functional/shada/registers_spec.lua11
-rw-r--r--test/functional/shada/shada_spec.lua24
-rw-r--r--test/functional/shada/testutil.lua (renamed from test/functional/shada/helpers.lua)16
-rw-r--r--test/functional/shada/variables_spec.lua12
10 files changed, 122 insertions, 101 deletions
diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua
index 9fead98fed..07b0bf4217 100644
--- a/test/functional/shada/buffers_spec.lua
+++ b/test/functional/shada/buffers_spec.lua
@@ -1,10 +1,12 @@
-- shada buffer list saving/reading support
-local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, fn, eq, api = helpers.command, helpers.fn, helpers.eq, helpers.api
-local expect_exit = helpers.expect_exit
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear = shada_helpers.reset, shada_helpers.clear
+local nvim_command, fn, eq, api = n.command, n.fn, t.eq, n.api
+local expect_exit = n.expect_exit
+
+local reset, clear = t_shada.reset, t_shada.clear
describe('shada support code', function()
local testfilename = 'Xtestfile-functional-shada-buffers'
diff --git a/test/functional/shada/compatibility_spec.lua b/test/functional/shada/compatibility_spec.lua
index bc4e9675c6..98d3884098 100644
--- a/test/functional/shada/compatibility_spec.lua
+++ b/test/functional/shada/compatibility_spec.lua
@@ -1,18 +1,18 @@
-- ShaDa compatibility support
-local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, fn, eq = helpers.command, helpers.fn, helpers.eq
-local exc_exec = helpers.exc_exec
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear, get_shada_rw =
- shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
-local read_shada_file = shada_helpers.read_shada_file
+local nvim_command, fn, eq = n.command, n.fn, t.eq
+local exc_exec = n.exc_exec
+local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw
+local read_shada_file = t_shada.read_shada_file
local wshada, sdrcmd, shada_fname = get_shada_rw('Xtest-functional-shada-compatibility.shada')
local mock_file_path = '/a/b/'
local mock_file_path2 = '/d/e/'
-if helpers.is_os('win') then
+if t.is_os('win') then
mock_file_path = 'C:/a/'
mock_file_path2 = 'C:/d/'
end
diff --git a/test/functional/shada/errors_spec.lua b/test/functional/shada/errors_spec.lua
index 233f03e5c0..a9084da929 100644
--- a/test/functional/shada/errors_spec.lua
+++ b/test/functional/shada/errors_spec.lua
@@ -1,10 +1,10 @@
-- ShaDa errors handling support
-local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, eq, exc_exec = helpers.command, helpers.eq, helpers.exc_exec
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear, get_shada_rw =
- shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
+local nvim_command, eq, exc_exec = n.command, t.eq, n.exc_exec
+local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw
local wshada, sdrcmd, shada_fname, clean = get_shada_rw('Xtest-functional-shada-errors.shada')
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
index c8a19bb082..39a5f8df7e 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -1,12 +1,13 @@
-- ShaDa history saving/reading support
-local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, fn, api, nvim_feed, eq =
- helpers.command, helpers.fn, helpers.api, helpers.feed, helpers.eq
-local assert_alive = helpers.assert_alive
-local expect_exit = helpers.expect_exit
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear = shada_helpers.reset, shada_helpers.clear
+local nvim_command, fn, api, nvim_feed, eq = n.command, n.fn, n.api, n.feed, t.eq
+local assert_alive = n.assert_alive
+local expect_exit = n.expect_exit
+
+local reset, clear = t_shada.reset, t_shada.clear
describe('ShaDa support code', function()
before_each(reset)
@@ -115,6 +116,12 @@ describe('ShaDa support code', function()
nvim_feed('gg0n')
eq({ 0, 2, 3, 0 }, fn.getpos('.'))
eq(1, api.nvim_get_vvar('searchforward'))
+ -- Autocommands shouldn't cause search pattern to change
+ nvim_command('autocmd User * :')
+ nvim_command('doautocmd User')
+ nvim_feed('gg0n')
+ eq({ 0, 2, 3, 0 }, fn.getpos('.'))
+ eq(1, api.nvim_get_vvar('searchforward'))
end)
it('dumps and loads last search pattern with offset and backward direction', function()
@@ -129,6 +136,12 @@ describe('ShaDa support code', function()
nvim_feed('G$n')
eq({ 0, 2, 3, 0 }, fn.getpos('.'))
eq(0, api.nvim_get_vvar('searchforward'))
+ -- Autocommands shouldn't cause search pattern to change
+ nvim_command('autocmd User * :')
+ nvim_command('doautocmd User')
+ nvim_feed('G$n')
+ eq({ 0, 2, 3, 0 }, fn.getpos('.'))
+ eq(0, api.nvim_get_vvar('searchforward'))
end)
it('saves v:hlsearch=1', function()
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index 3f29a02506..d680f0b83b 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -1,12 +1,14 @@
-- ShaDa marks saving/reading support
-local helpers = require('test.functional.helpers')(after_each)
-local api, nvim_command, fn, eq = helpers.api, helpers.command, helpers.fn, helpers.eq
-local feed = helpers.feed
-local exc_exec, exec_capture = helpers.exc_exec, helpers.exec_capture
-local expect_exit = helpers.expect_exit
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear = shada_helpers.reset, shada_helpers.clear
+local api, nvim_command, fn, eq = n.api, n.command, n.fn, t.eq
+local feed = n.feed
+local exc_exec, exec_capture = n.exc_exec, n.exec_capture
+local expect_exit = n.expect_exit
+
+local reset, clear = t_shada.reset, t_shada.clear
local nvim_current_line = function()
return api.nvim_win_get_cursor(0)[1]
@@ -163,17 +165,17 @@ describe('ShaDa support code', function()
eq({ 2, 0 }, api.nvim_win_get_cursor(0))
end)
- it('is able to dump and restore jump list with different times (slow!)', function()
+ it('is able to dump and restore jump list with different times', function()
nvim_command('edit ' .. testfilename_2)
- nvim_command('sleep 2')
+ nvim_command('sleep 10m')
nvim_command('normal! G')
- nvim_command('sleep 2')
+ nvim_command('sleep 10m')
nvim_command('normal! gg')
- nvim_command('sleep 2')
+ nvim_command('sleep 10m')
nvim_command('edit ' .. testfilename)
- nvim_command('sleep 2')
+ nvim_command('sleep 10m')
nvim_command('normal! G')
- nvim_command('sleep 2')
+ nvim_command('sleep 10m')
nvim_command('normal! gg')
expect_exit(nvim_command, 'qall')
reset()
@@ -216,7 +218,7 @@ describe('ShaDa support code', function()
-- -c temporary sets lnum to zero to make `+/pat` work, so calling setpcmark()
-- during -c used to add item with zero lnum to jump list.
it('does not create incorrect file for non-existent buffers when writing from -c', function()
- local argv = helpers.new_argv {
+ local argv = n.new_argv {
args_rm = {
'-i',
'--embed', -- no --embed
@@ -235,7 +237,7 @@ describe('ShaDa support code', function()
end)
it('does not create incorrect file for non-existent buffers opened from -c', function()
- local argv = helpers.new_argv {
+ local argv = n.new_argv {
args_rm = {
'-i',
'--embed', -- no --embed
diff --git a/test/functional/shada/merging_spec.lua b/test/functional/shada/merging_spec.lua
index 1b5c0eab5d..c98678ccbf 100644
--- a/test/functional/shada/merging_spec.lua
+++ b/test/functional/shada/merging_spec.lua
@@ -1,18 +1,19 @@
-- ShaDa merging data support
-local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, fn, eq = helpers.command, helpers.fn, helpers.eq
-local exc_exec, exec_capture = helpers.exc_exec, helpers.exec_capture
-local api = helpers.api
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear, get_shada_rw =
- shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
-local read_shada_file = shada_helpers.read_shada_file
+local nvim_command, fn, eq = n.command, n.fn, t.eq
+local exc_exec, exec_capture = n.exc_exec, n.exec_capture
+local api = n.api
+
+local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw
+local read_shada_file = t_shada.read_shada_file
local wshada, sdrcmd, shada_fname = get_shada_rw('Xtest-functional-shada-merging.shada')
local mock_file_path = '/a/b/'
-if helpers.is_os('win') then
+if t.is_os('win') then
mock_file_path = 'C:/a/'
end
@@ -698,9 +699,9 @@ describe('ShaDa marks support code', function()
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 7 then
local name = ('%c'):format(v.value.n)
- local t = found[name] or {}
- t[v.value.f] = (t[v.value.f] or 0) + 1
- found[name] = t
+ local _t = found[name] or {}
+ _t[v.value.f] = (_t[v.value.f] or 0) + 1
+ found[name] = _t
end
end
eq({ ['0'] = { [mock_file_path .. '-'] = 1 }, A = { [mock_file_path .. '?'] = 1 } }, found)
@@ -1003,7 +1004,7 @@ describe('ShaDa jumps support code', function()
eq(jumps[found].line, v.value.l)
end
end
- eq(found, #jumps)
+ eq(#jumps, found)
end)
it('merges JUMPLISTSIZE jumps when writing', function()
@@ -1018,14 +1019,14 @@ describe('ShaDa jumps support code', function()
eq(0, exc_exec(sdrcmd()))
shada = ''
for i = 1, 101 do
- local t = i * 2
+ local _t = i * 2
shada = shada
.. ('\008\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'):format(
- t,
- t
+ _t,
+ _t
)
- jumps[(t > #jumps + 1) and (#jumps + 1) or t] =
- { file = '' .. mock_file_path .. 'c', line = t }
+ jumps[(_t > #jumps + 1) and (#jumps + 1) or _t] =
+ { file = '' .. mock_file_path .. 'c', line = _t }
end
wshada(shada)
eq(0, exc_exec('wshada ' .. shada_fname))
@@ -1041,7 +1042,7 @@ describe('ShaDa jumps support code', function()
eq(jumps[found].line, v.value.l)
end
end
- eq(found, 100)
+ eq(100, found)
end)
end)
@@ -1132,7 +1133,7 @@ describe('ShaDa changes support code', function()
eq(changes[found].line, v.value.l or 1)
end
end
- eq(found, #changes)
+ eq(#changes, found)
end)
it('merges JUMPLISTSIZE changes when writing', function()
@@ -1149,13 +1150,13 @@ describe('ShaDa changes support code', function()
eq(0, exc_exec(sdrcmd()))
shada = ''
for i = 1, 101 do
- local t = i * 2
+ local _t = i * 2
shada = shada
.. ('\011\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'):format(
- t,
- t
+ _t,
+ _t
)
- changes[(t > #changes + 1) and (#changes + 1) or t] = { line = t }
+ changes[(_t > #changes + 1) and (#changes + 1) or _t] = { line = _t }
end
wshada(shada)
eq(0, exc_exec('wshada ' .. shada_fname))
@@ -1170,7 +1171,7 @@ describe('ShaDa changes support code', function()
eq(changes[found].line, v.value.l)
end
end
- eq(found, 100)
+ eq(100, found)
end)
it('merges JUMPLISTSIZE changes when writing, with new items between old', function()
@@ -1178,11 +1179,11 @@ describe('ShaDa changes support code', function()
nvim_command('keepjumps call setline(1, range(202))')
local shada = ''
for i = 1, 101 do
- local t = i * 2
+ local _t = i * 2
shada = shada
.. ('\011\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'):format(
- t,
- t
+ _t,
+ _t
)
end
wshada(shada)
@@ -1197,8 +1198,8 @@ describe('ShaDa changes support code', function()
changes[i] = { line = i }
end
for i = 1, 101 do
- local t = i * 2
- changes[(t > #changes + 1) and (#changes + 1) or t] = { line = t }
+ local _t = i * 2
+ changes[(_t > #changes + 1) and (#changes + 1) or _t] = { line = _t }
end
wshada(shada)
eq(0, exc_exec('wshada ' .. shada_fname))
@@ -1213,6 +1214,6 @@ describe('ShaDa changes support code', function()
eq(changes[found].line, v.value.l)
end
end
- eq(found, 100)
+ eq(100, found)
end)
end)
diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua
index ef15ab9a05..1e6249807e 100644
--- a/test/functional/shada/registers_spec.lua
+++ b/test/functional/shada/registers_spec.lua
@@ -1,10 +1,11 @@
-- ShaDa registers saving/reading support
-local helpers = require('test.functional.helpers')(after_each)
-local nvim_command, fn, eq = helpers.command, helpers.fn, helpers.eq
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear = shada_helpers.reset, shada_helpers.clear
-local expect_exit = helpers.expect_exit
+local nvim_command, fn, eq = n.command, n.fn, t.eq
+local reset, clear = t_shada.reset, t_shada.clear
+local expect_exit = n.expect_exit
local setreg = function(name, contents, typ)
if type(contents) == 'string' then
diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua
index 6eb318015d..5debdc6c77 100644
--- a/test/functional/shada/shada_spec.lua
+++ b/test/functional/shada/shada_spec.lua
@@ -1,18 +1,18 @@
-- Other ShaDa tests
-local helpers = require('test.functional.helpers')(after_each)
-local api, nvim_command, fn, eq = helpers.api, helpers.command, helpers.fn, helpers.eq
-local write_file, spawn, set_session, nvim_prog, exc_exec =
- helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog, helpers.exc_exec
-local is_os = helpers.is_os
-local skip = helpers.skip
-
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
local uv = vim.uv
-local paths = helpers.paths
+local paths = t.paths
+
+local api, nvim_command, fn, eq = n.api, n.command, n.fn, t.eq
+local write_file, spawn, set_session, nvim_prog, exc_exec =
+ t.write_file, n.spawn, n.set_session, n.nvim_prog, n.exc_exec
+local is_os = t.is_os
+local skip = t.skip
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear, get_shada_rw =
- shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
-local read_shada_file = shada_helpers.read_shada_file
+local reset, clear, get_shada_rw = t_shada.reset, t_shada.clear, t_shada.get_shada_rw
+local read_shada_file = t_shada.read_shada_file
local wshada, _, shada_fname, clean = get_shada_rw('Xtest-functional-shada-shada.shada')
diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/testutil.lua
index baa27889f3..d9252af5f0 100644
--- a/test/functional/shada/helpers.lua
+++ b/test/functional/shada/testutil.lua
@@ -1,9 +1,11 @@
-local helpers = require('test.functional.helpers')(nil)
-local api = helpers.api
-local write_file = helpers.write_file
-local concat_tables = helpers.concat_tables
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
-local tmpname = helpers.tmpname()
+local api = n.api
+local write_file = t.write_file
+local concat_tables = t.concat_tables
+
+local tmpname = t.tmpname()
-- o={
-- args=…,
@@ -24,7 +26,7 @@ local function reset(o)
elseif o.args then
args = concat_tables(args, o.args)
end
- helpers.clear {
+ n.clear {
args_rm = args_rm,
args = args,
}
@@ -32,7 +34,7 @@ local function reset(o)
end
local clear = function()
- helpers.expect_exit(helpers.command, 'qall!')
+ n.expect_exit(n.command, 'qall!')
os.remove(tmpname)
end
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua
index d70f5deded..2fea7278ef 100644
--- a/test/functional/shada/variables_spec.lua
+++ b/test/functional/shada/variables_spec.lua
@@ -1,11 +1,11 @@
-- ShaDa variables saving/reading support
-local helpers = require('test.functional.helpers')(after_each)
-local api, fn, nvim_command, eq, eval =
- helpers.api, helpers.fn, helpers.command, helpers.eq, helpers.eval
-local expect_exit = helpers.expect_exit
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local t_shada = require('test.functional.shada.testutil')
-local shada_helpers = require('test.functional.shada.helpers')
-local reset, clear = shada_helpers.reset, shada_helpers.clear
+local api, fn, nvim_command, eq, eval = n.api, n.fn, n.command, t.eq, n.eval
+local expect_exit = n.expect_exit
+local reset, clear = t_shada.reset, t_shada.clear
describe('ShaDa support code', function()
before_each(reset)