diff options
author | dundargoc <gocdundar@gmail.com> | 2024-04-20 17:44:13 +0200 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-04-23 18:17:04 +0200 |
commit | 052498ed42780a76daea589d063cd8947a894673 (patch) | |
tree | b6c85416a4d7ced5eabb0a7a3866f5e0fee886cc /test/functional/shada | |
parent | c5af5c0b9ab84c86f84e32210512923e7eb641ba (diff) | |
download | rneovim-052498ed42780a76daea589d063cd8947a894673.tar.gz rneovim-052498ed42780a76daea589d063cd8947a894673.tar.bz2 rneovim-052498ed42780a76daea589d063cd8947a894673.zip |
test: improve test conventions
Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.
Closes https://github.com/neovim/neovim/issues/27004.
Diffstat (limited to 'test/functional/shada')
-rw-r--r-- | test/functional/shada/buffers_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/shada/compatibility_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/shada/errors_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/shada/history_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/shada/marks_spec.lua | 18 | ||||
-rw-r--r-- | test/functional/shada/merging_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/shada/registers_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/shada/shada_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/shada/testutil.lua | 10 | ||||
-rw-r--r-- | test/functional/shada/variables_spec.lua | 9 |
10 files changed, 63 insertions, 48 deletions
diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua index ed918e37f4..07b0bf4217 100644 --- a/test/functional/shada/buffers_spec.lua +++ b/test/functional/shada/buffers_spec.lua @@ -1,9 +1,11 @@ -- shada buffer list saving/reading support -local t = require('test.functional.testutil')() -local nvim_command, fn, eq, api = t.command, t.fn, t.eq, t.api -local expect_exit = t.expect_exit - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +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() diff --git a/test/functional/shada/compatibility_spec.lua b/test/functional/shada/compatibility_spec.lua index b7f6bfb0b4..98d3884098 100644 --- a/test/functional/shada/compatibility_spec.lua +++ b/test/functional/shada/compatibility_spec.lua @@ -1,9 +1,10 @@ -- ShaDa compatibility support -local t = require('test.functional.testutil')() -local nvim_command, fn, eq = t.command, t.fn, t.eq -local exc_exec = t.exc_exec - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +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 diff --git a/test/functional/shada/errors_spec.lua b/test/functional/shada/errors_spec.lua index 736a6956af..a9084da929 100644 --- a/test/functional/shada/errors_spec.lua +++ b/test/functional/shada/errors_spec.lua @@ -1,8 +1,9 @@ -- ShaDa errors handling support -local t = require('test.functional.testutil')() -local nvim_command, eq, exc_exec = t.command, t.eq, t.exc_exec - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +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 521b7fb56f..1ad230f244 100644 --- a/test/functional/shada/history_spec.lua +++ b/test/functional/shada/history_spec.lua @@ -1,10 +1,12 @@ -- ShaDa history saving/reading support -local t = require('test.functional.testutil')() -local nvim_command, fn, api, nvim_feed, eq = t.command, t.fn, t.api, t.feed, t.eq -local assert_alive = t.assert_alive -local expect_exit = t.expect_exit - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +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() diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index e6eefd4aed..d680f0b83b 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -1,11 +1,13 @@ -- ShaDa marks saving/reading support -local t = require('test.functional.testutil')() -local api, nvim_command, fn, eq = t.api, t.command, t.fn, t.eq -local feed = t.feed -local exc_exec, exec_capture = t.exc_exec, t.exec_capture -local expect_exit = t.expect_exit - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +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() @@ -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 = t.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 = t.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 57af4d5537..c98678ccbf 100644 --- a/test/functional/shada/merging_spec.lua +++ b/test/functional/shada/merging_spec.lua @@ -1,10 +1,12 @@ -- ShaDa merging data support -local t = require('test.functional.testutil')() -local nvim_command, fn, eq = t.command, t.fn, t.eq -local exc_exec, exec_capture = t.exc_exec, t.exec_capture -local api = t.api - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +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 diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua index e6636e9ece..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 t = require('test.functional.testutil')() -local nvim_command, fn, eq = t.command, t.fn, t.eq - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +local nvim_command, fn, eq = n.command, n.fn, t.eq local reset, clear = t_shada.reset, t_shada.clear -local expect_exit = t.expect_exit +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 8e677e2729..5debdc6c77 100644 --- a/test/functional/shada/shada_spec.lua +++ b/test/functional/shada/shada_spec.lua @@ -1,15 +1,16 @@ -- Other ShaDa tests -local t = require('test.functional.testutil')() -local api, nvim_command, fn, eq = t.api, t.command, t.fn, t.eq +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 = 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, t.spawn, t.set_session, t.nvim_prog, t.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 uv = vim.uv -local paths = t.paths - -local t_shada = require('test.functional.shada.testutil') 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 diff --git a/test/functional/shada/testutil.lua b/test/functional/shada/testutil.lua index 286a7a8e21..d9252af5f0 100644 --- a/test/functional/shada/testutil.lua +++ b/test/functional/shada/testutil.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local api = n.api local write_file = t.write_file local concat_tables = t.concat_tables @@ -24,7 +26,7 @@ local function reset(o) elseif o.args then args = concat_tables(args, o.args) end - t.clear { + n.clear { args_rm = args_rm, args = args, } @@ -32,7 +34,7 @@ local function reset(o) end local clear = function() - t.expect_exit(t.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 19916ea466..2fea7278ef 100644 --- a/test/functional/shada/variables_spec.lua +++ b/test/functional/shada/variables_spec.lua @@ -1,9 +1,10 @@ -- ShaDa variables saving/reading support -local t = require('test.functional.testutil')() -local api, fn, nvim_command, eq, eval = t.api, t.fn, t.command, t.eq, t.eval -local expect_exit = t.expect_exit - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local t_shada = require('test.functional.shada.testutil') + +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() |