test: improve test conventions

Work on https://github.com/neovim/neovim/issues/27004.
This commit is contained in:
dundargoc
2024-04-08 11:03:20 +02:00
committed by dundargoc
parent 978962f9a0
commit 7035125b2b
488 changed files with 4176 additions and 4235 deletions

View File

@@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local neq, eq, command = helpers.neq, helpers.eq, helpers.command
local clear = helpers.clear
local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval
local exec_lua = helpers.exec_lua
local insert, pcall_err = helpers.insert, helpers.pcall_err
local matches = helpers.matches
local api = helpers.api
local feed = helpers.feed
local neq, eq, command = t.neq, t.eq, t.command
local clear = t.clear
local exc_exec, expect, eval = t.exc_exec, t.expect, t.eval
local exec_lua = t.exec_lua
local insert, pcall_err = t.insert, t.pcall_err
local matches = t.matches
local api = t.api
local feed = t.feed
describe('eval-API', function()
before_each(clear)

View File

@@ -1,15 +1,15 @@
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 fn = helpers.fn
local api = helpers.api
local command = helpers.command
local exc_exec = helpers.exc_exec
local get_pathsep = helpers.get_pathsep
local rmdir = helpers.rmdir
local pcall_err = helpers.pcall_err
local mkdir = helpers.mkdir
local eq = t.eq
local clear = t.clear
local fn = t.fn
local api = t.api
local command = t.command
local exc_exec = t.exc_exec
local get_pathsep = t.get_pathsep
local rmdir = t.rmdir
local pcall_err = t.pcall_err
local mkdir = t.mkdir
local fname = 'Xtest-functional-eval-buf_functions'
local fname2 = fname .. '.2'

View File

@@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
local clear = helpers.clear
local fn = helpers.fn
local api = helpers.api
local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local exec_capture = helpers.exec_capture
local eq = t.eq
local eval = t.eval
local feed = t.feed
local clear = t.clear
local fn = t.fn
local api = t.api
local command = t.command
local exc_exec = t.exc_exec
local pcall_err = t.pcall_err
local exec_capture = t.exec_capture
before_each(clear)

View File

@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local eq = helpers.eq
local eval = helpers.eval
local api = helpers.api
local clear = helpers.clear
local eq = t.eq
local eval = t.eval
local api = t.api
local clear = t.clear
before_each(clear)

View File

@@ -1,19 +1,19 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local call = helpers.call
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
local call = t.call
local clear = t.clear
local command = t.command
local eq = t.eq
local eval = t.eval
local feed = t.feed
local map = vim.tbl_map
local api = helpers.api
local parse_context = helpers.parse_context
local exec_capture = helpers.exec_capture
local source = helpers.source
local api = t.api
local parse_context = t.parse_context
local exec_capture = t.exec_capture
local source = t.source
local trim = vim.trim
local write_file = helpers.write_file
local pcall_err = helpers.pcall_err
local write_file = t.write_file
local pcall_err = t.pcall_err
describe('context functions', function()
local fname1 = 'Xtest-functional-eval-ctx1'

View File

@@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local environ = helpers.fn.environ
local exists = helpers.fn.exists
local system = helpers.fn.system
local nvim_prog = helpers.nvim_prog
local command = helpers.command
local eval = helpers.eval
local setenv = helpers.fn.setenv
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local eq = t.eq
local environ = t.fn.environ
local exists = t.fn.exists
local system = t.fn.system
local nvim_prog = t.nvim_prog
local command = t.command
local eval = t.eval
local setenv = t.fn.setenv
describe('environment variables', function()
it('environ() handles empty env variable', function()

View File

@@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local exc_exec = helpers.exc_exec
local get_win_var = helpers.api.nvim_win_get_var
local clear = t.clear
local command = t.command
local eq = t.eq
local exc_exec = t.exc_exec
local get_win_var = t.api.nvim_win_get_var
describe('setqflist()', function()
local setqflist = helpers.fn.setqflist
local setqflist = t.fn.setqflist
before_each(clear)
@@ -46,7 +46,7 @@ describe('setqflist()', function()
end)
describe('setloclist()', function()
local setloclist = helpers.fn.setloclist
local setloclist = t.fn.setloclist
before_each(clear)
@@ -73,7 +73,7 @@ describe('setloclist()', function()
end)
it("doesn't crash when when window is closed in the middle #13721", function()
helpers.insert([[
t.insert([[
hello world]])
command('vsplit')
@@ -82,6 +82,6 @@ describe('setloclist()', function()
command('call setloclist(0, [])')
command('lopen')
helpers.assert_alive()
t.assert_alive()
end)
end)

View File

@@ -9,37 +9,37 @@
-- test/functional/vimscript/<funcname>_spec.lua
-- test/functional/vimscript/functions_spec.lua
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local mkdir = helpers.mkdir
local clear = helpers.clear
local eq = helpers.eq
local exec = helpers.exec
local exc_exec = helpers.exc_exec
local exec_lua = helpers.exec_lua
local exec_capture = helpers.exec_capture
local eval = helpers.eval
local command = helpers.command
local write_file = helpers.write_file
local api = helpers.api
local mkdir = t.mkdir
local clear = t.clear
local eq = t.eq
local exec = t.exec
local exc_exec = t.exc_exec
local exec_lua = t.exec_lua
local exec_capture = t.exec_capture
local eval = t.eval
local command = t.command
local write_file = t.write_file
local api = t.api
local sleep = vim.uv.sleep
local matches = helpers.matches
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
local poke_eventloop = helpers.poke_eventloop
local feed = helpers.feed
local expect_exit = helpers.expect_exit
local matches = t.matches
local pcall_err = t.pcall_err
local assert_alive = t.assert_alive
local poke_eventloop = t.poke_eventloop
local feed = t.feed
local expect_exit = t.expect_exit
describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
local max_func_args = 20 -- from eval.h
local range = helpers.fn.range
local range = t.fn.range
before_each(clear)
it('printf()', function()
local printf = helpers.fn.printf
local rep = helpers.fn['repeat']
local printf = t.fn.printf
local rep = t.fn['repeat']
local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,'
eq(expected, printf(rep('%d,', max_func_args - 1), unpack(range(2, max_func_args))))
local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
@@ -47,7 +47,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
end)
it('rpcnotify()', function()
local rpcnotify = helpers.fn.rpcnotify
local rpcnotify = t.fn.rpcnotify
local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args)))
eq(1, ret)
ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
@@ -69,17 +69,17 @@ describe('backtick expansion', function()
end)
teardown(function()
helpers.rmdir('test-backticks')
t.rmdir('test-backticks')
end)
it("with default 'shell'", function()
if helpers.is_os('win') then
if t.is_os('win') then
command(':silent args `dir /b *2`')
else
command(':silent args `echo ***2`')
end
eq({ 'file2' }, eval('argv()'))
if helpers.is_os('win') then
if t.is_os('win') then
command(':silent args `dir /s/b *4`')
eq({ 'subdir\\file4' }, eval('map(argv(), \'fnamemodify(v:val, ":.")\')'))
else

View File

@@ -1,9 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local eq, clear, call, write_file, command =
helpers.eq, helpers.clear, helpers.call, helpers.write_file, helpers.command
local exc_exec = helpers.exc_exec
local eval = helpers.eval
local is_os = helpers.is_os
local t = require('test.functional.testutil')(after_each)
local eq, clear, call, write_file, command = t.eq, t.clear, t.call, t.write_file, t.command
local exc_exec = t.exc_exec
local eval = t.eval
local is_os = t.is_os
describe('executable()', function()
before_each(clear)

View File

@@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local eval = helpers.eval
local clear = helpers.clear
local source = helpers.source
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local fn = helpers.fn
local t = require('test.functional.testutil')(after_each)
local eq = t.eq
local eval = t.eval
local clear = t.clear
local source = t.source
local exc_exec = t.exc_exec
local pcall_err = t.pcall_err
local fn = t.fn
local Screen = require('test.functional.ui.screen')
local command = helpers.command
local feed = helpers.feed
local is_os = helpers.is_os
local command = t.command
local feed = t.feed
local is_os = t.is_os
describe('execute()', function()
before_each(clear)

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local eq, clear, call = helpers.eq, helpers.clear, helpers.call
local command = helpers.command
local exc_exec = helpers.exc_exec
local matches = helpers.matches
local is_os = helpers.is_os
local set_shell_powershell = helpers.set_shell_powershell
local eval = helpers.eval
local t = require('test.functional.testutil')(after_each)
local eq, clear, call = t.eq, t.clear, t.call
local command = t.command
local exc_exec = t.exc_exec
local matches = t.matches
local is_os = t.is_os
local set_shell_powershell = t.set_shell_powershell
local eval = t.eval
local find_dummies = function(ext_pat)
local tmp_path = eval('$PATH')

View File

@@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local fnamemodify = helpers.fn.fnamemodify
local getcwd = helpers.fn.getcwd
local command = helpers.command
local write_file = helpers.write_file
local alter_slashes = helpers.alter_slashes
local is_os = helpers.is_os
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local eq = t.eq
local fnamemodify = t.fn.fnamemodify
local getcwd = t.fn.getcwd
local command = t.command
local write_file = t.write_file
local alter_slashes = t.alter_slashes
local is_os = t.is_os
local function eq_slashconvert(expected, got)
eq(alter_slashes(expected), alter_slashes(got))
@@ -24,7 +24,7 @@ describe('fnamemodify()', function()
end)
it('handles the root path', function()
local root = helpers.pathroot()
local root = t.pathroot()
eq(root, fnamemodify([[/]], ':p:h'))
eq(root, fnamemodify([[/]], ':p'))
if is_os('win') then

View File

@@ -5,12 +5,12 @@
--
-- Core "eval" tests live in eval_spec.lua.
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear
local eval = helpers.eval
local matches = helpers.matches
local is_os = helpers.is_os
local clear = t.clear
local eval = t.eval
local matches = t.matches
local is_os = t.is_os
before_each(clear)

View File

@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local call = helpers.call
local clear = helpers.clear
local eq = helpers.eq
local expect = helpers.expect
local call = t.call
local clear = t.clear
local eq = t.eq
local expect = t.expect
describe('getline()', function()
before_each(function()

View File

@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, command, eval, eq = helpers.clear, helpers.command, helpers.eval, helpers.eq
local mkdir = helpers.mkdir
local t = require('test.functional.testutil')(after_each)
local clear, command, eval, eq = t.clear, t.command, t.eval, t.eq
local mkdir = t.mkdir
before_each(function()
clear()

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local connect = helpers.connect
local eq = helpers.eq
local fn = helpers.fn
local is_os = helpers.is_os
local nvim_prog = helpers.nvim_prog
local clear = t.clear
local connect = t.connect
local eq = t.eq
local fn = t.fn
local is_os = t.is_os
local nvim_prog = t.nvim_prog
describe('has()', function()
before_each(clear)

View File

@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local ok = helpers.ok
local call = helpers.call
local clear = helpers.clear
local is_os = helpers.is_os
local t = require('test.functional.testutil')(after_each)
local eq = t.eq
local ok = t.ok
local call = t.call
local clear = t.clear
local is_os = t.is_os
describe('hostname()', function()
before_each(clear)

View File

@@ -1,14 +1,14 @@
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 feed = helpers.feed
local api = helpers.api
local clear = helpers.clear
local source = helpers.source
local command = helpers.command
local exc_exec = helpers.exc_exec
local async_meths = helpers.async_meths
local eq = t.eq
local feed = t.feed
local api = t.api
local clear = t.clear
local source = t.source
local command = t.command
local exc_exec = t.exc_exec
local async_meths = t.async_meths
local NIL = vim.NIL
local screen

View File

@@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local fn = helpers.fn
local api = helpers.api
local eq = helpers.eq
local eval = helpers.eval
local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local fn = t.fn
local api = t.api
local eq = t.eq
local eval = t.eval
local command = t.command
local exc_exec = t.exc_exec
local pcall_err = t.pcall_err
local NIL = vim.NIL
local source = helpers.source
local source = t.source
describe('json_decode() function', function()
local restart = function(...)

View File

@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
local exc_exec, source = helpers.exc_exec, helpers.source
local t = require('test.functional.testutil')(after_each)
local clear, eval, eq = t.clear, t.eval, t.eq
local exc_exec, source = t.exc_exec, t.source
describe('vimscript', function()
before_each(clear)

View File

@@ -1,15 +1,15 @@
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 command = helpers.command
local eval = helpers.eval
local api = helpers.api
local exec = helpers.exec
local exec_capture = helpers.exec_capture
local expect_exit = helpers.expect_exit
local source = helpers.source
local testprg = helpers.testprg
local eq = t.eq
local clear = t.clear
local command = t.command
local eval = t.eval
local api = t.api
local exec = t.exec
local exec_capture = t.exec_capture
local expect_exit = t.expect_exit
local source = t.source
local testprg = t.testprg
before_each(clear)

View File

@@ -1,18 +1,18 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
local exec = helpers.exec
local exec_lua = helpers.exec_lua
local expect = helpers.expect
local feed = helpers.feed
local fn = helpers.fn
local api = helpers.api
local source = helpers.source
local command = helpers.command
local exec_capture = helpers.exec_capture
local pcall_err = helpers.pcall_err
local clear = t.clear
local eq = t.eq
local eval = t.eval
local exec = t.exec
local exec_lua = t.exec_lua
local expect = t.expect
local feed = t.feed
local fn = t.fn
local api = t.api
local source = t.source
local command = t.command
local exec_capture = t.exec_capture
local pcall_err = t.pcall_err
describe('maparg()', function()
before_each(clear)

View File

@@ -1,11 +1,11 @@
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 clear = helpers.clear
local fn = helpers.fn
local command = helpers.command
local exc_exec = helpers.exc_exec
local eq = t.eq
local clear = t.clear
local fn = t.fn
local command = t.command
local exc_exec = t.exc_exec
before_each(clear)

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local eq = helpers.eq
local eval = helpers.eval
local command = helpers.command
local clear = helpers.clear
local fn = helpers.fn
local pcall_err = helpers.pcall_err
local eq = t.eq
local eval = t.eval
local command = t.command
local clear = t.clear
local fn = t.fn
local pcall_err = t.pcall_err
before_each(clear)
for _, func in ipairs({ 'min', 'max' }) do

View File

@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local assert_alive = helpers.assert_alive
local clear, command, write_file = helpers.clear, helpers.command, helpers.write_file
local t = require('test.functional.testutil')(after_each)
local assert_alive = t.assert_alive
local clear, command, write_file = t.clear, t.command, t.write_file
describe('modeline', function()
local tempfile = helpers.tmpname()
local tempfile = t.tmpname()
before_each(clear)
after_each(function()

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local fn = helpers.fn
local eval, eq = helpers.eval, helpers.eq
local command = helpers.command
local api = helpers.api
local exc_exec = helpers.exc_exec
local is_os = helpers.is_os
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local fn = t.fn
local eval, eq = t.eval, t.eq
local command = t.command
local api = t.api
local exc_exec = t.exc_exec
local is_os = t.is_os
describe('msgpack*() functions', function()
before_each(clear)
@@ -469,12 +469,12 @@ describe('msgpackparse() function', function()
end)
it('msgpackparse(systemlist(...)) does not segfault. #3135', function()
local cmd = "sort(keys(msgpackparse(systemlist('" .. helpers.nvim_prog .. " --api-info'))[0]))"
local cmd = "sort(keys(msgpackparse(systemlist('" .. t.nvim_prog .. " --api-info'))[0]))"
eval(cmd)
eval(cmd) -- do it again (try to force segfault)
local api_info = eval(cmd) -- do it again
if is_os('win') then
helpers.assert_alive()
t.assert_alive()
pending('msgpackparse() has a bug on windows')
return
end

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local exc_exec = helpers.exc_exec
local command = helpers.command
local clear = helpers.clear
local api = helpers.api
local fn = helpers.fn
local eq = helpers.eq
local exc_exec = t.exc_exec
local command = t.command
local clear = t.clear
local api = t.api
local fn = t.fn
local eq = t.eq
local function redir_exec(cmd)
api.nvim_set_var('__redir_exec_cmd', cmd)

View File

@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local eval = helpers.eval
local clear = helpers.clear
local t = require('test.functional.testutil')(after_each)
local eq = t.eq
local eval = t.eval
local clear = t.clear
describe('Division operator', function()
before_each(clear)

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
local fn = helpers.fn
local api = helpers.api
local exc_exec = helpers.exc_exec
local clear = t.clear
local eq = t.eq
local eval = t.eval
local fn = t.fn
local api = t.api
local exc_exec = t.exc_exec
describe('printf()', function()
before_each(clear)

View File

@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok
local neq, command, fn = helpers.neq, helpers.command, helpers.fn
local matches = helpers.matches
local t = require('test.functional.testutil')(after_each)
local clear, eq, ok = t.clear, t.eq, t.ok
local neq, command, fn = t.neq, t.command, t.fn
local matches = t.matches
local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat
describe('reltimestr(), reltimefloat()', function()

View File

@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
local command, api, fn = helpers.command, helpers.api, helpers.fn
local t = require('test.functional.testutil')(after_each)
local clear, eq, neq = t.clear, t.eq, t.neq
local command, api, fn = t.command, t.api, t.fn
local tbl_deep_extend = vim.tbl_deep_extend
-- Set up two overlapping floating windows

View File

@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, api = helpers.clear, helpers.eq, helpers.api
local command, fn = helpers.command, helpers.fn
local feed = helpers.feed
local t = require('test.functional.testutil')(after_each)
local clear, eq, api = t.clear, t.eq, t.api
local command, fn = t.command, t.fn
local feed = t.feed
before_each(clear)

View File

@@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each)
local assert_log = helpers.assert_log
local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval
local clear, fn, api = helpers.clear, helpers.fn, helpers.api
local ok = helpers.ok
local matches = helpers.matches
local pcall_err = helpers.pcall_err
local check_close = helpers.check_close
local mkdir = helpers.mkdir
local rmdir = helpers.rmdir
local is_os = helpers.is_os
local t = require('test.functional.testutil')(after_each)
local assert_log = t.assert_log
local eq, neq, eval = t.eq, t.neq, t.eval
local clear, fn, api = t.clear, t.fn, t.api
local ok = t.ok
local matches = t.matches
local pcall_err = t.pcall_err
local check_close = t.check_close
local mkdir = t.mkdir
local rmdir = t.rmdir
local is_os = t.is_os
local testlog = 'Xtest-server-log'
@@ -176,11 +176,11 @@ end)
describe('startup --listen', function()
it('validates', function()
clear()
local cmd = { unpack(helpers.nvim_argv) }
local cmd = { unpack(t.nvim_argv) }
table.insert(cmd, '--listen')
matches('nvim.*: Argument missing after: "%-%-listen"', fn.system(cmd))
cmd = { unpack(helpers.nvim_argv) }
cmd = { unpack(t.nvim_argv) }
table.insert(cmd, '--listen2')
matches('nvim.*: Garbage after option argument: "%-%-listen2"', fn.system(cmd))
end)

View File

@@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each)
local setpos = helpers.fn.setpos
local getpos = helpers.fn.getpos
local insert = helpers.insert
local clear = helpers.clear
local command = helpers.command
local eval = helpers.eval
local eq = helpers.eq
local exc_exec = helpers.exc_exec
local t = require('test.functional.testutil')(after_each)
local setpos = t.fn.setpos
local getpos = t.fn.getpos
local insert = t.insert
local clear = t.clear
local command = t.command
local eval = t.eval
local eq = t.eq
local exc_exec = t.exc_exec
describe('setpos() function', function()
before_each(function()

View File

@@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local eq = helpers.eq
local eq = t.eq
local NIL = vim.NIL
local eval = helpers.eval
local clear = helpers.clear
local api = helpers.api
local fn = helpers.fn
local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local eval = t.eval
local clear = t.clear
local api = t.api
local fn = t.fn
local command = t.command
local exc_exec = t.exc_exec
local pcall_err = t.pcall_err
before_each(clear)

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local exc_exec = helpers.exc_exec
local command = helpers.command
local fn = helpers.fn
local clear = helpers.clear
local eval = helpers.eval
local eq = helpers.eq
local api = helpers.api
local t = require('test.functional.testutil')(after_each)
local exc_exec = t.exc_exec
local command = t.command
local fn = t.fn
local clear = t.clear
local eval = t.eval
local eq = t.eq
local api = t.api
local NIL = vim.NIL
describe('Special values', function()

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local exec = helpers.exec
local exec_lua = helpers.exec_lua
local feed = helpers.feed
local api = helpers.api
local poke_eventloop = helpers.poke_eventloop
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local eq = t.eq
local exec = t.exec
local exec_lua = t.exec_lua
local feed = t.feed
local api = t.api
local poke_eventloop = t.poke_eventloop
before_each(clear)

View File

@@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local command = helpers.command
local api = helpers.api
local eval = helpers.eval
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local fn = helpers.fn
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local eq = t.eq
local command = t.command
local api = t.api
local eval = t.eval
local exc_exec = t.exc_exec
local pcall_err = t.pcall_err
local fn = t.fn
local NIL = vim.NIL
local source = helpers.source
local source = t.source
describe('string() function', function()
before_each(clear)
@@ -190,7 +190,7 @@ describe('string() function', function()
eval('add(l, l)')
-- Regression: the below line used to crash (add returns original list and
-- there was error in dumping partials). Tested explicitly in
-- test/unit/api/private_helpers_spec.lua.
-- test/unit/api/private_t_spec.lua.
eval('add(l, function("Test1", l))')
eq(
[=[Vim(echo):E724: unable to correctly dump variable with self-referencing container]=],

View File

@@ -1,24 +1,18 @@
-- Tests for system() and :! shell.
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local assert_alive = helpers.assert_alive
local testprg = helpers.testprg
local assert_alive = t.assert_alive
local testprg = t.testprg
local eq, call, clear, eval, feed_command, feed, api =
helpers.eq,
helpers.call,
helpers.clear,
helpers.eval,
helpers.feed_command,
helpers.feed,
helpers.api
local command = helpers.command
local insert = helpers.insert
local expect = helpers.expect
local exc_exec = helpers.exc_exec
local os_kill = helpers.os_kill
local pcall_err = helpers.pcall_err
local is_os = helpers.is_os
t.eq, t.call, t.clear, t.eval, t.feed_command, t.feed, t.api
local command = t.command
local insert = t.insert
local expect = t.expect
local exc_exec = t.exc_exec
local os_kill = t.os_kill
local pcall_err = t.pcall_err
local is_os = t.is_os
local Screen = require('test.functional.ui.screen')
@@ -189,7 +183,7 @@ describe('system()', function()
end)
it('with powershell', function()
helpers.set_shell_powershell()
t.set_shell_powershell()
eq('a\nb\n', eval([[system('Write-Output a b')]]))
eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]]))
eq('a b\n', eval([[system('Write-Output "a b"')]]))
@@ -197,11 +191,11 @@ describe('system()', function()
end
it('powershell w/ UTF-8 text #13713', function()
if not helpers.has_powershell() then
if not t.has_powershell() then
pending('powershell not found', function() end)
return
end
helpers.set_shell_powershell()
t.set_shell_powershell()
eq('ああ\n', eval([[system('Write-Output "ああ"')]]))
-- Sanity test w/ default encoding
-- * on Windows, expected to default to Western European enc
@@ -234,7 +228,7 @@ describe('system()', function()
end)
it('self and total time recorded separately', function()
local tempfile = helpers.tmpname()
local tempfile = t.tmpname()
feed(':function! AlmostNoSelfTime()<cr>')
feed('echo system("echo hi")<cr>')
@@ -247,11 +241,11 @@ describe('system()', function()
feed(':edit ' .. tempfile .. '<cr>')
local command_total_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[2])
local command_self_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[3])
local command_total_time = tonumber(t.fn.split(t.fn.getline(7))[2])
local command_self_time = tonumber(t.fn.split(t.fn.getline(7))[3])
helpers.neq(nil, command_total_time)
helpers.neq(nil, command_self_time)
t.neq(nil, command_total_time)
t.neq(nil, command_self_time)
end)
it('`yes` interrupted with CTRL-C', function()
@@ -554,11 +548,11 @@ describe('systemlist()', function()
end)
it('powershell w/ UTF-8 text #13713', function()
if not helpers.has_powershell() then
if not t.has_powershell() then
pending('powershell not found', function() end)
return
end
helpers.set_shell_powershell()
t.set_shell_powershell()
eq({ is_os('win') and '\r' or '' }, eval([[systemlist('Write-Output あ')]]))
-- Sanity test w/ default encoding
-- * on Windows, expected to default to Western European enc
@@ -574,7 +568,7 @@ describe('shell :!', function()
it(':{range}! with powershell filter/redirect #16271 #19250', function()
local screen = Screen.new(500, 8)
screen:attach()
local found = helpers.set_shell_powershell(true)
local found = t.set_shell_powershell(true)
insert([[
3
1
@@ -621,12 +615,12 @@ describe('shell :!', function()
}
end
feed('<CR>')
helpers.set_shell_powershell(true)
t.set_shell_powershell(true)
feed(':4verbose %w !sort<cr>')
screen:expect {
any = [[Executing command: .?& { Get%-Content .* | & sort }]],
}
feed('<CR>')
helpers.expect_exit(command, 'qall!')
t.expect_exit(command, 'qall!')
end)
end)

View File

@@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local feed, eq, eval, ok = helpers.feed, helpers.eq, helpers.eval, helpers.ok
local source, async_meths, run = helpers.source, helpers.async_meths, helpers.run
local clear, command, fn = helpers.clear, helpers.command, helpers.fn
local exc_exec = helpers.exc_exec
local api = helpers.api
local load_adjust = helpers.load_adjust
local retry = helpers.retry
local feed, eq, eval, ok = t.feed, t.eq, t.eval, t.ok
local source, async_meths, run = t.source, t.async_meths, t.run
local clear, command, fn = t.clear, t.command, t.fn
local exc_exec = t.exc_exec
local api = t.api
local load_adjust = t.load_adjust
local retry = t.retry
describe('timers', function()
before_each(function()

View File

@@ -1,10 +1,10 @@
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 command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local eq = t.eq
local clear = t.clear
local command = t.command
local exc_exec = t.exc_exec
local pcall_err = t.pcall_err
before_each(clear)

View File

@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
local command = helpers.command
local t = require('test.functional.testutil')(after_each)
local clear, eval, eq = t.clear, t.eval, t.eq
local command = t.command
describe('v:event', function()
before_each(clear)
it('is empty before any autocommand', function()

View File

@@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each)
local call = helpers.call
local clear = helpers.clear
local command = helpers.command
local eval = helpers.eval
local eq = helpers.eq
local feed = helpers.feed
local feed_command = helpers.feed_command
local next_msg = helpers.next_msg
local api = helpers.api
local source = helpers.source
local pcall_err = helpers.pcall_err
local t = require('test.functional.testutil')(after_each)
local call = t.call
local clear = t.clear
local command = t.command
local eval = t.eval
local eq = t.eq
local feed = t.feed
local feed_command = t.feed_command
local next_msg = t.next_msg
local api = t.api
local source = t.source
local pcall_err = t.pcall_err
before_each(function()
clear()
@@ -60,7 +60,7 @@ describe('wait()', function()
]])
-- XXX: flaky (#11137)
helpers.retry(nil, nil, function()
t.retry(nil, nil, function()
api.nvim_set_var('counter', 0)
eq(-1, call('wait', 20, 'Count() >= 5', 99999))
end)

View File

@@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local mkdir = helpers.mkdir
local clear = helpers.clear
local eq = helpers.eq
local fn = helpers.fn
local api = helpers.api
local exc_exec = helpers.exc_exec
local read_file = helpers.read_file
local write_file = helpers.write_file
local pcall_err = helpers.pcall_err
local command = helpers.command
local mkdir = t.mkdir
local clear = t.clear
local eq = t.eq
local fn = t.fn
local api = t.api
local exc_exec = t.exc_exec
local read_file = t.read_file
local write_file = t.write_file
local pcall_err = t.pcall_err
local command = t.command
local fname = 'Xtest-functional-eval-writefile'
local dname = fname .. '.d'