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

@ -46,7 +46,7 @@ if(DEFINED ENV{TEST_FILTER_OUT} AND NOT "$ENV{TEST_FILTER_OUT}" STREQUAL "")
list(APPEND BUSTED_ARGS --filter-out $ENV{TEST_FILTER_OUT}) list(APPEND BUSTED_ARGS --filter-out $ENV{TEST_FILTER_OUT})
endif() endif()
# TMPDIR: for helpers.tmpname() and Nvim tempname(). # TMPDIR: for testutil.tmpname() and Nvim tempname().
set(ENV{TMPDIR} "${BUILD_DIR}/Xtest_tmpdir") set(ENV{TMPDIR} "${BUILD_DIR}/Xtest_tmpdir")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory $ENV{TMPDIR}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory $ENV{TMPDIR})
@ -57,7 +57,7 @@ if(NOT DEFINED ENV{TEST_TIMEOUT} OR "$ENV{TEST_TIMEOUT}" STREQUAL "")
set(ENV{TEST_TIMEOUT} 1200) set(ENV{TEST_TIMEOUT} 1200)
endif() endif()
set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/helpers.lua. set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/testutil.lua.
if(NOT WIN32) if(NOT WIN32)
# Tests assume POSIX "sh" and may fail if SHELL=fish. #24941 #6172 # Tests assume POSIX "sh" and may fail if SHELL=fish. #24941 #6172

View File

@ -88,7 +88,7 @@ Then, in another terminal:
gdb build/bin/nvim gdb build/bin/nvim
target remote localhost:7777 target remote localhost:7777
< <
- See also test/functional/helpers.lua https://github.com/neovim/neovim/blob/3098b18a2b63a841351f6d5e3697cb69db3035ef/test/functional/helpers.lua#L38-L44. - See also test/functional/testutil.lua https://github.com/neovim/neovim/blob/3098b18a2b63a841351f6d5e3697cb69db3035ef/test/functional/testutil.lua#L38-L44.
USING LLDB TO STEP THROUGH UNIT TESTS ~ USING LLDB TO STEP THROUGH UNIT TESTS ~

View File

@ -282,9 +282,9 @@ open my $spec_file_handle, ">", $spec_file;
print $spec_file_handle <<"EOS"; print $spec_file_handle <<"EOS";
@{[join "\n", @{$description_lines}]} @{[join "\n", @{$description_lines}]}
local helpers = require('test.functional.helpers') local t = require('test.functional.testutil')
local feed, insert, source = helpers.feed, helpers.insert, helpers.source local feed, insert, source = t.feed, t.insert, t.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect local clear, execute, expect = t.clear, t.execute, t.expect
describe('$test_name', function() describe('$test_name', function()
before_each(clear) before_each(clear)

View File

@ -44,9 +44,9 @@ Layout
parser: normally used to make macros not accessible via this mechanism parser: normally used to make macros not accessible via this mechanism
accessible the other way. accessible the other way.
- `/test/*/preload.lua` : modules preloaded by busted `--helper` option - `/test/*/preload.lua` : modules preloaded by busted `--helper` option
- `/test/**/helpers.lua` : common utility functions for test code - `/test/**/testutil.lua` : common utility functions for test code
- `/test/*/**/*_spec.lua` : actual tests. Files that do not end with - `/test/*/**/*_spec.lua` : actual tests. Files that do not end with
`_spec.lua` are libraries like `/test/**/helpers.lua`, except that they have `_spec.lua` are libraries like `/test/**/testutil.lua`, except that they have
some common topic. some common topic.
- `/test/old/testdir` : old tests (from Vim) - `/test/old/testdir` : old tests (from Vim)
@ -119,7 +119,7 @@ Debugging tests
If `$VALGRIND` is also set it will pass `--vgdb=yes` to valgrind instead of If `$VALGRIND` is also set it will pass `--vgdb=yes` to valgrind instead of
starting gdbserver directly. starting gdbserver directly.
See [test/functional/helpers.lua](https://github.com/neovim/neovim/blob/9cadbf1d36b63f53f0de48c8c5ff6c752ff05d70/test/functional/helpers.lua#L52-L69) for details. See [test/functional/testutil.lua](https://github.com/neovim/neovim/blob/9cadbf1d36b63f53f0de48c8c5ff6c752ff05d70/test/functional/testutil.lua#L52-L69) for details.
- Hanging tests can happen due to unexpected "press-enter" prompts. The - Hanging tests can happen due to unexpected "press-enter" prompts. The
default screen width is 50 columns. Commands that try to print lines longer default screen width is 50 columns. Commands that try to print lines longer
@ -218,7 +218,7 @@ Guidelines
- Luajit needs to know about type and constant declarations used in function - Luajit needs to know about type and constant declarations used in function
prototypes. The prototypes. The
[helpers.lua](https://github.com/neovim/neovim/blob/master/test/unit/helpers.lua) [testutil.lua](https://github.com/neovim/neovim/blob/master/test/unit/testutil.lua)
file automatically parses `types.h`, so types used in the tested functions file automatically parses `types.h`, so types used in the tested functions
could be moved to it to avoid having to rewrite the declarations in the test could be moved to it to avoid having to rewrite the declarations in the test
files. files.
@ -297,7 +297,7 @@ Number; !must be defined to function properly):
- `VALGRIND` (F) (D): makes nvim instances to be run under `valgrind`. Log - `VALGRIND` (F) (D): makes nvim instances to be run under `valgrind`. Log
files are named `valgrind-%p.log` in this case. Note that non-empty valgrind files are named `valgrind-%p.log` in this case. Note that non-empty valgrind
log may fail tests. Valgrind arguments may be seen in log may fail tests. Valgrind arguments may be seen in
`/test/functional/helpers.lua`. May be used in conjunction with `GDB`. `/test/functional/testutil.lua`. May be used in conjunction with `GDB`.
- `VALGRIND_LOG` (F) (S): overrides valgrind log file name used for `VALGRIND`. - `VALGRIND_LOG` (F) (S): overrides valgrind log file name used for `VALGRIND`.

View File

@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local N = 7500 local N = 7500

View File

@ -1,8 +1,8 @@
-- Test for benchmarking the RE engine. -- Test for benchmarking the RE engine.
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local insert, source = helpers.insert, helpers.source local insert, source = t.insert, t.source
local clear, command = helpers.clear, helpers.command local clear, command = t.clear, t.command
-- Temporary file for gathering benchmarking results for each regexp engine. -- Temporary file for gathering benchmarking results for each regexp engine.
local result_file = 'benchmark.out' local result_file = 'benchmark.out'

View File

@ -1,4 +1,4 @@
-- Modules loaded here will not be cleared and reloaded by Busted. -- Modules loaded here will not be cleared and reloaded by Busted.
-- Busted started doing this to help provide more isolation. See issue #62 -- Busted started doing this to help provide more isolation. See issue #62
-- for more information about this. -- for more information about this.
local helpers = require('test.functional.helpers') local t = require('test.functional.testutil')

View File

@ -1,5 +1,5 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local api = helpers.api local api = t.api
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local function rand_utf8(count, seed) local function rand_utf8(count, seed)
@ -78,7 +78,7 @@ local N = 10000
local function benchmark(lines, expected_value) local function benchmark(lines, expected_value)
local lnum = #lines local lnum = #lines
local results = helpers.exec_lua( local results = t.exec_lua(
[==[ [==[
local N, lnum = ... local N, lnum = ...
@ -99,7 +99,7 @@ local function benchmark(lines, expected_value)
) )
for _, value in ipairs(results[1]) do for _, value in ipairs(results[1]) do
helpers.eq(expected_value, value) t.eq(expected_value, value)
end end
local stats = results[2] local stats = results[2]
table.sort(stats) table.sort(stats)
@ -119,7 +119,7 @@ end
local function benchmarks(benchmark_results) local function benchmarks(benchmark_results)
describe('screenpos() perf', function() describe('screenpos() perf', function()
before_each(helpers.clear) before_each(t.clear)
-- no breakindent -- no breakindent
for li, lines_type in ipairs(benchmark_lines) do for li, lines_type in ipairs(benchmark_lines) do
@ -134,7 +134,7 @@ local function benchmarks(benchmark_results)
screen:attach() screen:attach()
api.nvim_buf_set_lines(0, 0, 1, false, lines) api.nvim_buf_set_lines(0, 0, 1, false, lines)
-- for smaller screen expect (last line always different, first line same as others) -- for smaller screen expect (last line always different, first line same as others)
helpers.feed('G$') t.feed('G$')
screen:expect(result.screen) screen:expect(result.screen)
benchmark(lines, result.value) benchmark(lines, result.value)
end) end)
@ -153,9 +153,9 @@ local function benchmarks(benchmark_results)
local screen = Screen.new(width, height + 1) local screen = Screen.new(width, height + 1)
screen:attach() screen:attach()
api.nvim_buf_set_lines(0, 0, 1, false, lines) api.nvim_buf_set_lines(0, 0, 1, false, lines)
helpers.command('set breakindent') t.command('set breakindent')
-- for smaller screen expect (last line always different, first line same as others) -- for smaller screen expect (last line always different, first line same as others)
helpers.feed('G$') t.feed('G$')
screen:expect(result.screen) screen:expect(result.screen)
benchmark(lines, result.value) benchmark(lines, result.value)
end) end)

View File

@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
describe('treesitter perf', function() describe('treesitter perf', function()
setup(function() setup(function()
@ -9,7 +9,7 @@ describe('treesitter perf', function()
end) end)
it('can handle large folds', function() it('can handle large folds', function()
helpers.command 'edit ./src/nvim/eval.c' t.command 'edit ./src/nvim/eval.c'
exec_lua [[ exec_lua [[
local parser = vim.treesitter.get_parser(0, "c", {}) local parser = vim.treesitter.get_parser(0, "c", {})
vim.treesitter.highlighter.new(parser) vim.treesitter.highlighter.new(parser)

View File

@ -1,13 +1,13 @@
-- Extends the upstream TAP handler, to display the log with suiteEnd. -- Extends the upstream TAP handler, to display the log with suiteEnd.
local global_helpers = require('test.helpers') local t_global = require('test.testutil')
return function(options) return function(options)
local busted = require 'busted' local busted = require 'busted'
local handler = require 'busted.outputHandlers.TAP'(options) local handler = require 'busted.outputHandlers.TAP'(options)
local suiteEnd = function() local suiteEnd = function()
io.write(global_helpers.read_nvim_log(nil, true)) io.write(t_global.read_nvim_log(nil, true))
return nil, true return nil, true
end end
busted.subscribe({ 'suite', 'end' }, suiteEnd) busted.subscribe({ 'suite', 'end' }, suiteEnd)

View File

@ -1,5 +1,5 @@
local pretty = require 'pl.pretty' local pretty = require 'pl.pretty'
local global_helpers = require('test.helpers') local t_global = require('test.testutil')
local colors = setmetatable({}, { local colors = setmetatable({}, {
__index = function() __index = function()
@ -236,7 +236,7 @@ return function(options)
io.write(suiteEndString:format(testCount, tests, fileCount, files, elapsedTime_ms)) io.write(suiteEndString:format(testCount, tests, fileCount, files, elapsedTime_ms))
io.write(getSummaryString()) io.write(getSummaryString())
if failureCount > 0 or errorCount > 0 then if failureCount > 0 or errorCount > 0 then
io.write(global_helpers.read_nvim_log(nil, true)) io.write(t_global.read_nvim_log(nil, true))
end end
io.flush() io.flush()

View File

@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local neq = helpers.neq local neq = t.neq
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local matches = helpers.matches local matches = t.matches
local api = helpers.api local api = t.api
local source = helpers.source local source = t.source
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
before_each(clear) before_each(clear)

View File

@ -1,21 +1,21 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local ok = helpers.ok local ok = t.ok
local describe_lua_and_rpc = helpers.describe_lua_and_rpc(describe) local describe_lua_and_rpc = t.describe_lua_and_rpc(describe)
local api = helpers.api local api = t.api
local fn = helpers.fn local fn = t.fn
local request = helpers.request local request = t.request
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local feed_command = helpers.feed_command local feed_command = t.feed_command
local insert = helpers.insert local insert = t.insert
local NIL = vim.NIL local NIL = vim.NIL
local command = helpers.command local command = t.command
local feed = helpers.feed local feed = t.feed
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
describe('api/buf', function() describe('api/buf', function()
before_each(clear) before_each(clear)

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 clear = t.clear
local eq, ok = helpers.eq, helpers.ok local eq, ok = t.eq, t.ok
local fn = helpers.fn local fn = t.fn
local api = helpers.api local api = t.api
local command, eval, next_msg = helpers.command, helpers.eval, helpers.next_msg local command, eval, next_msg = t.command, t.eval, t.next_msg
local nvim_prog = helpers.nvim_prog local nvim_prog = t.nvim_prog
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local sleep = vim.uv.sleep local sleep = vim.uv.sleep
local write_file = helpers.write_file local write_file = t.write_file
local origlines = { local origlines = {
'original line 1', 'original line 1',
@ -34,7 +34,7 @@ local function sendkeys(keys)
end end
local function open(activate, lines) local function open(activate, lines)
local filename = helpers.tmpname() local filename = t.tmpname()
write_file(filename, table.concat(lines, '\n') .. '\n', true) write_file(filename, table.concat(lines, '\n') .. '\n', true)
command('edit ' .. filename) command('edit ' .. filename)
local b = api.nvim_get_current_buf() local b = api.nvim_get_current_buf()
@ -511,11 +511,11 @@ describe('API: buffer events:', function()
-- create several new sessions, in addition to our main API -- create several new sessions, in addition to our main API
local sessions = {} local sessions = {}
local pipe = helpers.new_pipename() local pipe = t.new_pipename()
eval("serverstart('" .. pipe .. "')") eval("serverstart('" .. pipe .. "')")
sessions[1] = helpers.connect(pipe) sessions[1] = t.connect(pipe)
sessions[2] = helpers.connect(pipe) sessions[2] = t.connect(pipe)
sessions[3] = helpers.connect(pipe) sessions[3] = t.connect(pipe)
local function request(sessionnr, method, ...) local function request(sessionnr, method, ...)
local status, rv = sessions[sessionnr]:request(method, ...) local status, rv = sessions[sessionnr]:request(method, ...)
@ -814,7 +814,7 @@ describe('API: buffer events:', function()
clear() clear()
sleep(250) sleep(250)
-- response -- response
eq(true, helpers.request('nvim_buf_attach', 0, false, {})) eq(true, t.request('nvim_buf_attach', 0, false, {}))
-- notification -- notification
eq({ eq({
[1] = 'notification', [1] = 'notification',

View File

@ -1,17 +1,17 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local NIL = vim.NIL local NIL = vim.NIL
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local api = helpers.api local api = t.api
local matches = helpers.matches local matches = t.matches
local source = helpers.source local source = t.source
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local feed = helpers.feed local feed = t.feed
local fn = helpers.fn local fn = t.fn
describe('nvim_get_commands', function() describe('nvim_get_commands', function()
local cmd_dict = { local cmd_dict = {

View File

@ -1,20 +1,20 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local request = helpers.request local request = t.request
local eq = helpers.eq local eq = t.eq
local ok = helpers.ok local ok = t.ok
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local insert = helpers.insert local insert = t.insert
local feed = helpers.feed local feed = t.feed
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local exec = helpers.exec local exec = t.exec
local api = helpers.api local api = t.api
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local function expect(contents) local function expect(contents)
return eq(contents, helpers.curbuf_contents()) return eq(contents, t.curbuf_contents())
end end
local function set_extmark(ns_id, id, line, col, opts) local function set_extmark(ns_id, id, line, col, opts)

View File

@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local eq, eval = helpers.eq, helpers.eval local eq, eval = t.eq, t.eval
local command = helpers.command local command = t.command
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
local api = helpers.api local api = t.api
local fn = helpers.fn local fn = t.fn
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local ok = helpers.ok local ok = t.ok
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
describe('API: highlight', function() describe('API: highlight', function()
clear() clear()

View File

@ -1,17 +1,17 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq, neq = helpers.eq, helpers.neq local eq, neq = t.eq, t.neq
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local exec = helpers.exec local exec = t.exec
local feed = helpers.feed local feed = t.feed
local fn = helpers.fn local fn = t.fn
local api = helpers.api local api = t.api
local source = helpers.source local source = t.source
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local shallowcopy = helpers.shallowcopy local shallowcopy = t.shallowcopy
local sleep = vim.uv.sleep local sleep = vim.uv.sleep
local sid_api_client = -9 local sid_api_client = -9
@ -1114,7 +1114,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('asdf\n') feed('asdf\n')
eq(1, exec_lua [[return GlobalCount]]) eq(1, exec_lua [[return GlobalCount]])
eq('\nNo mapping found', helpers.exec_capture('nmap asdf')) eq('\nNo mapping found', t.exec_capture('nmap asdf'))
end) end)
it('no double-free when unmapping simplifiable lua mappings', function() it('no double-free when unmapping simplifiable lua mappings', function()
@ -1138,13 +1138,13 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('<C-I>\n') feed('<C-I>\n')
eq(1, exec_lua [[return GlobalCount]]) eq(1, exec_lua [[return GlobalCount]])
eq('\nNo mapping found', helpers.exec_capture('nmap <C-I>')) eq('\nNo mapping found', t.exec_capture('nmap <C-I>'))
end) end)
it('can set descriptions on mappings', function() it('can set descriptions on mappings', function()
api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' }) api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
eq(generate_mapargs('n', 'lhs', 'rhs', { desc = 'map description' }), get_mapargs('n', 'lhs')) eq(generate_mapargs('n', 'lhs', 'rhs', { desc = 'map description' }), get_mapargs('n', 'lhs'))
eq('\nn lhs rhs\n map description', helpers.exec_capture('nmap lhs')) eq('\nn lhs rhs\n map description', t.exec_capture('nmap lhs'))
end) end)
it('can define !-mode abbreviations with lua callbacks', function() it('can define !-mode abbreviations with lua callbacks', function()
@ -1290,7 +1290,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
it('does not crash when setting mapping in a non-existing buffer #13541', function() it('does not crash when setting mapping in a non-existing buffer #13541', function()
pcall_err(api.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {}) pcall_err(api.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {})
helpers.assert_alive() t.assert_alive()
end) end)
it('can make lua mappings', function() it('can make lua mappings', function()
@ -1372,7 +1372,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
feed('asdf\n') feed('asdf\n')
eq(1, exec_lua [[return GlobalCount]]) eq(1, exec_lua [[return GlobalCount]])
eq('\nNo mapping found', helpers.exec_capture('nmap asdf')) eq('\nNo mapping found', t.exec_capture('nmap asdf'))
end) end)
it('no double-free when unmapping simplifiable lua mappings', function() it('no double-free when unmapping simplifiable lua mappings', function()
@ -1396,6 +1396,6 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
feed('<C-I>\n') feed('<C-I>\n')
eq(1, exec_lua [[return GlobalCount]]) eq(1, exec_lua [[return GlobalCount]])
eq('\nNo mapping found', helpers.exec_capture('nmap <C-I>')) eq('\nNo mapping found', t.exec_capture('nmap <C-I>'))
end) end)
end) end)

View File

@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local feed = helpers.feed local feed = t.feed
describe('update_menu notification', function() describe('update_menu notification', function()
local screen local screen

View File

@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local fn = helpers.fn local fn = t.fn
local neq = helpers.neq local neq = t.neq
local nvim_argv = helpers.nvim_argv local nvim_argv = t.nvim_argv
local request = helpers.request local request = t.request
local retry = helpers.retry local retry = t.retry
local NIL = vim.NIL local NIL = vim.NIL
local is_os = helpers.is_os local is_os = t.is_os
describe('API', function() describe('API', function()
before_each(clear) before_each(clear)

View File

@ -1,12 +1,11 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local assert_log = helpers.assert_log local assert_log = t.assert_log
local eq, clear, eval, command, next_msg = local eq, clear, eval, command, next_msg = t.eq, t.clear, t.eval, t.command, t.next_msg
helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.next_msg local api = t.api
local api = helpers.api local exec_lua = t.exec_lua
local exec_lua = helpers.exec_lua local retry = t.retry
local retry = helpers.retry local assert_alive = t.assert_alive
local assert_alive = helpers.assert_alive local check_close = t.check_close
local check_close = helpers.check_close
local testlog = 'Xtest-server-notify-log' local testlog = 'Xtest-server-notify-log'

View File

@ -1,17 +1,17 @@
-- Test server -> client RPC scenarios. Note: unlike `rpcnotify`, to evaluate -- Test server -> client RPC scenarios. Note: unlike `rpcnotify`, to evaluate
-- `rpcrequest` calls we need the client event loop to be running. -- `rpcrequest` calls we need the client event loop to be running.
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, eval = helpers.clear, helpers.eval local clear, eval = t.clear, t.eval
local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop local eq, neq, run, stop = t.eq, t.neq, t.run, t.stop
local nvim_prog, command, fn = helpers.nvim_prog, helpers.command, helpers.fn local nvim_prog, command, fn = t.nvim_prog, t.command, t.fn
local source, next_msg = helpers.source, helpers.next_msg local source, next_msg = t.source, t.next_msg
local ok = helpers.ok local ok = t.ok
local api = helpers.api local api = t.api
local spawn, merge_args = helpers.spawn, helpers.merge_args local spawn, merge_args = t.spawn, t.merge_args
local set_session = helpers.set_session local set_session = t.set_session
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
describe('server -> client', function() describe('server -> client', function()
local cid local cid
@ -259,7 +259,7 @@ describe('server -> client', function()
pcall(fn.jobstop, jobid) pcall(fn.jobstop, jobid)
end) end)
if helpers.skip(helpers.is_os('win')) then if t.skip(t.is_os('win')) then
return return
end end
@ -280,7 +280,7 @@ describe('server -> client', function()
end) end)
describe('connecting to another (peer) nvim', function() describe('connecting to another (peer) nvim', function()
local nvim_argv = merge_args(helpers.nvim_argv, { '--headless' }) local nvim_argv = merge_args(t.nvim_argv, { '--headless' })
local function connect_test(server, mode, address) local function connect_test(server, mode, address)
local serverpid = fn.getpid() local serverpid = fn.getpid()
local client = spawn(nvim_argv, false, nil, true) local client = spawn(nvim_argv, false, nil, true)

View File

@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok local clear, eq, ok = t.clear, t.eq, t.ok
local exec = helpers.exec local exec = t.exec
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
local fn = helpers.fn local fn = t.fn
local request = helpers.request local request = t.request
local NIL = vim.NIL local NIL = vim.NIL
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local command = helpers.command local command = t.command
describe('api/tabpage', function() describe('api/tabpage', function()
before_each(clear) 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 Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local exec = helpers.exec local exec = t.exec
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
local request = helpers.request local request = t.request
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
describe('nvim_ui_attach()', function() describe('nvim_ui_attach()', function()
before_each(function() before_each(function()

View File

@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, fn, eq = helpers.clear, helpers.fn, helpers.eq local clear, fn, eq = t.clear, t.fn, t.eq
local api = helpers.api local api = t.api
local function read_mpack_file(fname) local function read_mpack_file(fname)
local fd = io.open(fname, 'rb') local fd = io.open(fname, 'rb')

View File

@ -1,42 +1,42 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local uv = vim.uv local uv = vim.uv
local fmt = string.format local fmt = string.format
local dedent = helpers.dedent local dedent = t.dedent
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local NIL = vim.NIL local NIL = vim.NIL
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq local clear, eq, neq = t.clear, t.eq, t.neq
local command = helpers.command local command = t.command
local command_output = helpers.api.nvim_command_output local command_output = t.api.nvim_command_output
local exec = helpers.exec local exec = t.exec
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
local eval = helpers.eval local eval = t.eval
local expect = helpers.expect local expect = t.expect
local fn = helpers.fn local fn = t.fn
local api = helpers.api local api = t.api
local matches = helpers.matches local matches = t.matches
local pesc = vim.pesc local pesc = vim.pesc
local mkdir_p = helpers.mkdir_p local mkdir_p = t.mkdir_p
local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed local ok, nvim_async, feed = t.ok, t.nvim_async, t.feed
local async_meths = helpers.async_meths local async_meths = t.async_meths
local is_os = helpers.is_os local is_os = t.is_os
local parse_context = helpers.parse_context local parse_context = t.parse_context
local request = helpers.request local request = t.request
local rmdir = helpers.rmdir local rmdir = t.rmdir
local source = helpers.source local source = t.source
local next_msg = helpers.next_msg local next_msg = t.next_msg
local tmpname = helpers.tmpname local tmpname = t.tmpname
local write_file = helpers.write_file local write_file = t.write_file
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local insert = helpers.insert local insert = t.insert
local skip = helpers.skip local skip = t.skip
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local format_string = require('test.format_string').format_string local format_string = require('test.format_string').format_string
local intchar2lua = helpers.intchar2lua local intchar2lua = t.intchar2lua
local mergedicts_copy = helpers.mergedicts_copy local mergedicts_copy = t.mergedicts_copy
local endswith = vim.endswith local endswith = vim.endswith
describe('API', function() describe('API', function()
@ -702,12 +702,12 @@ describe('API', function()
end) end)
after_each(function() after_each(function()
helpers.rmdir('Xtestdir') t.rmdir('Xtestdir')
end) end)
it('works', function() it('works', function()
api.nvim_set_current_dir('Xtestdir') api.nvim_set_current_dir('Xtestdir')
eq(start_dir .. helpers.get_pathsep() .. 'Xtestdir', fn.getcwd()) eq(start_dir .. t.get_pathsep() .. 'Xtestdir', fn.getcwd())
end) end)
it('sets previous directory', function() it('sets previous directory', function()
@ -1467,7 +1467,7 @@ describe('API', function()
eq(NIL, api.nvim_get_var('Unknown_script_func')) eq(NIL, api.nvim_get_var('Unknown_script_func'))
-- Check if autoload works properly -- Check if autoload works properly
local pathsep = helpers.get_pathsep() local pathsep = t.get_pathsep()
local xconfig = 'Xhome' .. pathsep .. 'Xconfig' local xconfig = 'Xhome' .. pathsep .. 'Xconfig'
local xdata = 'Xhome' .. pathsep .. 'Xdata' local xdata = 'Xhome' .. pathsep .. 'Xdata'
local autoload_folder = table.concat({ xconfig, 'nvim', 'autoload' }, pathsep) local autoload_folder = table.concat({ xconfig, 'nvim', 'autoload' }, pathsep)
@ -1951,7 +1951,7 @@ describe('API', function()
describe('RPC (K_EVENT)', function() describe('RPC (K_EVENT)', function()
it('does not complete ("interrupt") normal-mode operator-pending #6166', function() it('does not complete ("interrupt") normal-mode operator-pending #6166', function()
helpers.insert([[ t.insert([[
FIRST LINE FIRST LINE
SECOND LINE]]) SECOND LINE]])
api.nvim_input('gg') api.nvim_input('gg')
@ -1988,7 +1988,7 @@ describe('API', function()
it('does not complete ("interrupt") normal-mode map-pending #6166', function() it('does not complete ("interrupt") normal-mode map-pending #6166', function()
command("nnoremap dd :let g:foo='it worked...'<CR>") command("nnoremap dd :let g:foo='it worked...'<CR>")
helpers.insert([[ t.insert([[
FIRST LINE FIRST LINE
SECOND LINE]]) SECOND LINE]])
api.nvim_input('gg') api.nvim_input('gg')
@ -2000,13 +2000,13 @@ describe('API', function()
expect([[ expect([[
FIRST LINE FIRST LINE
SECOND LINE]]) SECOND LINE]])
eq('it worked...', helpers.eval('g:foo')) eq('it worked...', t.eval('g:foo'))
end) end)
it('does not complete ("interrupt") insert-mode map-pending #6166', function() it('does not complete ("interrupt") insert-mode map-pending #6166', function()
command('inoremap xx foo') command('inoremap xx foo')
command('set timeoutlen=9999') command('set timeoutlen=9999')
helpers.insert([[ t.insert([[
FIRST LINE FIRST LINE
SECOND LINE]]) SECOND LINE]])
api.nvim_input('ix') api.nvim_input('ix')
@ -2153,35 +2153,32 @@ describe('API', function()
describe('nvim_replace_termcodes', function() describe('nvim_replace_termcodes', function()
it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function() it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function()
eq('\128\254X', helpers.api.nvim_replace_termcodes('\128', true, true, true)) eq('\128\254X', t.api.nvim_replace_termcodes('\128', true, true, true))
end) end)
it('leaves non-K_SPECIAL string unchanged', function() it('leaves non-K_SPECIAL string unchanged', function()
eq('abc', helpers.api.nvim_replace_termcodes('abc', true, true, true)) eq('abc', t.api.nvim_replace_termcodes('abc', true, true, true))
end) end)
it('converts <expressions>', function() it('converts <expressions>', function()
eq('\\', helpers.api.nvim_replace_termcodes('<Leader>', true, true, true)) eq('\\', t.api.nvim_replace_termcodes('<Leader>', true, true, true))
end) end)
it('converts <LeftMouse> to K_SPECIAL KS_EXTRA KE_LEFTMOUSE', function() it('converts <LeftMouse> to K_SPECIAL KS_EXTRA KE_LEFTMOUSE', function()
-- K_SPECIAL KS_EXTRA KE_LEFTMOUSE -- K_SPECIAL KS_EXTRA KE_LEFTMOUSE
-- 0x80 0xfd 0x2c -- 0x80 0xfd 0x2c
-- 128 253 44 -- 128 253 44
eq('\128\253\44', helpers.api.nvim_replace_termcodes('<LeftMouse>', true, true, true)) eq('\128\253\44', t.api.nvim_replace_termcodes('<LeftMouse>', true, true, true))
end) end)
it('converts keycodes', function() it('converts keycodes', function()
eq( eq('\nx\27x\rx<x', t.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true))
'\nx\27x\rx<x',
helpers.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true)
)
end) end)
it('does not convert keycodes if special=false', function() it('does not convert keycodes if special=false', function()
eq( eq(
'<NL>x<Esc>x<CR>x<lt>x', '<NL>x<Esc>x<CR>x<lt>x',
helpers.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false) t.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false)
) )
end) end)
@ -2210,18 +2207,18 @@ describe('API', function()
api.nvim_feedkeys(':let x1="…"\n', '', true) api.nvim_feedkeys(':let x1="…"\n', '', true)
-- Both nvim_replace_termcodes and nvim_feedkeys escape \x80 -- Both nvim_replace_termcodes and nvim_feedkeys escape \x80
local inp = helpers.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true) local inp = t.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true)
api.nvim_feedkeys(inp, '', true) -- escape_ks=true api.nvim_feedkeys(inp, '', true) -- escape_ks=true
-- nvim_feedkeys with K_SPECIAL escaping disabled -- nvim_feedkeys with K_SPECIAL escaping disabled
inp = helpers.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true) inp = t.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true)
api.nvim_feedkeys(inp, '', false) -- escape_ks=false api.nvim_feedkeys(inp, '', false) -- escape_ks=false
helpers.stop() t.stop()
end end
-- spin the loop a bit -- spin the loop a bit
helpers.run(nil, nil, on_setup) t.run(nil, nil, on_setup)
eq('', api.nvim_get_var('x1')) eq('', api.nvim_get_var('x1'))
-- Because of the double escaping this is neq -- Because of the double escaping this is neq
@ -2364,7 +2361,7 @@ describe('API', function()
{0:~ }|*6 {0:~ }|*6
{1:very fail} | {1:very fail} |
]]) ]])
helpers.poke_eventloop() t.poke_eventloop()
-- shows up to &cmdheight lines -- shows up to &cmdheight lines
async_meths.nvim_err_write('more fail\ntoo fail\n') async_meths.nvim_err_write('more fail\ntoo fail\n')
@ -2676,7 +2673,7 @@ describe('API', function()
describe('nvim_list_runtime_paths', function() describe('nvim_list_runtime_paths', function()
setup(function() setup(function()
local pathsep = helpers.get_pathsep() local pathsep = t.get_pathsep()
mkdir_p('Xtest' .. pathsep .. 'a') mkdir_p('Xtest' .. pathsep .. 'a')
mkdir_p('Xtest' .. pathsep .. 'b') mkdir_p('Xtest' .. pathsep .. 'b')
end) end)
@ -3183,7 +3180,7 @@ describe('API', function()
end) end)
describe('nvim_get_runtime_file', function() describe('nvim_get_runtime_file', function()
local p = helpers.alter_slashes local p = t.alter_slashes
it('can find files', function() it('can find files', function()
eq({}, api.nvim_get_runtime_file('bork.borkbork', false)) eq({}, api.nvim_get_runtime_file('bork.borkbork', false))
eq({}, api.nvim_get_runtime_file('bork.borkbork', true)) eq({}, api.nvim_get_runtime_file('bork.borkbork', true))
@ -3410,13 +3407,13 @@ describe('API', function()
{desc="(global option, fallback requested) points to global", linenr=9, sid=1, args={'completeopt', {}}}, {desc="(global option, fallback requested) points to global", linenr=9, sid=1, args={'completeopt', {}}},
} }
for _, t in pairs(tests) do for _, test in pairs(tests) do
it(t.desc, function() it(test.desc, function()
-- Switch to the target buffer/window so that curbuf/curwin are used. -- Switch to the target buffer/window so that curbuf/curwin are used.
api.nvim_set_current_win(wins[2]) api.nvim_set_current_win(wins[2])
local info = api.nvim_get_option_info2(unpack(t.args)) local info = api.nvim_get_option_info2(unpack(test.args))
eq(t.linenr, info.last_set_linenr) eq(test.linenr, info.last_set_linenr)
eq(t.sid, info.last_set_sid) eq(test.sid, info.last_set_sid)
end) end)
end end
@ -3537,9 +3534,9 @@ describe('API', function()
false, false,
{ width = 79, height = 31, row = 1, col = 1, relative = 'editor' } { width = 79, height = 31, row = 1, col = 1, relative = 'editor' }
) )
local t = api.nvim_open_term(b, {}) local term = api.nvim_open_term(b, {})
api.nvim_chan_send(t, io.open('test/functional/fixtures/smile2.cat', 'r'):read('*a')) api.nvim_chan_send(term, io.open('test/functional/fixtures/smile2.cat', 'r'):read('*a'))
screen:expect { screen:expect {
grid = [[ grid = [[
^ | ^ |

View File

@ -1,27 +1,27 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear, curbuf, curbuf_contents, curwin, eq, neq, matches, ok, feed, insert, eval = local clear, curbuf, curbuf_contents, curwin, eq, neq, matches, ok, feed, insert, eval =
helpers.clear, t.clear,
helpers.api.nvim_get_current_buf, t.api.nvim_get_current_buf,
helpers.curbuf_contents, t.curbuf_contents,
helpers.api.nvim_get_current_win, t.api.nvim_get_current_win,
helpers.eq, t.eq,
helpers.neq, t.neq,
helpers.matches, t.matches,
helpers.ok, t.ok,
helpers.feed, t.feed,
helpers.insert, t.insert,
helpers.eval t.eval
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = t.poke_eventloop
local exec = helpers.exec local exec = t.exec
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local fn = helpers.fn local fn = t.fn
local request = helpers.request local request = t.request
local NIL = vim.NIL local NIL = vim.NIL
local api = helpers.api local api = t.api
local command = helpers.command local command = t.command
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
describe('API/win', function() describe('API/win', function()
before_each(clear) before_each(clear)
@ -1297,7 +1297,7 @@ describe('API/win', function()
local tab1 = api.nvim_get_current_tabpage() local tab1 = api.nvim_get_current_tabpage()
local tab1_win = api.nvim_get_current_win() local tab1_win = api.nvim_get_current_win()
helpers.command('tabnew') t.command('tabnew')
local tab2 = api.nvim_get_current_tabpage() local tab2 = api.nvim_get_current_tabpage()
local tab2_win = api.nvim_get_current_win() local tab2_win = api.nvim_get_current_win()

View File

@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local api = helpers.api local api = t.api
local fn = helpers.fn local fn = t.fn
local exec = helpers.exec local exec = t.exec
local feed = helpers.feed local feed = t.feed
local assert_log = helpers.assert_log local assert_log = t.assert_log
local check_close = helpers.check_close local check_close = t.check_close
local is_os = helpers.is_os local is_os = t.is_os
local testlog = 'Xtest_autocmd_oldtest_log' local testlog = 'Xtest_autocmd_oldtest_log'

View File

@ -1,24 +1,24 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local assert_visible = helpers.assert_visible local assert_visible = t.assert_visible
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local dedent = helpers.dedent local dedent = t.dedent
local eq = helpers.eq local eq = t.eq
local neq = helpers.neq local neq = t.neq
local eval = helpers.eval local eval = t.eval
local feed = helpers.feed local feed = t.feed
local clear = helpers.clear local clear = t.clear
local matches = helpers.matches local matches = t.matches
local api = helpers.api local api = t.api
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local fn = helpers.fn local fn = t.fn
local expect = helpers.expect local expect = t.expect
local command = helpers.command local command = t.command
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local retry = helpers.retry local retry = t.retry
local source = helpers.source local source = t.source
describe('autocmd', function() describe('autocmd', function()
before_each(clear) 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 clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local request = helpers.request local request = t.request
local source = helpers.source local source = t.source
describe('autocmd BufEnter', function() describe('autocmd BufEnter', function()
before_each(clear) before_each(clear)
@ -33,7 +33,7 @@ describe('autocmd BufEnter', function()
end) end)
it('triggered by ":split normal|:help|:bw"', function() it('triggered by ":split normal|:help|:bw"', function()
helpers.add_builddir_to_rtp() t.add_builddir_to_rtp()
command('split normal') command('split normal')
command('wincmd j') command('wincmd j')
command('help') command('help')

View File

@ -1,10 +1,10 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local source = helpers.source local source = t.source
local request = helpers.request local request = t.request
describe('BufModified', function() describe('BufModified', function()
before_each(clear) 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 Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local expect = helpers.expect local expect = t.expect
local eval = helpers.eval local eval = t.eval
local next_msg = helpers.next_msg local next_msg = t.next_msg
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
describe('cmdline autocommands', function() describe('cmdline autocommands', function()
local channel local channel

View File

@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local feed = helpers.feed local feed = t.feed
local retry = helpers.retry local retry = t.retry
local exec = helpers.source local exec = t.source
local sleep = vim.uv.sleep local sleep = vim.uv.sleep
local api = helpers.api local api = t.api
before_each(clear) 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 clear = t.clear
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local api = helpers.api local api = t.api
local source = helpers.source local source = t.source
local command = helpers.command local command = t.command
describe('CursorMoved', function() describe('CursorMoved', function()
before_each(clear) 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 clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local request = helpers.request local request = t.request
local is_os = helpers.is_os local is_os = t.is_os
describe('autocmd DirChanged and DirChangedPre', function() describe('autocmd DirChanged and DirChangedPre', function()
local curdir = vim.uv.cwd():gsub('\\', '/') local curdir = vim.uv.cwd():gsub('\\', '/')
@ -22,12 +22,12 @@ describe('autocmd DirChanged and DirChangedPre', function()
setup(function() setup(function()
for _, dir in pairs(dirs) do for _, dir in pairs(dirs) do
helpers.mkdir(dir) t.mkdir(dir)
end end
end) end)
teardown(function() teardown(function()
for _, dir in pairs(dirs) do for _, dir in pairs(dirs) do
helpers.rmdir(dir) t.rmdir(dir)
end end
end) end)

View File

@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local eval = helpers.eval local eval = t.eval
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
describe('autocmd FileType', function() describe('autocmd FileType', function()
before_each(clear) before_each(clear)
it('is triggered by :help only once', function() it('is triggered by :help only once', function()
helpers.add_builddir_to_rtp() t.add_builddir_to_rtp()
command('let g:foo = 0') command('let g:foo = 0')
command('autocmd FileType help let g:foo = g:foo + 1') command('autocmd FileType help let g:foo = g:foo + 1')
command('help help') command('help help')

View File

@ -1,10 +1,10 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local thelpers = require('test.functional.terminal.helpers') local tt = require('test.functional.terminal.testutil')
local clear = helpers.clear local clear = t.clear
local feed_command = helpers.feed_command local feed_command = t.feed_command
local feed_data = thelpers.feed_data local feed_data = tt.feed_data
if helpers.skip(helpers.is_os('win')) then if t.skip(t.is_os('win')) then
return return
end end
@ -14,7 +14,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
before_each(function() before_each(function()
clear() clear()
screen = thelpers.setup_child_nvim({ screen = tt.setup_child_nvim({
'-u', '-u',
'NONE', 'NONE',
'-i', '-i',
@ -39,7 +39,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
line 4 line 4
]] ]]
helpers.write_file(path, '') t.write_file(path, '')
local atime = os.time() - 10 local atime = os.time() - 10
vim.uv.fs_utime(path, atime, atime) vim.uv.fs_utime(path, atime, atime)
@ -75,7 +75,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
unchanged = true, unchanged = true,
} }
helpers.write_file(path, expected_addition) t.write_file(path, expected_addition)
feed_data('\027[I') feed_data('\027[I')

View File

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

View File

@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local source_vim = helpers.source local source_vim = t.source
describe('RecordingEnter', function() describe('RecordingEnter', function()
before_each(clear) 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 clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local exec = helpers.exec local exec = t.exec
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
before_each(clear) 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 clear = t.clear
local command = helpers.command local command = t.command
local api = helpers.api local api = t.api
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local feed = helpers.feed local feed = t.feed
describe('autocmd SearchWrapped', function() describe('autocmd SearchWrapped', function()
before_each(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 Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local dedent = helpers.dedent local dedent = t.dedent
local eq = helpers.eq local eq = t.eq
local fn = helpers.fn local fn = t.fn
local eval = helpers.eval local eval = t.eval
local exec = helpers.exec local exec = t.exec
local feed = helpers.feed local feed = t.feed
describe(':autocmd', function() describe(':autocmd', function()
before_each(function() before_each(function()

View File

@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local fn = helpers.fn local fn = t.fn
local next_msg = helpers.next_msg local next_msg = t.next_msg
local is_os = helpers.is_os local is_os = t.is_os
local skip = helpers.skip local skip = t.skip
if skip(is_os('win'), 'Only applies to POSIX systems') then if skip(is_os('win'), 'Only applies to POSIX systems') then
return return

View File

@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, eq = helpers.clear, helpers.eq local clear, eq = t.clear, t.eq
local api = helpers.api local api = t.api
local command = helpers.command local command = t.command
describe('TabClosed', function() describe('TabClosed', function()
before_each(clear) 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 clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
describe('autocmd TabNew', function() describe('autocmd TabNew', function()
before_each(clear) before_each(clear)

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 clear = t.clear
local command = helpers.command local command = t.command
local dedent = helpers.dedent local dedent = t.dedent
local eval = helpers.eval local eval = t.eval
local eq = helpers.eq local eq = t.eq
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
describe('TabNewEntered', function() describe('TabNewEntered', function()
describe('au TabNewEntered', function() describe('au TabNewEntered', function()

View File

@ -1,17 +1,17 @@
local uv = vim.uv local uv = vim.uv
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local thelpers = require('test.functional.terminal.helpers') local tt = require('test.functional.terminal.testutil')
local clear, command, testprg = helpers.clear, helpers.command, helpers.testprg local clear, command, testprg = t.clear, t.command, t.testprg
local eval, eq, neq, retry = helpers.eval, helpers.eq, helpers.neq, helpers.retry local eval, eq, neq, retry = t.eval, t.eq, t.neq, t.retry
local matches = helpers.matches local matches = t.matches
local ok = helpers.ok local ok = t.ok
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local skip = helpers.skip local skip = t.skip
local is_os = helpers.is_os local is_os = t.is_os
describe('autocmd TermClose', function() describe('autocmd TermClose', function()
before_each(function() before_each(function()
@ -198,11 +198,11 @@ end)
describe('autocmd TextChangedT', function() describe('autocmd TextChangedT', function()
clear() clear()
local screen = thelpers.screen_setup() local screen = tt.screen_setup()
it('works', function() it('works', function()
command('autocmd TextChangedT * ++once let g:called = 1') command('autocmd TextChangedT * ++once let g:called = 1')
thelpers.feed_data('a') tt.feed_data('a')
retry(nil, nil, function() retry(nil, nil, function()
eq(1, api.nvim_get_var('called')) eq(1, api.nvim_get_var('called'))
end) end)
@ -210,7 +210,7 @@ describe('autocmd TextChangedT', function()
it('cannot delete terminal buffer', function() it('cannot delete terminal buffer', function()
command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]]) command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]])
thelpers.feed_data('a') tt.feed_data('a')
screen:expect({ any = 'E937: ' }) screen:expect({ any = 'E937: ' })
matches( matches(
'^E937: Attempt to delete a buffer that is in use: term://', '^E937: Attempt to delete a buffer that is in use: term://',

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 clear = t.clear
local exec = helpers.exec local exec = t.exec
local command = helpers.command local command = t.command
local feed = helpers.feed local feed = t.feed
local eq = helpers.eq local eq = t.eq
local neq = helpers.neq local neq = t.neq
local eval = helpers.eval local eval = t.eval
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = t.poke_eventloop
local write_file = helpers.write_file local write_file = t.write_file
-- oldtest: Test_ChangedP() -- oldtest: Test_ChangedP()
it('TextChangedI and TextChangedP autocommands', function() it('TextChangedI and TextChangedP autocommands', function()

View File

@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq local clear, eval, eq = t.clear, t.eval, t.eq
local feed, command, expect = helpers.feed, helpers.command, helpers.expect local feed, command, expect = t.feed, t.command, t.expect
local api, fn, neq = helpers.api, helpers.fn, helpers.neq local api, fn, neq = t.api, t.fn, t.neq
describe('TextYankPost', function() describe('TextYankPost', function()
before_each(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 Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local exec = helpers.exec local exec = t.exec
local command = helpers.command local command = t.command
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
before_each(clear) before_each(clear)

View File

@ -1,18 +1,17 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, eq, eval, next_msg, ok, source = local clear, eq, eval, next_msg, ok, source = t.clear, t.eq, t.eval, t.next_msg, t.ok, t.source
helpers.clear, helpers.eq, helpers.eval, helpers.next_msg, helpers.ok, helpers.source local command, fn, api = t.command, t.fn, t.api
local command, fn, api = helpers.command, helpers.fn, helpers.api local matches = t.matches
local matches = helpers.matches
local sleep = vim.uv.sleep local sleep = vim.uv.sleep
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv local spawn, nvim_argv = t.spawn, t.nvim_argv
local get_session, set_session = helpers.get_session, helpers.set_session local get_session, set_session = t.get_session, t.set_session
local nvim_prog = helpers.nvim_prog local nvim_prog = t.nvim_prog
local is_os = helpers.is_os local is_os = t.is_os
local retry = helpers.retry local retry = t.retry
local expect_twostreams = helpers.expect_twostreams local expect_twostreams = t.expect_twostreams
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local skip = helpers.skip local skip = t.skip
describe('channels', function() describe('channels', function()
local init = [[ local init = [[

View File

@ -1,24 +1,24 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local command = helpers.command local command = t.command
local feed_command = helpers.feed_command local feed_command = t.feed_command
local feed = helpers.feed local feed = t.feed
local eval = helpers.eval local eval = t.eval
local eq = helpers.eq local eq = t.eq
local run = helpers.run local run = t.run
local fn = helpers.fn local fn = t.fn
local nvim_prog = helpers.nvim_prog local nvim_prog = t.nvim_prog
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = t.poke_eventloop
describe('v:exiting', function() describe('v:exiting', function()
local cid local cid
before_each(function() before_each(function()
helpers.clear() t.clear()
cid = helpers.api.nvim_get_chan_info(0).id cid = t.api.nvim_get_chan_info(0).id
end) end)
it('defaults to v:null', function() it('defaults to v:null', function()
@ -74,7 +74,7 @@ describe(':cquit', function()
end end
before_each(function() before_each(function()
helpers.clear() t.clear()
end) end)
it('exits with non-zero after :cquit', function() it('exits with non-zero after :cquit', function()

View File

@ -1,37 +1,37 @@
local uv = vim.uv local uv = vim.uv
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local assert_log = helpers.assert_log local assert_log = t.assert_log
local assert_nolog = helpers.assert_nolog local assert_nolog = t.assert_nolog
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local neq = helpers.neq local neq = t.neq
local ok = helpers.ok local ok = t.ok
local feed = helpers.feed local feed = t.feed
local fn = helpers.fn local fn = t.fn
local nvim_prog = helpers.nvim_prog local nvim_prog = t.nvim_prog
local request = helpers.request local request = t.request
local retry = helpers.retry local retry = t.retry
local rmdir = helpers.rmdir local rmdir = t.rmdir
local matches = helpers.matches local matches = t.matches
local api = helpers.api local api = t.api
local mkdir = helpers.mkdir local mkdir = t.mkdir
local sleep = vim.uv.sleep local sleep = vim.uv.sleep
local read_file = helpers.read_file local read_file = t.read_file
local trim = vim.trim local trim = vim.trim
local currentdir = helpers.fn.getcwd local currentdir = t.fn.getcwd
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local check_close = helpers.check_close local check_close = t.check_close
local expect_exit = helpers.expect_exit local expect_exit = t.expect_exit
local write_file = helpers.write_file local write_file = t.write_file
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local feed_command = helpers.feed_command local feed_command = t.feed_command
local skip = helpers.skip local skip = t.skip
local is_os = helpers.is_os local is_os = t.is_os
local is_ci = helpers.is_ci local is_ci = t.is_ci
local spawn = helpers.spawn local spawn = t.spawn
local set_session = helpers.set_session local set_session = t.set_session
describe('fileio', function() describe('fileio', function()
before_each(function() end) before_each(function() end)
@ -228,7 +228,7 @@ describe('fileio', function()
local initial_content = 'foo' local initial_content = 'foo'
local backup_dir = 'Xtest_backupdir' local backup_dir = 'Xtest_backupdir'
local sep = helpers.get_pathsep() local sep = t.get_pathsep()
local link_file_name = 'Xtest_startup_file2' local link_file_name = 'Xtest_startup_file2'
local backup_file_name = backup_dir .. sep .. link_file_name .. '~' local backup_file_name = backup_dir .. sep .. link_file_name .. '~'
@ -329,7 +329,7 @@ describe('tmpdir', function()
before_each(function() before_each(function()
-- Fake /tmp dir so that we can mess it up. -- 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) end)
after_each(function() after_each(function()

View File

@ -1,40 +1,40 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local thelpers = require('test.functional.terminal.helpers') local tt = require('test.functional.terminal.testutil')
local clear = helpers.clear local clear = t.clear
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local feed_command = helpers.feed_command local feed_command = t.feed_command
local feed = helpers.feed local feed = t.feed
local insert = helpers.insert local insert = t.insert
local neq = helpers.neq local neq = t.neq
local next_msg = helpers.next_msg local next_msg = t.next_msg
local testprg = helpers.testprg local testprg = t.testprg
local ok = helpers.ok local ok = t.ok
local source = helpers.source local source = t.source
local write_file = helpers.write_file local write_file = t.write_file
local mkdir = helpers.mkdir local mkdir = t.mkdir
local rmdir = helpers.rmdir local rmdir = t.rmdir
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local command = helpers.command local command = t.command
local fn = helpers.fn local fn = t.fn
local os_kill = helpers.os_kill local os_kill = t.os_kill
local retry = helpers.retry local retry = t.retry
local api = helpers.api local api = t.api
local NIL = vim.NIL local NIL = vim.NIL
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = t.poke_eventloop
local get_pathsep = helpers.get_pathsep local get_pathsep = t.get_pathsep
local pathroot = helpers.pathroot local pathroot = t.pathroot
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local nvim_set = helpers.nvim_set local nvim_set = t.nvim_set
local expect_twostreams = helpers.expect_twostreams local expect_twostreams = t.expect_twostreams
local expect_msg_seq = helpers.expect_msg_seq local expect_msg_seq = t.expect_msg_seq
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local matches = helpers.matches local matches = t.matches
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local skip = helpers.skip local skip = t.skip
local is_os = helpers.is_os local is_os = t.is_os
describe('jobs', function() describe('jobs', function()
local channel local channel
@ -307,7 +307,7 @@ describe('jobs', function()
it('preserves NULs', function() it('preserves NULs', function()
-- Make a file with NULs in it. -- Make a file with NULs in it.
local filename = helpers.tmpname() local filename = t.tmpname()
write_file(filename, 'abc\0def\n') write_file(filename, 'abc\0def\n')
command("let j = jobstart(['cat', '" .. filename .. "'], g:job_opts)") command("let j = jobstart(['cat', '" .. filename .. "'], g:job_opts)")
@ -732,7 +732,7 @@ describe('jobs', function()
describe('jobwait()', function() describe('jobwait()', function()
before_each(function() before_each(function()
if is_os('win') then if is_os('win') then
helpers.set_shell_powershell() t.set_shell_powershell()
end end
end) end)
@ -1182,7 +1182,7 @@ describe('jobs', function()
end) end)
it('does not close the same handle twice on exit #25086', function() 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( write_file(
filename, filename,
[[ [[
@ -1195,7 +1195,7 @@ describe('jobs', function()
]] ]]
) )
local screen = thelpers.setup_child_nvim({ local screen = tt.setup_child_nvim({
'--cmd', '--cmd',
'set notermguicolors', 'set notermguicolors',
'-i', '-i',
@ -1239,7 +1239,7 @@ describe('pty process teardown', function()
skip(fn.executable('sleep') == 0, 'missing "sleep" command') skip(fn.executable('sleep') == 0, 'missing "sleep" command')
-- Use a nested nvim (in :term) to test without --headless. -- Use a nested nvim (in :term) to test without --headless.
fn.termopen({ fn.termopen({
helpers.nvim_prog, t.nvim_prog,
'-u', '-u',
'NONE', 'NONE',
'-i', '-i',

View File

@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local assert_log = helpers.assert_log local assert_log = t.assert_log
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local expect_exit = helpers.expect_exit local expect_exit = t.expect_exit
local request = helpers.request local request = t.request
describe('log', function() describe('log', function()
local testlog = 'Xtest_logging' local testlog = 'Xtest_logging'

View File

@ -1,17 +1,17 @@
local uv = vim.uv 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 Screen = require('test.functional.ui.screen')
local eq = helpers.eq local eq = t.eq
local matches = helpers.matches local matches = t.matches
local feed = helpers.feed local feed = t.feed
local eval = helpers.eval local eval = t.eval
local clear = helpers.clear local clear = t.clear
local fn = helpers.fn local fn = t.fn
local nvim_prog_abs = helpers.nvim_prog_abs local nvim_prog_abs = t.nvim_prog_abs
local write_file = helpers.write_file local write_file = t.write_file
local is_os = helpers.is_os local is_os = t.is_os
local skip = helpers.skip local skip = t.skip
describe('command-line option', function() describe('command-line option', function()
describe('-s', function() describe('-s', function()

View File

@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local feed = helpers.feed local feed = t.feed
local fn = helpers.fn local fn = t.fn
local insert = helpers.insert local insert = t.insert
local is_os = helpers.is_os local is_os = t.is_os
local mkdir = helpers.mkdir local mkdir = t.mkdir
local rmdir = helpers.rmdir local rmdir = t.rmdir
local write_file = helpers.write_file local write_file = t.write_file
local function join_path(...) local function join_path(...)
local pathsep = (is_os('win') and '\\' or '/') local pathsep = (is_os('win') and '\\' or '/')

View File

@ -1,20 +1,20 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local expect = helpers.expect local expect = t.expect
local fn = helpers.fn local fn = t.fn
local insert = helpers.insert local insert = t.insert
local nvim_prog = helpers.nvim_prog local nvim_prog = t.nvim_prog
local new_argv = helpers.new_argv local new_argv = t.new_argv
local neq = helpers.neq local neq = t.neq
local set_session = helpers.set_session local set_session = t.set_session
local spawn = helpers.spawn local spawn = t.spawn
local tmpname = helpers.tmpname local tmpname = t.tmpname
local write_file = helpers.write_file local write_file = t.write_file
describe('Remote', function() describe('Remote', function()
local fname, other_fname local fname, other_fname

View File

@ -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 eq = t.eq
local clear = helpers.clear local clear = t.clear
local api = helpers.api local api = t.api
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local fn = helpers.fn local fn = t.fn
local rmdir = helpers.rmdir local rmdir = t.rmdir
local write_file = helpers.write_file local write_file = t.write_file
local mkdir = helpers.mkdir local mkdir = t.mkdir
local testdir = 'Xtest-functional-spell-spellfile.d' local testdir = 'Xtest-functional-spell-spellfile.d'

View File

@ -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 Screen = require('test.functional.ui.screen')
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local assert_log = helpers.assert_log local assert_log = t.assert_log
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local ok = helpers.ok local ok = t.ok
local eq = helpers.eq local eq = t.eq
local matches = helpers.matches local matches = t.matches
local eval = helpers.eval local eval = t.eval
local exec = helpers.exec local exec = t.exec
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local feed = helpers.feed local feed = t.feed
local fn = helpers.fn local fn = t.fn
local pesc = vim.pesc local pesc = vim.pesc
local mkdir = helpers.mkdir local mkdir = t.mkdir
local mkdir_p = helpers.mkdir_p local mkdir_p = t.mkdir_p
local nvim_prog = helpers.nvim_prog local nvim_prog = t.nvim_prog
local nvim_set = helpers.nvim_set local nvim_set = t.nvim_set
local read_file = helpers.read_file local read_file = t.read_file
local retry = helpers.retry local retry = t.retry
local rmdir = helpers.rmdir local rmdir = t.rmdir
local sleep = vim.uv.sleep local sleep = vim.uv.sleep
local startswith = vim.startswith local startswith = vim.startswith
local write_file = helpers.write_file local write_file = t.write_file
local api = helpers.api local api = t.api
local alter_slashes = helpers.alter_slashes local alter_slashes = t.alter_slashes
local is_os = helpers.is_os local is_os = t.is_os
local dedent = helpers.dedent local dedent = t.dedent
local tbl_map = vim.tbl_map local tbl_map = vim.tbl_map
local tbl_filter = vim.tbl_filter local tbl_filter = vim.tbl_filter
local endswith = vim.endswith local endswith = vim.endswith
local check_close = helpers.check_close local check_close = t.check_close
local testlog = 'Xtest-startupspec-log' local testlog = 'Xtest-startupspec-log'
@ -467,7 +467,7 @@ describe('startup', function()
| |
]]) ]])
if not is_os('win') then 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
end) end)
@ -994,7 +994,7 @@ describe('sysinit', function()
local xdgdir = 'Xxdg' local xdgdir = 'Xxdg'
local vimdir = 'Xvim' local vimdir = 'Xvim'
local xhome = 'Xhome' local xhome = 'Xhome'
local pathsep = helpers.get_pathsep() local pathsep = t.get_pathsep()
before_each(function() before_each(function()
rmdir(xdgdir) rmdir(xdgdir)
@ -1055,7 +1055,7 @@ end)
describe('user config init', function() describe('user config init', function()
local xhome = 'Xhome' local xhome = 'Xhome'
local pathsep = helpers.get_pathsep() local pathsep = t.get_pathsep()
local xconfig = xhome .. pathsep .. 'Xconfig' local xconfig = xhome .. pathsep .. 'Xconfig'
local xdata = xhome .. pathsep .. 'Xdata' local xdata = xhome .. pathsep .. 'Xdata'
local init_lua_path = table.concat({ xconfig, 'nvim', 'init.lua' }, pathsep) local init_lua_path = table.concat({ xconfig, 'nvim', 'init.lua' }, pathsep)
@ -1218,7 +1218,7 @@ end)
describe('runtime:', function() describe('runtime:', function()
local xhome = 'Xhome' local xhome = 'Xhome'
local pathsep = helpers.get_pathsep() local pathsep = t.get_pathsep()
local xconfig = xhome .. pathsep .. 'Xconfig' local xconfig = xhome .. pathsep .. 'Xconfig'
local xdata = xhome .. pathsep .. 'Xdata' local xdata = xhome .. pathsep .. 'Xdata'
local xenv = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata } local xenv = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata }
@ -1360,7 +1360,7 @@ end)
describe('user session', function() describe('user session', function()
local xhome = 'Xhome' local xhome = 'Xhome'
local pathsep = helpers.get_pathsep() local pathsep = t.get_pathsep()
local session_file = table.concat({ xhome, 'session.lua' }, pathsep) local session_file = table.concat({ xhome, 'session.lua' }, pathsep)
before_each(function() before_each(function()

View File

@ -1,6 +1,5 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local eq, clear, eval, feed, api, retry = local eq, clear, eval, feed, api, retry = t.eq, t.clear, t.eval, t.feed, t.api, t.retry
helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.api, helpers.retry
describe('K', function() describe('K', function()
local test_file = 'K_spec_out' local test_file = 'K_spec_out'
@ -13,19 +12,19 @@ describe('K', function()
end) end)
it("invokes colon-prefixed 'keywordprg' as Vim command", function() it("invokes colon-prefixed 'keywordprg' as Vim command", function()
helpers.source([[ t.source([[
let @a='fnord' let @a='fnord'
set keywordprg=:put]]) set keywordprg=:put]])
-- K on the text "a" resolves to `:put a`. -- K on the text "a" resolves to `:put a`.
feed('ia<ESC>K') feed('ia<ESC>K')
helpers.expect([[ t.expect([[
a a
fnord]]) fnord]])
end) end)
it("invokes non-prefixed 'keywordprg' as shell command", function() it("invokes non-prefixed 'keywordprg' as shell command", function()
helpers.source([[ t.source([[
let @a='fnord' let @a='fnord'
set keywordprg=echo\ fnord>>]]) set keywordprg=echo\ fnord>>]])
@ -43,7 +42,7 @@ describe('K', function()
end) end)
it("<esc> kills the buffer for a running 'keywordprg' command", function() it("<esc> kills the buffer for a running 'keywordprg' command", function()
helpers.source('set keywordprg=less') t.source('set keywordprg=less')
eval('writefile(["hello", "world"], "' .. test_file .. '")') eval('writefile(["hello", "world"], "' .. test_file .. '")')
feed('i' .. test_file .. '<esc>K') feed('i' .. test_file .. '<esc>K')
eq('t', eval('mode()')) eq('t', eval('mode()'))
@ -57,7 +56,7 @@ describe('K', function()
local bufnr = eval('bufnr()') local bufnr = eval('bufnr()')
feed('<esc>') feed('<esc>')
eq('n', eval('mode()')) eq('n', eval('mode()'))
helpers.neq(bufnr, eval('bufnr()')) t.neq(bufnr, eval('bufnr()'))
end) end)
it('empty string falls back to :help #19298', function() it('empty string falls back to :help #19298', function()

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 Screen = require('test.functional.ui.screen')
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local clear, feed = helpers.clear, helpers.feed local clear, feed = t.clear, t.feed
local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq local eval, eq, neq = t.eval, t.eq, t.neq
local feed_command, source, expect = helpers.feed_command, helpers.source, helpers.expect local feed_command, source, expect = t.feed_command, t.source, t.expect
local fn = helpers.fn local fn = t.fn
local command = helpers.command local command = t.command
local api = helpers.api local api = t.api
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = t.poke_eventloop
describe('completion', function() describe('completion', function()
local screen local screen

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 eq = t.eq
local eval = helpers.eval local eval = t.eval
local feed = helpers.feed local feed = t.feed
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
describe('v:count/v:count1', function() describe('v:count/v:count1', function()
before_each(function() before_each(function()

View File

@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear, feed, source = helpers.clear, helpers.feed, helpers.source local clear, feed, source = t.clear, t.feed, t.source
local command = helpers.command local command = t.command
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = t.poke_eventloop
local sleep = vim.uv.sleep local sleep = vim.uv.sleep
describe('CTRL-C (mapped)', function() describe('CTRL-C (mapped)', function()
@ -16,7 +16,7 @@ describe('CTRL-C (mapped)', function()
it('interrupts :global', function() it('interrupts :global', function()
-- Crashes luajit. -- Crashes luajit.
if helpers.skip_fragile(pending) then if t.skip_fragile(pending) then
return return
end end

View File

@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local insert = helpers.insert local insert = t.insert
local exec = helpers.exec local exec = t.exec
local feed = helpers.feed local feed = t.feed
local expect = helpers.expect local expect = t.expect
local command = helpers.command local command = t.command
local fn = helpers.fn local fn = t.fn
local eq = helpers.eq local eq = t.eq
local neq = helpers.neq local neq = t.neq
describe('Folding', function() describe('Folding', function()
local tempfname = 'Xtest-fold.txt' local tempfname = 'Xtest-fold.txt'
@ -301,7 +301,7 @@ a]],
it('updates correctly on :read', function() it('updates correctly on :read', function()
-- luacheck: ignore 621 -- luacheck: ignore 621
helpers.write_file( t.write_file(
tempfname, tempfname,
[[ [[
a a
@ -376,7 +376,7 @@ a]],
end) end)
it('splits folds according to >N and <N with foldexpr', function() it('splits folds according to >N and <N with foldexpr', function()
helpers.source([[ t.source([[
function TestFoldExpr(lnum) function TestFoldExpr(lnum)
let thisline = getline(a:lnum) let thisline = getline(a:lnum)
if thisline == 'a' if thisline == 'a'
@ -391,7 +391,7 @@ a]],
return 0 return 0
endfunction endfunction
]]) ]])
helpers.write_file( t.write_file(
tempfname, tempfname,
[[ [[
b b

View File

@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local dedent = helpers.dedent local dedent = t.dedent
local eq = helpers.eq local eq = t.eq
local fn = helpers.fn local fn = t.fn
local feed = helpers.feed local feed = t.feed
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
local write_file = helpers.write_file local write_file = t.write_file
local api = helpers.api local api = t.api
describe('jumplist', function() describe('jumplist', function()
local fname1 = 'Xtest-functional-normal-jump' local fname1 = 'Xtest-functional-normal-jump'

View File

@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, insert, eq = helpers.clear, helpers.insert, helpers.eq local clear, insert, eq = t.clear, t.insert, t.eq
local command, expect = helpers.command, helpers.expect local command, expect = t.command, t.expect
local feed, eval = helpers.feed, helpers.eval local feed, eval = t.feed, t.eval
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
describe('gu and gU', function() describe('gu and gU', function()
before_each(clear) before_each(clear)

View File

@ -1,10 +1,10 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local eq, neq, call = helpers.eq, helpers.neq, helpers.call local eq, neq, call = t.eq, t.neq, t.call
local eval, feed, clear = helpers.eval, helpers.feed, helpers.clear local eval, feed, clear = t.eval, t.feed, t.clear
local command, insert, expect = helpers.command, helpers.insert, helpers.expect local command, insert, expect = t.command, t.insert, t.expect
local feed_command = helpers.feed_command local feed_command = t.feed_command
local curwin = helpers.api.nvim_get_current_win local curwin = t.api.nvim_get_current_win
describe("'langmap'", function() describe("'langmap'", function()
before_each(function() before_each(function()
@ -133,7 +133,7 @@ describe("'langmap'", function()
hello]]) hello]])
end) end)
it('command-line CTRL-R', function() it('command-line CTRL-R', function()
helpers.source([[ t.source([[
let i_value = 0 let i_value = 0
let j_value = 0 let j_value = 0
call setreg('i', 'i_value') call setreg('i', 'i_value')
@ -171,7 +171,7 @@ describe("'langmap'", function()
end) end)
it('prompt for number', function() it('prompt for number', function()
command('set langmap=12,21') command('set langmap=12,21')
helpers.source([[ t.source([[
let gotten_one = 0 let gotten_one = 0
function Map() function Map()
let answer = inputlist(['a', '1.', '2.', '3.']) let answer = inputlist(['a', '1.', '2.', '3.'])
@ -214,10 +214,7 @@ describe("'langmap'", function()
end end
feed('qa' .. command_string .. 'q') feed('qa' .. command_string .. 'q')
expect(expect_string) expect(expect_string)
eq( eq(expect_macro or t.fn.nvim_replace_termcodes(command_string, true, true, true), eval('@a'))
expect_macro or helpers.fn.nvim_replace_termcodes(command_string, true, true, true),
eval('@a')
)
if setup_function then if setup_function then
setup_function() setup_function()
end end

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 eval = helpers.eval local eval = t.eval
local feed = helpers.feed local feed = t.feed
local clear = helpers.clear local clear = t.clear
local expect = helpers.expect local expect = t.expect
local command = helpers.command local command = t.command
local fn = helpers.fn local fn = t.fn
local api = helpers.api local api = t.api
local insert = helpers.insert local insert = t.insert
describe('macros', function() describe('macros', function()
before_each(function() before_each(function()

View File

@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local api = helpers.api local api = t.api
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local fn = helpers.fn local fn = t.fn
local eq = helpers.eq local eq = t.eq
local feed = helpers.feed local feed = t.feed
local write_file = helpers.write_file local write_file = t.write_file
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local cursor = function() local cursor = function()
return helpers.api.nvim_win_get_cursor(0) return t.api.nvim_win_get_cursor(0)
end end
describe('named marks', function() describe('named marks', function()
@ -39,59 +39,59 @@ describe('named marks', function()
it('errors when set out of range with :mark', function() it('errors when set out of range with :mark', function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, '1000mark x') local err = pcall_err(t.exec_capture, '1000mark x')
eq('nvim_exec2(): Vim(mark):E16: Invalid range: 1000mark x', err) eq('nvim_exec2(): Vim(mark):E16: Invalid range: 1000mark x', err)
end) end)
it('errors when set out of range with :k', function() it('errors when set out of range with :k', function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, '1000kx') local err = pcall_err(t.exec_capture, '1000kx')
eq('nvim_exec2(): Vim(k):E16: Invalid range: 1000kx', err) eq('nvim_exec2(): Vim(k):E16: Invalid range: 1000kx', err)
end) end)
it('errors on unknown mark name with :mark', function() it('errors on unknown mark name with :mark', function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, 'mark #') local err = pcall_err(t.exec_capture, 'mark #')
eq('nvim_exec2(): Vim(mark):E191: Argument must be a letter or forward/backward quote', err) eq('nvim_exec2(): Vim(mark):E191: Argument must be a letter or forward/backward quote', err)
end) end)
it("errors on unknown mark name with '", function() it("errors on unknown mark name with '", function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, "normal! '#") local err = pcall_err(t.exec_capture, "normal! '#")
eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err) eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err)
end) end)
it('errors on unknown mark name with `', function() it('errors on unknown mark name with `', function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, 'normal! `#') local err = pcall_err(t.exec_capture, 'normal! `#')
eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err) eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err)
end) end)
it("errors when moving to a mark that is not set with '", function() it("errors when moving to a mark that is not set with '", function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, "normal! 'z") local err = pcall_err(t.exec_capture, "normal! 'z")
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
err = pcall_err(helpers.exec_capture, "normal! '.") err = pcall_err(t.exec_capture, "normal! '.")
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
end) end)
it('errors when moving to a mark that is not set with `', function() it('errors when moving to a mark that is not set with `', function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, 'normal! `z') local err = pcall_err(t.exec_capture, 'normal! `z')
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
err = pcall_err(helpers.exec_capture, 'normal! `>') err = pcall_err(t.exec_capture, 'normal! `>')
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
end) end)
it("errors when moving to a global mark that is not set with '", function() it("errors when moving to a global mark that is not set with '", function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, "normal! 'Z") local err = pcall_err(t.exec_capture, "normal! 'Z")
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
end) end)
it('errors when moving to a global mark that is not set with `', function() it('errors when moving to a global mark that is not set with `', function()
command('edit ' .. file1) command('edit ' .. file1)
local err = pcall_err(helpers.exec_capture, 'normal! `Z') local err = pcall_err(t.exec_capture, 'normal! `Z')
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err) eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
end) end)
@ -166,7 +166,7 @@ describe('named marks', function()
feed('mA') feed('mA')
command('next') command('next')
command('bw! ' .. file1) command('bw! ' .. file1)
local err = pcall_err(helpers.exec_capture, "normal! 'A") local err = pcall_err(t.exec_capture, "normal! 'A")
eq('nvim_exec2(): Vim(normal):E92: Buffer 1 not found', err) eq('nvim_exec2(): Vim(normal):E92: Buffer 1 not found', err)
os.remove(file1) os.remove(file1)
end) end)

View File

@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local clear, feed, insert = t.clear, t.feed, t.insert
local command = helpers.command local command = t.command
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local eval = helpers.eval local eval = t.eval
local expect = helpers.expect local expect = t.expect
local fn = helpers.fn local fn = t.fn
local eq = helpers.eq local eq = t.eq
describe('meta-keys #8226 #13042', function() describe('meta-keys #8226 #13042', function()
before_each(function() before_each(function()

View File

@ -1,12 +1,11 @@
-- Cmdline-mode tests. -- Cmdline-mode tests.
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear, insert, fn, eq, feed = local clear, insert, fn, eq, feed = t.clear, t.insert, t.fn, t.eq, t.feed
helpers.clear, helpers.insert, helpers.fn, helpers.eq, helpers.feed local eval = t.eval
local eval = helpers.eval local command = t.command
local command = helpers.command local api = t.api
local api = helpers.api
describe('cmdline', function() describe('cmdline', function()
before_each(clear) before_each(clear)

View File

@ -1,14 +1,14 @@
-- Insert-mode tests. -- Insert-mode tests.
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local clear, feed, insert = t.clear, t.feed, t.insert
local expect = helpers.expect local expect = t.expect
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local curbuf_contents = helpers.curbuf_contents local curbuf_contents = t.curbuf_contents
local api = helpers.api local api = t.api
describe('insert-mode', function() describe('insert-mode', function()
before_each(function() before_each(function()
@ -232,10 +232,10 @@ describe('insert-mode', function()
end end
local function test_cols(expected_cols) local function test_cols(expected_cols)
local cols = { { helpers.fn.col('.'), helpers.fn.virtcol('.') } } local cols = { { t.fn.col('.'), t.fn.virtcol('.') } }
for _ = 2, #expected_cols do for _ = 2, #expected_cols do
feed('<BS>') feed('<BS>')
table.insert(cols, { helpers.fn.col('.'), helpers.fn.virtcol('.') }) table.insert(cols, { t.fn.col('.'), t.fn.virtcol('.') })
end end
eq(expected_cols, cols) eq(expected_cols, cols)
end end

View File

@ -1,11 +1,11 @@
-- Normal mode tests. -- Normal mode tests.
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local feed = helpers.feed local feed = t.feed
local fn = helpers.fn local fn = t.fn
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
describe('Normal mode', function() describe('Normal mode', function()
before_each(clear) before_each(clear)

View File

@ -1,18 +1,18 @@
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local insert = helpers.insert local insert = t.insert
local feed = helpers.feed local feed = t.feed
local expect = helpers.expect local expect = t.expect
local eq = helpers.eq local eq = t.eq
local map = vim.tbl_map local map = vim.tbl_map
local filter = vim.tbl_filter local filter = vim.tbl_filter
local feed_command = helpers.feed_command local feed_command = t.feed_command
local command = helpers.command local command = t.command
local curbuf_contents = helpers.curbuf_contents local curbuf_contents = t.curbuf_contents
local fn = helpers.fn local fn = t.fn
local dedent = helpers.dedent local dedent = t.dedent
local function reset() local function reset()
command('bwipe! | new') command('bwipe! | new')
@ -75,7 +75,7 @@ describe('put command', function()
extra_setup() extra_setup()
end end
local orig_dotstr = fn.getreg('.') local orig_dotstr = fn.getreg('.')
helpers.ok(visual_marks_zero()) t.ok(visual_marks_zero())
-- Make sure every test starts from the same conditions -- Make sure every test starts from the same conditions
assert_no_change(test.exception_table, false) assert_no_change(test.exception_table, false)
local was_cli = test.test_action() local was_cli = test.test_action()
@ -890,7 +890,7 @@ describe('put command', function()
-- check bell is not set by nvim before the action -- check bell is not set by nvim before the action
screen:sleep(50) screen:sleep(50)
end end
helpers.ok(not screen.bell and not screen.visualbell) t.ok(not screen.bell and not screen.visualbell)
actions() actions()
screen:expect { screen:expect {
condition = function() condition = function()

View File

@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
describe('search (/)', function() describe('search (/)', function()
before_each(clear) before_each(clear)

View File

@ -1,17 +1,17 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local neq = helpers.neq local neq = t.neq
local feed = helpers.feed local feed = t.feed
local eval = helpers.eval local eval = t.eval
local exec = helpers.exec local exec = t.exec
local fn = helpers.fn local fn = t.fn
local api = helpers.api local api = t.api
local curwin = helpers.api.nvim_get_current_win local curwin = t.api.nvim_get_current_win
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
describe('tabpage', function() describe('tabpage', function()
before_each(clear) before_each(clear)

View File

@ -1,16 +1,16 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eval = helpers.eval local eval = t.eval
local expect = helpers.expect local expect = t.expect
local eq = helpers.eq local eq = t.eq
local feed = helpers.feed local feed = t.feed
local feed_command = helpers.feed_command local feed_command = t.feed_command
local insert = helpers.insert local insert = t.insert
local fn = helpers.fn local fn = t.fn
local exec = helpers.exec local exec = t.exec
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local function lastmessage() local function lastmessage()
local messages = fn.split(fn.execute('messages'), '\n') local messages = fn.split(fn.execute('messages'), '\n')
@ -44,7 +44,7 @@ describe('u CTRL-R g- g+', function()
local function undo_and_redo(hist_pos, undo, redo, expect_str) local function undo_and_redo(hist_pos, undo, redo, expect_str)
command('enew!') command('enew!')
create_history(hist_pos) create_history(hist_pos)
local cur_contents = helpers.curbuf_contents() local cur_contents = t.curbuf_contents()
feed(undo) feed(undo)
expect(expect_str) expect(expect_str)
feed(redo) feed(redo)

View File

@ -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 eq = t.eq
local dedent = helpers.dedent local dedent = t.dedent
local exec = helpers.exec local exec = t.exec
local feed = helpers.feed local feed = t.feed
local clear = helpers.clear local clear = t.clear
local fn = helpers.fn local fn = t.fn
local command = helpers.command local command = t.command
local api = helpers.api local api = t.api
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local cmdtest = function(cmd, prep, ret1) local cmdtest = function(cmd, prep, ret1)

View File

@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local eq, command, fn = helpers.eq, helpers.command, helpers.fn local eq, command, fn = t.eq, t.command, t.fn
local ok = helpers.ok local ok = t.ok
local matches = helpers.matches local matches = t.matches
local clear = helpers.clear local clear = t.clear
describe(':argument', function() describe(':argument', function()
before_each(function() before_each(function()
@ -11,19 +11,19 @@ describe(':argument', function()
it('does not restart :terminal buffer', function() it('does not restart :terminal buffer', function()
command('terminal') command('terminal')
helpers.feed([[<C-\><C-N>]]) t.feed([[<C-\><C-N>]])
command('argadd') command('argadd')
helpers.feed([[<C-\><C-N>]]) t.feed([[<C-\><C-N>]])
local bufname_before = fn.bufname('%') local bufname_before = fn.bufname('%')
local bufnr_before = fn.bufnr('%') local bufnr_before = fn.bufnr('%')
matches('^term://', bufname_before) -- sanity matches('^term://', bufname_before) -- sanity
command('argument 1') command('argument 1')
helpers.feed([[<C-\><C-N>]]) t.feed([[<C-\><C-N>]])
local bufname_after = fn.bufname('%') local bufname_after = fn.bufname('%')
local bufnr_after = fn.bufnr('%') local bufnr_after = fn.bufnr('%')
eq('[' .. bufname_before .. ']', helpers.eval('trim(execute("args"))')) eq('[' .. bufname_before .. ']', t.eval('trim(execute("args"))'))
ok(fn.line('$') > 1) ok(fn.line('$') > 1)
eq(bufname_before, bufname_after) eq(bufname_before, bufname_after)
eq(bufnr_before, bufnr_after) eq(bufnr_before, bufnr_after)

View File

@ -1,16 +1,16 @@
-- Specs for :cd, :tcd, :lcd and getcwd() -- Specs for :cd, :tcd, :lcd and getcwd()
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 call = helpers.call local call = t.call
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local pathsep = helpers.get_pathsep() local pathsep = t.get_pathsep()
local skip = helpers.skip local skip = t.skip
local is_os = helpers.is_os local is_os = t.is_os
local mkdir = helpers.mkdir local mkdir = t.mkdir
-- These directories will be created for testing -- These directories will be created for testing
local directories = { local directories = {
@ -289,14 +289,14 @@ describe('getcwd()', function()
end) end)
after_each(function() after_each(function()
helpers.rmdir(directories.global) t.rmdir(directories.global)
end) end)
it('returns empty string if working directory does not exist', function() it('returns empty string if working directory does not exist', function()
skip(is_os('win')) skip(is_os('win'))
command('cd ' .. directories.global) command('cd ' .. directories.global)
command("call delete('../" .. directories.global .. "', 'd')") command("call delete('../" .. directories.global .. "', 'd')")
eq('', helpers.eval('getcwd()')) eq('', t.eval('getcwd()'))
end) end)
it("works with 'autochdir' after local directory was set (#9892)", function() it("works with 'autochdir' after local directory was set (#9892)", function()

View File

@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local feed = helpers.feed local feed = t.feed
local eq = helpers.eq local eq = t.eq
local expect = helpers.expect local expect = t.expect
local eval = helpers.eval local eval = t.eval
local fn = helpers.fn local fn = t.fn
local insert = helpers.insert local insert = t.insert
local write_file = helpers.write_file local write_file = t.write_file
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local command = helpers.command local command = t.command
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
describe('mappings with <Cmd>', function() describe('mappings with <Cmd>', function()

View File

@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local feed = helpers.feed local feed = t.feed
local clear = helpers.clear local clear = t.clear
describe(':debug', function() describe(':debug', function()
local screen local screen

View File

@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
local clear, source = helpers.clear, helpers.source local clear, source = t.clear, t.source
local api = helpers.api local api = t.api
local insert = helpers.insert local insert = t.insert
local eq, next_msg = helpers.eq, helpers.next_msg local eq, next_msg = t.eq, t.next_msg
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local exec_lua = helpers.exec_lua local exec_lua = t.exec_lua
local command = helpers.command local command = t.command
local eval = helpers.eval local eval = t.eval
describe('Vimscript dictionary notifications', function() describe('Vimscript dictionary notifications', function()
local channel local channel

View File

@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local feed = helpers.feed local feed = t.feed
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
describe(':digraphs', function() describe(':digraphs', function()

View File

@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local command = helpers.command local command = t.command
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear, feed, feed_command = helpers.clear, helpers.feed, helpers.feed_command local clear, feed, feed_command = t.clear, t.feed, t.feed_command
local exec = helpers.exec local exec = t.exec
describe(':drop', function() describe(':drop', function()
local screen local screen

View File

@ -1,17 +1,17 @@
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 NIL = vim.NIL
local eval = helpers.eval local eval = t.eval
local clear = helpers.clear local clear = t.clear
local api = helpers.api local api = t.api
local fn = helpers.fn local fn = t.fn
local source = helpers.source local source = t.source
local dedent = helpers.dedent local dedent = t.dedent
local command = helpers.command local command = t.command
local exc_exec = helpers.exc_exec local exc_exec = t.exc_exec
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
local matches = helpers.matches local matches = t.matches
describe(':echo :echon :echomsg :echoerr', function() describe(':echo :echon :echomsg :echoerr', function()
local fn_tbl = { 'String', 'StringN', 'StringMsg', 'StringErr' } local fn_tbl = { 'String', 'StringN', 'StringMsg', 'StringErr' }
@ -255,7 +255,7 @@ describe(':echo :echon :echomsg :echoerr', function()
eval('add(l, l)') eval('add(l, l)')
-- Regression: the below line used to crash (add returns original list and -- Regression: the below line used to crash (add returns original list and
-- there was error in dumping partials). Tested explicitly in -- 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))') eval('add(l, function("Test1", l))')
eq( eq(
dedent( dedent(

View File

@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local eq, command, fn = helpers.eq, helpers.command, helpers.fn local eq, command, fn = t.eq, t.command, t.fn
local ok = helpers.ok local ok = t.ok
local matches = helpers.matches local matches = t.matches
local clear = helpers.clear local clear = t.clear
local feed = helpers.feed local feed = t.feed
describe(':edit', function() describe(':edit', function()
before_each(function() before_each(function()

View File

@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, feed_command, feed = helpers.clear, helpers.feed_command, helpers.feed local clear, feed_command, feed = t.clear, t.feed_command, t.feed
local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval local eq, neq, eval = t.eq, t.neq, t.eval
describe('&encoding', function() describe('&encoding', function()
before_each(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 command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local clear = helpers.clear local clear = t.clear
local fn = helpers.fn local fn = t.fn
local pcall_err = helpers.pcall_err local pcall_err = t.pcall_err
local assert_alive = helpers.assert_alive local assert_alive = t.assert_alive
describe('Ex cmds', function() describe('Ex cmds', function()
before_each(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 clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local fn = helpers.fn local fn = t.fn
local rmdir = helpers.rmdir local rmdir = t.rmdir
local mkdir = helpers.mkdir local mkdir = t.mkdir
describe(':file', function() describe(':file', function()
local swapdir = vim.uv.cwd() .. '/Xtest-file_spec' local swapdir = vim.uv.cwd() .. '/Xtest-file_spec'

View File

@ -1,6 +1,5 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, feed_command, feed, ok, eval = local clear, feed_command, feed, ok, eval = t.clear, t.feed_command, t.feed, t.ok, t.eval
helpers.clear, helpers.feed_command, helpers.feed, helpers.ok, helpers.eval
describe(':grep', function() describe(':grep', function()
before_each(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 clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local fn = helpers.fn local fn = t.fn
local api = helpers.api local api = t.api
local mkdir = helpers.mkdir local mkdir = t.mkdir
local rmdir = helpers.rmdir local rmdir = t.rmdir
local write_file = helpers.write_file local write_file = t.write_file
describe(':help', function() describe(':help', function()
before_each(clear) before_each(clear)
it('window closed makes cursor return to a valid win/buf #9773', function() it('window closed makes cursor return to a valid win/buf #9773', function()
helpers.add_builddir_to_rtp() t.add_builddir_to_rtp()
command('help help') command('help help')
eq(1001, fn.win_getid()) eq(1001, fn.win_getid())
command('quit') command('quit')

View File

@ -1,11 +1,11 @@
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local eq, command = helpers.eq, helpers.command local eq, command = t.eq, t.command
local clear = helpers.clear local clear = t.clear
local eval, exc_exec = helpers.eval, helpers.exc_exec local eval, exc_exec = t.eval, t.exc_exec
local exec = helpers.exec local exec = t.exec
local fn = helpers.fn local fn = t.fn
local api = helpers.api local api = t.api
describe(':highlight', function() describe(':highlight', function()
local screen local screen

View File

@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local eq = helpers.eq local eq = t.eq
local eval = helpers.eval local eval = t.eval
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
local testprg = helpers.testprg local testprg = t.testprg
local retry = helpers.retry local retry = t.retry
describe(':ls', function() describe(':ls', function()
before_each(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 clear = helpers.clear local clear = t.clear
local eval = helpers.eval local eval = t.eval
local has_powershell = helpers.has_powershell local has_powershell = t.has_powershell
local matches = helpers.matches local matches = t.matches
local api = helpers.api local api = t.api
local testprg = helpers.testprg local testprg = t.testprg
describe(':make', function() describe(':make', function()
clear() clear()
@ -18,7 +18,7 @@ describe(':make', function()
return return
end end
before_each(function() before_each(function()
helpers.set_shell_powershell() t.set_shell_powershell()
end) end)
it('captures stderr & non zero exit code #14349', function() it('captures stderr & non zero exit code #14349', function()

View File

@ -1,16 +1,16 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local eq = helpers.eq local eq = t.eq
local exec = helpers.exec local exec = t.exec
local exec_capture = helpers.exec_capture local exec_capture = t.exec_capture
local feed = helpers.feed local feed = t.feed
local api = helpers.api local api = t.api
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local expect = helpers.expect local expect = t.expect
local insert = helpers.insert local insert = t.insert
local eval = helpers.eval local eval = t.eval
describe(':*map', function() describe(':*map', function()
before_each(clear) before_each(clear)

View File

@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear, command = helpers.clear, helpers.command local clear, command = t.clear, t.command
local expect, feed = helpers.expect, helpers.feed local expect, feed = t.expect, t.feed
local eq, eval = helpers.eq, helpers.eval local eq, eval = t.eq, t.eval
local fn = helpers.fn local fn = t.fn
describe(':emenu', function() describe(':emenu', function()
before_each(function() before_each(function()

View File

@ -1,20 +1,20 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local get_pathsep = helpers.get_pathsep local get_pathsep = t.get_pathsep
local eq = helpers.eq local eq = t.eq
local neq = helpers.neq local neq = t.neq
local fn = helpers.fn local fn = t.fn
local matches = helpers.matches local matches = t.matches
local pesc = vim.pesc local pesc = vim.pesc
local rmdir = helpers.rmdir local rmdir = t.rmdir
local sleep = vim.uv.sleep local sleep = vim.uv.sleep
local api = helpers.api local api = t.api
local skip = helpers.skip local skip = t.skip
local is_os = helpers.is_os local is_os = t.is_os
local mkdir = helpers.mkdir local mkdir = t.mkdir
local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec' local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'

View File

@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each) local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear local clear = t.clear
local command = helpers.command local command = t.command
local get_pathsep = helpers.get_pathsep local get_pathsep = t.get_pathsep
local eq = helpers.eq local eq = t.eq
local fn = helpers.fn local fn = t.fn
local rmdir = helpers.rmdir local rmdir = t.rmdir
local mkdir = helpers.mkdir local mkdir = t.mkdir
local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec' local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec'

Some files were not shown because too many files have changed in this diff Show More