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.
This commit is contained in:
dundargoc
2024-04-20 17:44:13 +02:00
committed by dundargoc
parent c5af5c0b9a
commit 052498ed42
444 changed files with 3459 additions and 3131 deletions

View File

@@ -1,13 +1,15 @@
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 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 neq, eq, command = t.neq, t.eq, n.command
local clear = n.clear
local exc_exec, expect, eval = n.exc_exec, n.expect, n.eval
local exec_lua = n.exec_lua
local insert, pcall_err = n.insert, t.pcall_err
local matches = t.matches
local api = t.api
local feed = t.feed
local api = n.api
local feed = n.feed
describe('eval-API', function()
before_each(clear)

View File

@@ -1,13 +1,14 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
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 clear = n.clear
local fn = n.fn
local api = n.api
local command = n.command
local exc_exec = n.exc_exec
local get_pathsep = n.get_pathsep
local rmdir = n.rmdir
local pcall_err = t.pcall_err
local mkdir = t.mkdir

View File

@@ -1,15 +1,16 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
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 eval = n.eval
local feed = n.feed
local clear = n.clear
local fn = n.fn
local api = n.api
local command = n.command
local exc_exec = n.exc_exec
local pcall_err = t.pcall_err
local exec_capture = t.exec_capture
local exec_capture = n.exec_capture
before_each(clear)

View File

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

View File

@@ -1,16 +1,17 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local call = t.call
local clear = t.clear
local command = t.command
local call = n.call
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
local map = vim.tbl_map
local api = t.api
local parse_context = t.parse_context
local exec_capture = t.exec_capture
local source = t.source
local api = n.api
local parse_context = n.parse_context
local exec_capture = n.exec_capture
local source = n.source
local trim = vim.trim
local write_file = t.write_file
local pcall_err = t.pcall_err

View File

@@ -1,13 +1,15 @@
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 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
local environ = n.fn.environ
local exists = n.fn.exists
local system = n.fn.system
local nvim_prog = n.nvim_prog
local command = n.command
local eval = n.eval
local setenv = n.fn.setenv
describe('environment variables', function()
it('environ() handles empty env variable', function()

View File

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

View File

@@ -9,37 +9,38 @@
-- test/functional/vimscript/<funcname>_spec.lua
-- test/functional/vimscript/functions_spec.lua
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 mkdir = t.mkdir
local clear = t.clear
local clear = n.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 exec = n.exec
local exc_exec = n.exc_exec
local exec_lua = n.exec_lua
local exec_capture = n.exec_capture
local eval = n.eval
local command = n.command
local write_file = t.write_file
local api = t.api
local api = n.api
local sleep = vim.uv.sleep
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
local assert_alive = n.assert_alive
local poke_eventloop = n.poke_eventloop
local feed = n.feed
local expect_exit = n.expect_exit
describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
local max_func_args = 20 -- from eval.h
local range = t.fn.range
local range = n.fn.range
before_each(clear)
it('printf()', function()
local printf = t.fn.printf
local rep = t.fn['repeat']
local printf = n.fn.printf
local rep = n.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 +48,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
end)
it('rpcnotify()', function()
local rpcnotify = t.fn.rpcnotify
local rpcnotify = n.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,7 +70,7 @@ describe('backtick expansion', function()
end)
teardown(function()
t.rmdir('test-backticks')
n.rmdir('test-backticks')
end)
it("with default 'shell'", function()

View File

@@ -1,7 +1,9 @@
local t = require('test.functional.testutil')()
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 t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq, clear, call, write_file, command = t.eq, n.clear, n.call, t.write_file, n.command
local exc_exec = n.exc_exec
local eval = n.eval
local is_os = t.is_os
describe('executable()', function()

View File

@@ -1,14 +1,16 @@
local t = require('test.functional.testutil')()
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 t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local command = t.command
local feed = t.feed
local eq = t.eq
local eval = n.eval
local clear = n.clear
local source = n.source
local exc_exec = n.exc_exec
local pcall_err = t.pcall_err
local fn = n.fn
local command = n.command
local feed = n.feed
local is_os = t.is_os
describe('execute()', function()

View File

@@ -1,11 +1,13 @@
local t = require('test.functional.testutil')()
local eq, clear, call = t.eq, t.clear, t.call
local command = t.command
local exc_exec = t.exc_exec
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq, clear, call = t.eq, n.clear, n.call
local command = n.command
local exc_exec = n.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 set_shell_powershell = n.set_shell_powershell
local eval = n.eval
local find_dummies = function(ext_pat)
local tmp_path = eval('$PATH')

View File

@@ -1,11 +1,13 @@
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 fnamemodify = t.fn.fnamemodify
local getcwd = t.fn.getcwd
local command = t.command
local fnamemodify = n.fn.fnamemodify
local getcwd = n.fn.getcwd
local command = n.command
local write_file = t.write_file
local alter_slashes = t.alter_slashes
local alter_slashes = n.alter_slashes
local is_os = t.is_os
local function eq_slashconvert(expected, got)
@@ -24,7 +26,7 @@ describe('fnamemodify()', function()
end)
it('handles the root path', function()
local root = t.pathroot()
local root = n.pathroot()
eq(root, fnamemodify([[/]], ':p:h'))
eq(root, fnamemodify([[/]], ':p'))
if is_os('win') then

View File

@@ -5,10 +5,11 @@
--
-- Core "eval" tests live in eval_spec.lua.
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local eval = t.eval
local clear = n.clear
local eval = n.eval
local matches = t.matches
local is_os = t.is_os

View File

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

View File

@@ -1,5 +1,7 @@
local t = require('test.functional.testutil')()
local clear, command, eval, eq = t.clear, t.command, t.eval, t.eq
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, command, eval, eq = n.clear, n.command, n.eval, t.eq
local mkdir = t.mkdir
before_each(function()

View File

@@ -1,11 +1,13 @@
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 connect = t.connect
local clear = n.clear
local connect = n.connect
local eq = t.eq
local fn = t.fn
local fn = n.fn
local is_os = t.is_os
local nvim_prog = t.nvim_prog
local nvim_prog = n.nvim_prog
describe('has()', function()
before_each(clear)

View File

@@ -1,8 +1,10 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local ok = t.ok
local call = t.call
local clear = t.clear
local call = n.call
local clear = n.clear
local is_os = t.is_os
describe('hostname()', function()

View File

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

View File

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

View File

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

View File

@@ -1,15 +1,16 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
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
local clear = n.clear
local command = n.command
local eval = n.eval
local api = n.api
local exec = n.exec
local exec_capture = n.exec_capture
local expect_exit = n.expect_exit
local source = n.source
local testprg = n.testprg
before_each(clear)

View File

@@ -1,17 +1,18 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local clear = n.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 eval = n.eval
local exec = n.exec
local exec_lua = n.exec_lua
local expect = n.expect
local feed = n.feed
local fn = n.fn
local api = n.api
local source = n.source
local command = n.command
local exec_capture = n.exec_capture
local pcall_err = t.pcall_err
describe('maparg()', function()

View File

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

View File

@@ -1,10 +1,11 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local eval = t.eval
local command = t.command
local clear = t.clear
local fn = t.fn
local eval = n.eval
local command = n.command
local clear = n.clear
local fn = n.fn
local pcall_err = t.pcall_err
before_each(clear)

View File

@@ -1,6 +1,8 @@
local t = require('test.functional.testutil')()
local assert_alive = t.assert_alive
local clear, command, write_file = t.clear, t.command, t.write_file
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local assert_alive = n.assert_alive
local clear, command, write_file = n.clear, n.command, t.write_file
describe('modeline', function()
local tempfile = t.tmpname()

View File

@@ -1,10 +1,12 @@
local t = require('test.functional.testutil')()
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 t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local fn = n.fn
local eval, eq = n.eval, t.eq
local command = n.command
local api = n.api
local exc_exec = n.exc_exec
local is_os = t.is_os
describe('msgpack*() functions', function()
@@ -469,12 +471,12 @@ describe('msgpackparse() function', function()
end)
it('msgpackparse(systemlist(...)) does not segfault. #3135', function()
local cmd = "sort(keys(msgpackparse(systemlist('" .. t.nvim_prog .. " --api-info'))[0]))"
local cmd = "sort(keys(msgpackparse(systemlist('" .. n.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
t.assert_alive()
n.assert_alive()
pending('msgpackparse() has a bug on windows')
return
end

View File

@@ -1,10 +1,11 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local exc_exec = t.exc_exec
local command = t.command
local clear = t.clear
local api = t.api
local fn = t.fn
local exc_exec = n.exc_exec
local command = n.command
local clear = n.clear
local api = n.api
local fn = n.fn
local eq = t.eq
local function redir_exec(cmd)

View File

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

View File

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

View File

@@ -1,6 +1,8 @@
local t = require('test.functional.testutil')()
local clear, eq, ok = t.clear, t.eq, t.ok
local neq, command, fn = t.neq, t.command, t.fn
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, eq, ok = n.clear, t.eq, t.ok
local neq, command, fn = t.neq, n.command, n.fn
local matches = t.matches
local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat

View File

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

View File

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

View File

@@ -1,13 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
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 eq, neq, eval = t.eq, t.neq, n.eval
local clear, fn, api = n.clear, n.fn, n.api
local ok = t.ok
local matches = t.matches
local pcall_err = t.pcall_err
local check_close = t.check_close
local check_close = n.check_close
local mkdir = t.mkdir
local rmdir = t.rmdir
local rmdir = n.rmdir
local is_os = t.is_os
local testlog = 'Xtest-server-log'
@@ -148,7 +150,7 @@ describe('server', function()
it('serverlist() returns the list of servers', function()
clear()
-- There should already be at least one server.
local n = eval('len(serverlist())')
local _n = eval('len(serverlist())')
-- Add some servers.
local servs = (
@@ -162,25 +164,25 @@ describe('server', function()
local new_servs = eval('serverlist()')
-- Exactly #servs servers should be added.
eq(n + #servs, #new_servs)
eq(_n + #servs, #new_servs)
-- The new servers should be at the end of the list.
for i = 1, #servs do
eq(servs[i], new_servs[i + n])
eq(servs[i], new_servs[i + _n])
eq(1, eval("serverstop('" .. servs[i] .. "')"))
end
-- After serverstop() the servers should NOT be in the list.
eq(n, eval('len(serverlist())'))
eq(_n, eval('len(serverlist())'))
end)
end)
describe('startup --listen', function()
it('validates', function()
clear()
local cmd = { unpack(t.nvim_argv) }
local cmd = { unpack(n.nvim_argv) }
table.insert(cmd, '--listen')
matches('nvim.*: Argument missing after: "%-%-listen"', fn.system(cmd))
cmd = { unpack(t.nvim_argv) }
cmd = { unpack(n.nvim_argv) }
table.insert(cmd, '--listen2')
matches('nvim.*: Garbage after option argument: "%-%-listen2"', fn.system(cmd))
end)

View File

@@ -1,12 +1,14 @@
local t = require('test.functional.testutil')()
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 t = require('test.testutil')
local n = require('test.functional.testnvim')()
local setpos = n.fn.setpos
local getpos = n.fn.getpos
local insert = n.insert
local clear = n.clear
local command = n.command
local eval = n.eval
local eq = t.eq
local exc_exec = t.exc_exec
local exc_exec = n.exc_exec
describe('setpos() function', function()
before_each(function()

View File

@@ -1,13 +1,14 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local NIL = vim.NIL
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 eval = n.eval
local clear = n.clear
local api = n.api
local fn = n.fn
local command = n.command
local exc_exec = n.exc_exec
local pcall_err = t.pcall_err
before_each(clear)

View File

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

View File

@@ -1,11 +1,13 @@
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 exec = t.exec
local exec_lua = t.exec_lua
local feed = t.feed
local api = t.api
local poke_eventloop = t.poke_eventloop
local exec = n.exec
local exec_lua = n.exec_lua
local feed = n.feed
local api = n.api
local poke_eventloop = n.poke_eventloop
before_each(clear)

View File

@@ -1,14 +1,16 @@
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 command = t.command
local api = t.api
local eval = t.eval
local exc_exec = t.exc_exec
local command = n.command
local api = n.api
local eval = n.eval
local exc_exec = n.exc_exec
local pcall_err = t.pcall_err
local fn = t.fn
local fn = n.fn
local NIL = vim.NIL
local source = t.source
local source = n.source
describe('string() function', function()
before_each(clear)

View File

@@ -1,21 +1,21 @@
-- Tests for system() and :! shell.
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 testprg = t.testprg
local assert_alive = n.assert_alive
local testprg = n.testprg
local eq, call, clear, eval, feed_command, feed, api =
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
t.eq, n.call, n.clear, n.eval, n.feed_command, n.feed, n.api
local command = n.command
local insert = n.insert
local expect = n.expect
local exc_exec = n.exc_exec
local os_kill = n.os_kill
local pcall_err = t.pcall_err
local is_os = t.is_os
local Screen = require('test.functional.ui.screen')
local function create_file_with_nuls(name)
return function()
feed('ipart1<C-V>000part2<C-V>000part3<ESC>:w ' .. name .. '<CR>')
@@ -183,7 +183,7 @@ describe('system()', function()
end)
it('with powershell', function()
t.set_shell_powershell()
n.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"')]]))
@@ -191,11 +191,11 @@ describe('system()', function()
end
it('powershell w/ UTF-8 text #13713', function()
if not t.has_powershell() then
if not n.has_powershell() then
pending('powershell not found', function() end)
return
end
t.set_shell_powershell()
n.set_shell_powershell()
eq('ああ\n', eval([[system('Write-Output "ああ"')]]))
-- Sanity test w/ default encoding
-- * on Windows, expected to default to Western European enc
@@ -241,8 +241,8 @@ describe('system()', function()
feed(':edit ' .. tempfile .. '<cr>')
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])
local command_total_time = tonumber(n.fn.split(n.fn.getline(7))[2])
local command_self_time = tonumber(n.fn.split(n.fn.getline(7))[3])
t.neq(nil, command_total_time)
t.neq(nil, command_self_time)
@@ -548,11 +548,11 @@ describe('systemlist()', function()
end)
it('powershell w/ UTF-8 text #13713', function()
if not t.has_powershell() then
if not n.has_powershell() then
pending('powershell not found', function() end)
return
end
t.set_shell_powershell()
n.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
@@ -568,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 = t.set_shell_powershell(true)
local found = n.set_shell_powershell(true)
insert([[
3
1
@@ -615,12 +615,12 @@ describe('shell :!', function()
}
end
feed('<CR>')
t.set_shell_powershell(true)
n.set_shell_powershell(true)
feed(':4verbose %w !sort<cr>')
screen:expect {
any = [[Executing command: .?& { Get%-Content .* | & sort }]],
}
feed('<CR>')
t.expect_exit(command, 'qall!')
n.expect_exit(command, 'qall!')
end)
end)

View File

@@ -1,11 +1,13 @@
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 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 feed, eq, eval, ok = n.feed, t.eq, n.eval, t.ok
local source, async_meths, run = n.source, n.async_meths, n.run
local clear, command, fn = n.clear, n.command, n.fn
local exc_exec = n.exc_exec
local api = n.api
local load_adjust = n.load_adjust
local retry = t.retry
describe('timers', function()

View File

@@ -1,9 +1,10 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local clear = t.clear
local command = t.command
local exc_exec = t.exc_exec
local clear = n.clear
local command = n.command
local exc_exec = n.exc_exec
local pcall_err = t.pcall_err
before_each(clear)

View File

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

View File

@@ -1,14 +1,16 @@
local t = require('test.functional.testutil')()
local call = t.call
local clear = t.clear
local command = t.command
local eval = t.eval
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local call = n.call
local clear = n.clear
local command = n.command
local eval = n.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 feed = n.feed
local feed_command = n.feed_command
local next_msg = n.next_msg
local api = n.api
local source = n.source
local pcall_err = t.pcall_err
before_each(function()

View File

@@ -1,15 +1,16 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local mkdir = t.mkdir
local clear = t.clear
local clear = n.clear
local eq = t.eq
local fn = t.fn
local api = t.api
local exc_exec = t.exc_exec
local fn = n.fn
local api = n.api
local exc_exec = n.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 command = n.command
local fname = 'Xtest-functional-eval-writefile'
local dname = fname .. '.d'