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/options | |
| 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/options')
| -rw-r--r-- | test/functional/options/autochdir_spec.lua | 14 | ||||
| -rw-r--r-- | test/functional/options/chars_spec.lua | 14 | ||||
| -rw-r--r-- | test/functional/options/cursorbind_spec.lua | 11 | ||||
| -rw-r--r-- | test/functional/options/defaults_spec.lua | 32 | ||||
| -rw-r--r-- | test/functional/options/keymap_spec.lua | 12 | ||||
| -rw-r--r-- | test/functional/options/modified_spec.lua | 8 | ||||
| -rw-r--r-- | test/functional/options/mousescroll_spec.lua | 20 | ||||
| -rw-r--r-- | test/functional/options/num_options_spec.lua | 6 | ||||
| -rw-r--r-- | test/functional/options/shortmess_spec.lua | 12 | ||||
| -rw-r--r-- | test/functional/options/tabstop_spec.lua | 8 | ||||
| -rw-r--r-- | test/functional/options/winfixbuf_spec.lua | 7 |
11 files changed, 80 insertions, 64 deletions
diff --git a/test/functional/options/autochdir_spec.lua b/test/functional/options/autochdir_spec.lua index 681f0f5cdd..c490ab67a9 100644 --- a/test/functional/options/autochdir_spec.lua +++ b/test/functional/options/autochdir_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local fn = t.fn -local command = t.command +local fn = n.fn +local command = n.command local mkdir = t.mkdir describe("'autochdir'", function() @@ -38,7 +40,7 @@ describe("'autochdir'", function() eq(dir_a, fn.getcwd()) fn.getwinvar(2, 'foo') eq(dir_a, fn.getcwd()) - t.rmdir(dir_a) - t.rmdir(dir_b) + n.rmdir(dir_a) + n.rmdir(dir_b) end) end) diff --git a/test/functional/options/chars_spec.lua b/test/functional/options/chars_spec.lua index 4f75c5800a..8e63e07e09 100644 --- a/test/functional/options/chars_spec.lua +++ b/test/functional/options/chars_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, command = t.clear, t.command + +local clear, command = n.clear, n.command local pcall_err = t.pcall_err -local eval = t.eval +local eval = n.eval local eq = t.eq -local insert = t.insert -local feed = t.feed -local api = t.api +local insert = n.insert +local feed = n.feed +local api = n.api describe("'fillchars'", function() local screen diff --git a/test/functional/options/cursorbind_spec.lua b/test/functional/options/cursorbind_spec.lua index 3977d08317..19551b928f 100644 --- a/test/functional/options/cursorbind_spec.lua +++ b/test/functional/options/cursorbind_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command -local exec = t.exec -local feed = t.feed + +local clear = n.clear +local command = n.command +local exec = n.exec +local feed = n.feed before_each(clear) diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index d07ff3da0f..f61139d92d 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -1,26 +1,26 @@ -local t = require('test.functional.testutil')() - +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive +local assert_alive = n.assert_alive local assert_log = t.assert_log -local api = t.api -local command = t.command -local clear = t.clear -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local eval = t.eval +local api = n.api +local command = n.command +local clear = n.clear +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local eval = n.eval local eq = t.eq local ok = t.ok -local fn = t.fn -local insert = t.insert +local fn = n.fn +local insert = n.insert local neq = t.neq local mkdir = t.mkdir -local rmdir = t.rmdir -local alter_slashes = t.alter_slashes +local rmdir = n.rmdir +local alter_slashes = n.alter_slashes local tbl_contains = vim.tbl_contains -local expect_exit = t.expect_exit -local check_close = t.check_close +local expect_exit = n.expect_exit +local check_close = n.check_close local is_os = t.is_os local testlog = 'Xtest-defaults-log' @@ -1248,7 +1248,7 @@ end) describe('autocommands', function() it('closes terminal with default shell on success', function() clear() - api.nvim_set_option_value('shell', t.testprg('shell-test'), {}) + api.nvim_set_option_value('shell', n.testprg('shell-test'), {}) command('set shellcmdflag=EXIT shellredir= shellpipe= shellquote= shellxquote=') -- Should not block other events diff --git a/test/functional/options/keymap_spec.lua b/test/functional/options/keymap_spec.lua index 79b2e3dd0e..f76525699f 100644 --- a/test/functional/options/keymap_spec.lua +++ b/test/functional/options/keymap_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() -local clear, feed, eq = t.clear, t.feed, t.eq -local expect, command, eval = t.expect, t.command, t.eval -local insert, call = t.insert, t.call -local exec_capture, dedent = t.exec_capture, t.dedent +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed, eq = n.clear, n.feed, t.eq +local expect, command, eval = n.expect, n.command, n.eval +local insert, call = n.insert, n.call +local exec_capture, dedent = n.exec_capture, t.dedent -- First test it's implemented using the :lmap and :lnoremap commands, then -- check those mappings behave as expected. diff --git a/test/functional/options/modified_spec.lua b/test/functional/options/modified_spec.lua index afd56eef98..956deb70ff 100644 --- a/test/functional/options/modified_spec.lua +++ b/test/functional/options/modified_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local api = t.api +local api = n.api describe("'modified'", function() before_each(function() diff --git a/test/functional/options/mousescroll_spec.lua b/test/functional/options/mousescroll_spec.lua index 281d6cbe04..2ccf934fd4 100644 --- a/test/functional/options/mousescroll_spec.lua +++ b/test/functional/options/mousescroll_spec.lua @@ -1,21 +1,23 @@ -local t = require('test.functional.testutil')() -local command = t.command -local clear = t.clear -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local command = n.command +local clear = n.clear +local eval = n.eval local eq = t.eq -local exc_exec = t.exc_exec -local feed = t.feed +local exc_exec = n.exc_exec +local feed = n.feed local scroll = function(direction) - return t.request('nvim_input_mouse', 'wheel', direction, '', 0, 2, 2) + return n.request('nvim_input_mouse', 'wheel', direction, '', 0, 2, 2) end local screenrow = function() - return t.call('screenrow') + return n.call('screenrow') end local screencol = function() - return t.call('screencol') + return n.call('screencol') end describe("'mousescroll'", function() diff --git a/test/functional/options/num_options_spec.lua b/test/functional/options/num_options_spec.lua index 7c6d0ea21e..3ac6f3f121 100644 --- a/test/functional/options/num_options_spec.lua +++ b/test/functional/options/num_options_spec.lua @@ -1,7 +1,9 @@ -- Tests for :setlocal and :setglobal -local t = require('test.functional.testutil')() -local clear, feed_command, eval, eq, api = t.clear, t.feed_command, t.eval, t.eq, t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed_command, eval, eq, api = n.clear, n.feed_command, n.eval, t.eq, n.api local function should_fail(opt, value, errmsg) feed_command('setglobal ' .. opt .. '=' .. value) diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua index 4fb69b79d8..dcbf9d15e0 100644 --- a/test/functional/options/shortmess_spec.lua +++ b/test/functional/options/shortmess_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local command = t.command + +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed +local eval = n.eval +local feed = n.feed describe("'shortmess'", function() local screen diff --git a/test/functional/options/tabstop_spec.lua b/test/functional/options/tabstop_spec.lua index 7e9bd5e06c..4ddbb13a0e 100644 --- a/test/functional/options/tabstop_spec.lua +++ b/test/functional/options/tabstop_spec.lua @@ -1,8 +1,8 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local assert_alive = t.assert_alive -local clear = t.clear -local feed = t.feed +local assert_alive = n.assert_alive +local clear = n.clear +local feed = n.feed describe("'tabstop' option", function() before_each(function() diff --git a/test/functional/options/winfixbuf_spec.lua b/test/functional/options/winfixbuf_spec.lua index 8a0df75782..124f194b5a 100644 --- a/test/functional/options/winfixbuf_spec.lua +++ b/test/functional/options/winfixbuf_spec.lua @@ -1,6 +1,7 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local exec_lua = t.exec_lua +local n = require('test.functional.testnvim')() + +local clear = n.clear +local exec_lua = n.exec_lua describe("Nvim API calls with 'winfixbuf'", function() before_each(function() |