aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-01-04 16:48:00 -0800
committerGitHub <noreply@github.com>2025-01-04 16:48:00 -0800
commit64b0e6582ae8c273efbe39109bcb261079c2bcd4 (patch)
tree2e9de1f2224814dc10af8c5ef338e3aaa974f181 /test/functional/shada
parenta8ace2c58a318552869462a36859aabf1cdfaa68 (diff)
downloadrneovim-64b0e6582ae8c273efbe39109bcb261079c2bcd4.tar.gz
rneovim-64b0e6582ae8c273efbe39109bcb261079c2bcd4.tar.bz2
rneovim-64b0e6582ae8c273efbe39109bcb261079c2bcd4.zip
refactor(tests): merge n.spawn/n.spawn_argv into n.new_session #31859
Problem: - `n.spawn()` is misleading because it also connects RPC, it's not just "spawning" a process. - It's confusing that `n.spawn()` and `n.spawn_argv()` are separate. Solution: - Replace `n.spawn()`/`n.spawn_argv()` with a single function `n.new_session()`. This name aligns with the existing functions `n.set_session`/`n.get_session`. - Note: removes direct handling of `prepend_argv`, but I doubt that was important or intentional. If callers want to control use of `prepend_argv` then we should add a new flag to `test.session.Opts`. - Move `keep` to first parameter of `n.new_session()`. - Add a `merge` flag to `test.session.Opts` - Mark `_new_argv()` as private. Test should use clear/new_session/spawn_wait instead.
Diffstat (limited to 'test/functional/shada')
-rw-r--r--test/functional/shada/marks_spec.lua10
-rw-r--r--test/functional/shada/shada_spec.lua18
2 files changed, 16 insertions, 12 deletions
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index d680f0b83b..837978dee1 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -218,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 = n.new_argv {
+ local p = n.spawn_wait {
args_rm = {
'-i',
'--embed', -- no --embed
@@ -232,12 +232,13 @@ describe('ShaDa support code', function()
'qall',
},
}
- eq('', fn.system(argv))
+ eq('', p:output())
+ eq(0, p.status)
eq(0, exc_exec('rshada'))
end)
it('does not create incorrect file for non-existent buffers opened from -c', function()
- local argv = n.new_argv {
+ local p = n.spawn_wait {
args_rm = {
'-i',
'--embed', -- no --embed
@@ -251,7 +252,8 @@ describe('ShaDa support code', function()
'autocmd VimEnter * qall',
},
}
- eq('', fn.system(argv))
+ eq('', p:output())
+ eq(0, p.status)
eq(0, exc_exec('rshada'))
end)
diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua
index 5debdc6c77..78fe19b984 100644
--- a/test/functional/shada/shada_spec.lua
+++ b/test/functional/shada/shada_spec.lua
@@ -6,8 +6,7 @@ local uv = vim.uv
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 write_file, set_session, exc_exec = t.write_file, n.set_session, n.exc_exec
local is_os = t.is_os
local skip = t.skip
@@ -254,7 +253,7 @@ describe('ShaDa support code', function()
it('does not crash when ShaDa file directory is not writable', function()
skip(is_os('win'))
- fn.mkdir(dirname, '', 0)
+ fn.mkdir(dirname, '', '0')
eq(0, fn.filewritable(dirname))
reset { shadafile = dirshada, args = { '--cmd', 'set shada=' } }
api.nvim_set_option_value('shada', "'10", {})
@@ -270,10 +269,10 @@ 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
- )
+ local session = n.new_session(false, {
+ merge = false,
+ args = { '-u', 'NONE', '-i', 'NONE', '--embed', '--headless', '--cmd', 'qall' },
+ })
session:close()
eq(nil, uv.fs_stat('NONE'))
eq(nil, uv.fs_stat('NONE.tmp.a'))
@@ -281,7 +280,10 @@ describe('ShaDa support code', function()
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)
+ local session = n.new_session(
+ false,
+ { merge = false, args = { '-u', 'NONE', '-i', 'NONE', '--embed', '--headless' } }
+ )
set_session(session)
eq('', fn.getreg('a'))
session:close()