aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-04-08 11:03:20 +0200
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-04-08 22:51:00 +0200
commit7035125b2b26aa68fcfb7cda39377ac79926a0f9 (patch)
treed194a3556a367b42505f9e7d26637e7cb3674928 /test/functional/core
parent978962f9a00ce75216d2c36b79397ef3d2b54096 (diff)
downloadrneovim-7035125b2b26aa68fcfb7cda39377ac79926a0f9.tar.gz
rneovim-7035125b2b26aa68fcfb7cda39377ac79926a0f9.tar.bz2
rneovim-7035125b2b26aa68fcfb7cda39377ac79926a0f9.zip
test: improve test conventions
Work on https://github.com/neovim/neovim/issues/27004.
Diffstat (limited to 'test/functional/core')
-rw-r--r--test/functional/core/channels_spec.lua27
-rw-r--r--test/functional/core/exit_spec.lua34
-rw-r--r--test/functional/core/fileio_spec.lua64
-rw-r--r--test/functional/core/job_spec.lua80
-rw-r--r--test/functional/core/log_spec.lua16
-rw-r--r--test/functional/core/main_spec.lua22
-rw-r--r--test/functional/core/path_spec.lua24
-rw-r--r--test/functional/core/remote_spec.lua34
-rw-r--r--test/functional/core/spellfile_spec.lua18
-rw-r--r--test/functional/core/startup_spec.lua64
10 files changed, 191 insertions, 192 deletions
diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua
index 0ab885e02f..24a295093a 100644
--- a/test/functional/core/channels_spec.lua
+++ b/test/functional/core/channels_spec.lua
@@ -1,18 +1,17 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear, eq, eval, next_msg, ok, source =
- helpers.clear, helpers.eq, helpers.eval, helpers.next_msg, helpers.ok, helpers.source
-local command, fn, api = helpers.command, helpers.fn, helpers.api
-local matches = helpers.matches
+local t = require('test.functional.testutil')(after_each)
+local clear, eq, eval, next_msg, ok, source = t.clear, t.eq, t.eval, t.next_msg, t.ok, t.source
+local command, fn, api = t.command, t.fn, t.api
+local matches = t.matches
local sleep = vim.uv.sleep
-local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
-local get_session, set_session = helpers.get_session, helpers.set_session
-local nvim_prog = helpers.nvim_prog
-local is_os = helpers.is_os
-local retry = helpers.retry
-local expect_twostreams = helpers.expect_twostreams
-local assert_alive = helpers.assert_alive
-local pcall_err = helpers.pcall_err
-local skip = helpers.skip
+local spawn, nvim_argv = t.spawn, t.nvim_argv
+local get_session, set_session = t.get_session, t.set_session
+local nvim_prog = t.nvim_prog
+local is_os = t.is_os
+local retry = t.retry
+local expect_twostreams = t.expect_twostreams
+local assert_alive = t.assert_alive
+local pcall_err = t.pcall_err
+local skip = t.skip
describe('channels', function()
local init = [[
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua
index d9e3cc3f31..058d67dba1 100644
--- a/test/functional/core/exit_spec.lua
+++ b/test/functional/core/exit_spec.lua
@@ -1,24 +1,24 @@
-local helpers = require('test.functional.helpers')(after_each)
-
-local assert_alive = helpers.assert_alive
-local command = helpers.command
-local feed_command = helpers.feed_command
-local feed = helpers.feed
-local eval = helpers.eval
-local eq = helpers.eq
-local run = helpers.run
-local fn = helpers.fn
-local nvim_prog = helpers.nvim_prog
-local pcall_err = helpers.pcall_err
-local exec_capture = helpers.exec_capture
-local poke_eventloop = helpers.poke_eventloop
+local t = require('test.functional.testutil')(after_each)
+
+local assert_alive = t.assert_alive
+local command = t.command
+local feed_command = t.feed_command
+local feed = t.feed
+local eval = t.eval
+local eq = t.eq
+local run = t.run
+local fn = t.fn
+local nvim_prog = t.nvim_prog
+local pcall_err = t.pcall_err
+local exec_capture = t.exec_capture
+local poke_eventloop = t.poke_eventloop
describe('v:exiting', function()
local cid
before_each(function()
- helpers.clear()
- cid = helpers.api.nvim_get_chan_info(0).id
+ t.clear()
+ cid = t.api.nvim_get_chan_info(0).id
end)
it('defaults to v:null', function()
@@ -74,7 +74,7 @@ describe(':cquit', function()
end
before_each(function()
- helpers.clear()
+ t.clear()
end)
it('exits with non-zero after :cquit', function()
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua
index 928cab525c..4b1018b0f0 100644
--- a/test/functional/core/fileio_spec.lua
+++ b/test/functional/core/fileio_spec.lua
@@ -1,37 +1,37 @@
local uv = vim.uv
-local helpers = require('test.functional.helpers')(after_each)
-
-local assert_log = helpers.assert_log
-local assert_nolog = helpers.assert_nolog
-local clear = helpers.clear
-local command = helpers.command
-local eq = helpers.eq
-local neq = helpers.neq
-local ok = helpers.ok
-local feed = helpers.feed
-local fn = helpers.fn
-local nvim_prog = helpers.nvim_prog
-local request = helpers.request
-local retry = helpers.retry
-local rmdir = helpers.rmdir
-local matches = helpers.matches
-local api = helpers.api
-local mkdir = helpers.mkdir
+local t = require('test.functional.testutil')(after_each)
+
+local assert_log = t.assert_log
+local assert_nolog = t.assert_nolog
+local clear = t.clear
+local command = t.command
+local eq = t.eq
+local neq = t.neq
+local ok = t.ok
+local feed = t.feed
+local fn = t.fn
+local nvim_prog = t.nvim_prog
+local request = t.request
+local retry = t.retry
+local rmdir = t.rmdir
+local matches = t.matches
+local api = t.api
+local mkdir = t.mkdir
local sleep = vim.uv.sleep
-local read_file = helpers.read_file
+local read_file = t.read_file
local trim = vim.trim
-local currentdir = helpers.fn.getcwd
-local assert_alive = helpers.assert_alive
-local check_close = helpers.check_close
-local expect_exit = helpers.expect_exit
-local write_file = helpers.write_file
+local currentdir = t.fn.getcwd
+local assert_alive = t.assert_alive
+local check_close = t.check_close
+local expect_exit = t.expect_exit
+local write_file = t.write_file
local Screen = require('test.functional.ui.screen')
-local feed_command = helpers.feed_command
-local skip = helpers.skip
-local is_os = helpers.is_os
-local is_ci = helpers.is_ci
-local spawn = helpers.spawn
-local set_session = helpers.set_session
+local feed_command = t.feed_command
+local skip = t.skip
+local is_os = t.is_os
+local is_ci = t.is_ci
+local spawn = t.spawn
+local set_session = t.set_session
describe('fileio', function()
before_each(function() end)
@@ -228,7 +228,7 @@ describe('fileio', function()
local initial_content = 'foo'
local backup_dir = 'Xtest_backupdir'
- local sep = helpers.get_pathsep()
+ local sep = t.get_pathsep()
local link_file_name = 'Xtest_startup_file2'
local backup_file_name = backup_dir .. sep .. link_file_name .. '~'
@@ -329,7 +329,7 @@ describe('tmpdir', function()
before_each(function()
-- Fake /tmp dir so that we can mess it up.
- os_tmpdir = vim.uv.fs_mkdtemp(vim.fs.dirname(helpers.tmpname()) .. '/nvim_XXXXXXXXXX')
+ os_tmpdir = vim.uv.fs_mkdtemp(vim.fs.dirname(t.tmpname()) .. '/nvim_XXXXXXXXXX')
end)
after_each(function()
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index f0e61fbcc1..17264d80a5 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -1,40 +1,40 @@
-local helpers = require('test.functional.helpers')(after_each)
-local thelpers = require('test.functional.terminal.helpers')
-
-local clear = helpers.clear
-local eq = helpers.eq
-local eval = helpers.eval
-local exc_exec = helpers.exc_exec
-local feed_command = helpers.feed_command
-local feed = helpers.feed
-local insert = helpers.insert
-local neq = helpers.neq
-local next_msg = helpers.next_msg
-local testprg = helpers.testprg
-local ok = helpers.ok
-local source = helpers.source
-local write_file = helpers.write_file
-local mkdir = helpers.mkdir
-local rmdir = helpers.rmdir
-local assert_alive = helpers.assert_alive
-local command = helpers.command
-local fn = helpers.fn
-local os_kill = helpers.os_kill
-local retry = helpers.retry
-local api = helpers.api
+local t = require('test.functional.testutil')(after_each)
+local tt = require('test.functional.terminal.testutil')
+
+local clear = t.clear
+local eq = t.eq
+local eval = t.eval
+local exc_exec = t.exc_exec
+local feed_command = t.feed_command
+local feed = t.feed
+local insert = t.insert
+local neq = t.neq
+local next_msg = t.next_msg
+local testprg = t.testprg
+local ok = t.ok
+local source = t.source
+local write_file = t.write_file
+local mkdir = t.mkdir
+local rmdir = t.rmdir
+local assert_alive = t.assert_alive
+local command = t.command
+local fn = t.fn
+local os_kill = t.os_kill
+local retry = t.retry
+local api = t.api
local NIL = vim.NIL
-local poke_eventloop = helpers.poke_eventloop
-local get_pathsep = helpers.get_pathsep
-local pathroot = helpers.pathroot
-local exec_lua = helpers.exec_lua
-local nvim_set = helpers.nvim_set
-local expect_twostreams = helpers.expect_twostreams
-local expect_msg_seq = helpers.expect_msg_seq
-local pcall_err = helpers.pcall_err
-local matches = helpers.matches
+local poke_eventloop = t.poke_eventloop
+local get_pathsep = t.get_pathsep
+local pathroot = t.pathroot
+local exec_lua = t.exec_lua
+local nvim_set = t.nvim_set
+local expect_twostreams = t.expect_twostreams
+local expect_msg_seq = t.expect_msg_seq
+local pcall_err = t.pcall_err
+local matches = t.matches
local Screen = require('test.functional.ui.screen')
-local skip = helpers.skip
-local is_os = helpers.is_os
+local skip = t.skip
+local is_os = t.is_os
describe('jobs', function()
local channel
@@ -307,7 +307,7 @@ describe('jobs', function()
it('preserves NULs', function()
-- Make a file with NULs in it.
- local filename = helpers.tmpname()
+ local filename = t.tmpname()
write_file(filename, 'abc\0def\n')
command("let j = jobstart(['cat', '" .. filename .. "'], g:job_opts)")
@@ -732,7 +732,7 @@ describe('jobs', function()
describe('jobwait()', function()
before_each(function()
if is_os('win') then
- helpers.set_shell_powershell()
+ t.set_shell_powershell()
end
end)
@@ -1182,7 +1182,7 @@ describe('jobs', function()
end)
it('does not close the same handle twice on exit #25086', function()
- local filename = string.format('%s.lua', helpers.tmpname())
+ local filename = string.format('%s.lua', t.tmpname())
write_file(
filename,
[[
@@ -1195,7 +1195,7 @@ describe('jobs', function()
]]
)
- local screen = thelpers.setup_child_nvim({
+ local screen = tt.setup_child_nvim({
'--cmd',
'set notermguicolors',
'-i',
@@ -1239,7 +1239,7 @@ describe('pty process teardown', function()
skip(fn.executable('sleep') == 0, 'missing "sleep" command')
-- Use a nested nvim (in :term) to test without --headless.
fn.termopen({
- helpers.nvim_prog,
+ t.nvim_prog,
'-u',
'NONE',
'-i',
diff --git a/test/functional/core/log_spec.lua b/test/functional/core/log_spec.lua
index 1637e683c1..dfacc0af6e 100644
--- a/test/functional/core/log_spec.lua
+++ b/test/functional/core/log_spec.lua
@@ -1,11 +1,11 @@
-local helpers = require('test.functional.helpers')(after_each)
-local assert_log = helpers.assert_log
-local clear = helpers.clear
-local command = helpers.command
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
-local expect_exit = helpers.expect_exit
-local request = helpers.request
+local t = require('test.functional.testutil')(after_each)
+local assert_log = t.assert_log
+local clear = t.clear
+local command = t.command
+local eq = t.eq
+local exec_lua = t.exec_lua
+local expect_exit = t.expect_exit
+local request = t.request
describe('log', function()
local testlog = 'Xtest_logging'
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua
index 396ec2c79e..ee3e32d794 100644
--- a/test/functional/core/main_spec.lua
+++ b/test/functional/core/main_spec.lua
@@ -1,17 +1,17 @@
local uv = vim.uv
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local eq = helpers.eq
-local matches = helpers.matches
-local feed = helpers.feed
-local eval = helpers.eval
-local clear = helpers.clear
-local fn = helpers.fn
-local nvim_prog_abs = helpers.nvim_prog_abs
-local write_file = helpers.write_file
-local is_os = helpers.is_os
-local skip = helpers.skip
+local eq = t.eq
+local matches = t.matches
+local feed = t.feed
+local eval = t.eval
+local clear = t.clear
+local fn = t.fn
+local nvim_prog_abs = t.nvim_prog_abs
+local write_file = t.write_file
+local is_os = t.is_os
+local skip = t.skip
describe('command-line option', function()
describe('-s', function()
diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua
index e98bfc0d45..65eaa201d9 100644
--- a/test/functional/core/path_spec.lua
+++ b/test/functional/core/path_spec.lua
@@ -1,15 +1,15 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local command = helpers.command
-local eq = helpers.eq
-local eval = helpers.eval
-local feed = helpers.feed
-local fn = helpers.fn
-local insert = helpers.insert
-local is_os = helpers.is_os
-local mkdir = helpers.mkdir
-local rmdir = helpers.rmdir
-local write_file = helpers.write_file
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local command = t.command
+local eq = t.eq
+local eval = t.eval
+local feed = t.feed
+local fn = t.fn
+local insert = t.insert
+local is_os = t.is_os
+local mkdir = t.mkdir
+local rmdir = t.rmdir
+local write_file = t.write_file
local function join_path(...)
local pathsep = (is_os('win') and '\\' or '/')
diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua
index caff06f6ab..5c8a86091d 100644
--- a/test/functional/core/remote_spec.lua
+++ b/test/functional/core/remote_spec.lua
@@ -1,20 +1,20 @@
-local helpers = require('test.functional.helpers')(after_each)
-
-local clear = helpers.clear
-local command = helpers.command
-local eq = helpers.eq
-local exec_capture = helpers.exec_capture
-local exec_lua = helpers.exec_lua
-local expect = helpers.expect
-local fn = helpers.fn
-local insert = helpers.insert
-local nvim_prog = helpers.nvim_prog
-local new_argv = helpers.new_argv
-local neq = helpers.neq
-local set_session = helpers.set_session
-local spawn = helpers.spawn
-local tmpname = helpers.tmpname
-local write_file = helpers.write_file
+local t = require('test.functional.testutil')(after_each)
+
+local clear = t.clear
+local command = t.command
+local eq = t.eq
+local exec_capture = t.exec_capture
+local exec_lua = t.exec_lua
+local expect = t.expect
+local fn = t.fn
+local insert = t.insert
+local nvim_prog = t.nvim_prog
+local new_argv = t.new_argv
+local neq = t.neq
+local set_session = t.set_session
+local spawn = t.spawn
+local tmpname = t.tmpname
+local write_file = t.write_file
describe('Remote', function()
local fname, other_fname
diff --git a/test/functional/core/spellfile_spec.lua b/test/functional/core/spellfile_spec.lua
index 57953b8f80..ac3f1b27a6 100644
--- a/test/functional/core/spellfile_spec.lua
+++ b/test/functional/core/spellfile_spec.lua
@@ -1,13 +1,13 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
-local eq = helpers.eq
-local clear = helpers.clear
-local api = helpers.api
-local exc_exec = helpers.exc_exec
-local fn = helpers.fn
-local rmdir = helpers.rmdir
-local write_file = helpers.write_file
-local mkdir = helpers.mkdir
+local eq = t.eq
+local clear = t.clear
+local api = t.api
+local exc_exec = t.exc_exec
+local fn = t.fn
+local rmdir = t.rmdir
+local write_file = t.write_file
+local mkdir = t.mkdir
local testdir = 'Xtest-functional-spell-spellfile.d'
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index bd3db02874..31e4805d76 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -1,38 +1,38 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local assert_alive = helpers.assert_alive
-local assert_log = helpers.assert_log
-local clear = helpers.clear
-local command = helpers.command
-local ok = helpers.ok
-local eq = helpers.eq
-local matches = helpers.matches
-local eval = helpers.eval
-local exec = helpers.exec
-local exec_capture = helpers.exec_capture
-local exec_lua = helpers.exec_lua
-local feed = helpers.feed
-local fn = helpers.fn
+local assert_alive = t.assert_alive
+local assert_log = t.assert_log
+local clear = t.clear
+local command = t.command
+local ok = t.ok
+local eq = t.eq
+local matches = t.matches
+local eval = t.eval
+local exec = t.exec
+local exec_capture = t.exec_capture
+local exec_lua = t.exec_lua
+local feed = t.feed
+local fn = t.fn
local pesc = vim.pesc
-local mkdir = helpers.mkdir
-local mkdir_p = helpers.mkdir_p
-local nvim_prog = helpers.nvim_prog
-local nvim_set = helpers.nvim_set
-local read_file = helpers.read_file
-local retry = helpers.retry
-local rmdir = helpers.rmdir
+local mkdir = t.mkdir
+local mkdir_p = t.mkdir_p
+local nvim_prog = t.nvim_prog
+local nvim_set = t.nvim_set
+local read_file = t.read_file
+local retry = t.retry
+local rmdir = t.rmdir
local sleep = vim.uv.sleep
local startswith = vim.startswith
-local write_file = helpers.write_file
-local api = helpers.api
-local alter_slashes = helpers.alter_slashes
-local is_os = helpers.is_os
-local dedent = helpers.dedent
+local write_file = t.write_file
+local api = t.api
+local alter_slashes = t.alter_slashes
+local is_os = t.is_os
+local dedent = t.dedent
local tbl_map = vim.tbl_map
local tbl_filter = vim.tbl_filter
local endswith = vim.endswith
-local check_close = helpers.check_close
+local check_close = t.check_close
local testlog = 'Xtest-startupspec-log'
@@ -467,7 +467,7 @@ describe('startup', function()
|
]])
if not is_os('win') then
- assert_log('Failed to get flags on descriptor 3: Bad file descriptor', testlog)
+ assert_log('Failed to get flags on descriptor 3: Bad file descriptor', testlog, 100)
end
end)
@@ -994,7 +994,7 @@ describe('sysinit', function()
local xdgdir = 'Xxdg'
local vimdir = 'Xvim'
local xhome = 'Xhome'
- local pathsep = helpers.get_pathsep()
+ local pathsep = t.get_pathsep()
before_each(function()
rmdir(xdgdir)
@@ -1055,7 +1055,7 @@ end)
describe('user config init', function()
local xhome = 'Xhome'
- local pathsep = helpers.get_pathsep()
+ local pathsep = t.get_pathsep()
local xconfig = xhome .. pathsep .. 'Xconfig'
local xdata = xhome .. pathsep .. 'Xdata'
local init_lua_path = table.concat({ xconfig, 'nvim', 'init.lua' }, pathsep)
@@ -1218,7 +1218,7 @@ end)
describe('runtime:', function()
local xhome = 'Xhome'
- local pathsep = helpers.get_pathsep()
+ local pathsep = t.get_pathsep()
local xconfig = xhome .. pathsep .. 'Xconfig'
local xdata = xhome .. pathsep .. 'Xdata'
local xenv = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata }
@@ -1360,7 +1360,7 @@ end)
describe('user session', function()
local xhome = 'Xhome'
- local pathsep = helpers.get_pathsep()
+ local pathsep = t.get_pathsep()
local session_file = table.concat({ xhome, 'session.lua' }, pathsep)
before_each(function()