test: improve test conventions

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

View File

@@ -1,15 +1,15 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local exc_exec = helpers.exc_exec
local remove_trace = helpers.remove_trace
local fn = helpers.fn
local clear = helpers.clear
local eval = helpers.eval
local exc_exec = t.exc_exec
local remove_trace = t.remove_trace
local fn = t.fn
local clear = t.clear
local eval = t.eval
local NIL = vim.NIL
local eq = helpers.eq
local exec_lua = helpers.exec_lua
local pcall_err = helpers.pcall_err
local eq = t.eq
local exec_lua = t.exec_lua
local pcall_err = t.pcall_err
before_each(clear)

View File

@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local pcall_err = helpers.pcall_err
local matches = helpers.matches
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local exec_lua = t.exec_lua
local eq = t.eq
local pcall_err = t.pcall_err
local matches = t.matches
describe('vim.base64', function()
before_each(clear)

View File

@@ -1,18 +1,18 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local command = helpers.command
local api = helpers.api
local fn = helpers.fn
local clear = helpers.clear
local eq = helpers.eq
local fail = helpers.fail
local exec_lua = helpers.exec_lua
local feed = helpers.feed
local expect_events = helpers.expect_events
local write_file = helpers.write_file
local dedent = helpers.dedent
local command = t.command
local api = t.api
local fn = t.fn
local clear = t.clear
local eq = t.eq
local fail = t.fail
local exec_lua = t.exec_lua
local feed = t.feed
local expect_events = t.expect_events
local write_file = t.write_file
local dedent = t.dedent
local origlines = {
'original line 1',
@@ -292,11 +292,11 @@ describe('lua buffer event callbacks: on_lines', function()
exec_lua(code)
command('q!')
helpers.assert_alive()
t.assert_alive()
exec_lua(code)
command('bd!')
helpers.assert_alive()
t.assert_alive()
end)
it('#12718 lnume', function()
@@ -965,7 +965,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
command('e! Xtest-undofile')
command('set undodir=. | set undofile')
local ns = helpers.request('nvim_create_namespace', 'ns1')
local ns = t.request('nvim_create_namespace', 'ns1')
api.nvim_buf_set_extmark(0, ns, 0, 0, {})
eq({ '12345', 'hello world' }, api.nvim_buf_get_lines(0, 0, -1, true))

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 eq = helpers.eq
local exec_lua = helpers.exec_lua
local clear = t.clear
local eq = t.eq
local exec_lua = t.exec_lua
local get_completions = function(input, env)
return exec_lua('return {vim._expand_pat(...)}', input, env)

View File

@@ -1,24 +1,24 @@
-- Test suite for checking :lua* commands
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local eq = t.eq
local NIL = vim.NIL
local eval = helpers.eval
local feed = helpers.feed
local clear = helpers.clear
local matches = helpers.matches
local api = helpers.api
local exec_lua = helpers.exec_lua
local exec_capture = helpers.exec_capture
local fn = helpers.fn
local source = helpers.source
local dedent = helpers.dedent
local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local write_file = helpers.write_file
local remove_trace = helpers.remove_trace
local eval = t.eval
local feed = t.feed
local clear = t.clear
local matches = t.matches
local api = t.api
local exec_lua = t.exec_lua
local exec_capture = t.exec_capture
local fn = t.fn
local source = t.source
local dedent = t.dedent
local command = t.command
local exc_exec = t.exc_exec
local pcall_err = t.pcall_err
local write_file = t.write_file
local remove_trace = t.remove_trace
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 api = helpers.api
local clear = helpers.clear
local eq = helpers.eq
local exec_capture = helpers.exec_capture
local exec_lua = helpers.exec_lua
local feed = helpers.feed
local api = t.api
local clear = t.clear
local eq = t.eq
local exec_capture = t.exec_capture
local exec_lua = t.exec_lua
local feed = t.feed
-- Reference text
-- aa

View File

@@ -1,14 +1,14 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local NIL = vim.NIL
local command = helpers.command
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local matches = helpers.matches
local api = helpers.api
local pcall_err = helpers.pcall_err
local fn = helpers.fn
local command = t.command
local clear = t.clear
local exec_lua = t.exec_lua
local eq = t.eq
local matches = t.matches
local api = t.api
local pcall_err = t.pcall_err
local fn = t.fn
describe('vim.diagnostic', function()
before_each(function()
@@ -1826,20 +1826,12 @@ describe('vim.diagnostic', function()
it('respects legacy signs placed with :sign define or sign_define #26618', function()
-- Legacy signs for diagnostics were deprecated in 0.10 and will be removed in 0.12
eq(0, helpers.fn.has('nvim-0.12'))
eq(0, t.fn.has('nvim-0.12'))
helpers.command(
'sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg'
)
helpers.command(
'sign define DiagnosticSignWarn text= texthl= linehl=WarningMsg numhl=WarningMsg'
)
helpers.command(
'sign define DiagnosticSignInfo text= texthl= linehl=Underlined numhl=Underlined'
)
helpers.command(
'sign define DiagnosticSignHint text= texthl= linehl=Underlined numhl=Underlined'
)
t.command('sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg')
t.command('sign define DiagnosticSignWarn text= texthl= linehl=WarningMsg numhl=WarningMsg')
t.command('sign define DiagnosticSignInfo text= texthl= linehl=Underlined numhl=Underlined')
t.command('sign define DiagnosticSignHint text= texthl= linehl=Underlined numhl=Underlined')
local result = exec_lua [[
vim.diagnostic.config({

View File

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

View File

@@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local api = helpers.api
local clear = helpers.clear
local pathroot = helpers.pathroot
local command = helpers.command
local mkdir = helpers.mkdir
local rmdir = helpers.rmdir
local write_file = helpers.write_file
local t = require('test.functional.testutil')(after_each)
local exec_lua = t.exec_lua
local eq = t.eq
local api = t.api
local clear = t.clear
local pathroot = t.pathroot
local command = t.command
local mkdir = t.mkdir
local rmdir = t.rmdir
local write_file = t.write_file
local uv = vim.uv
local root = pathroot()

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 exec_lua = helpers.exec_lua
local eq = helpers.eq
local mkdir_p = helpers.mkdir_p
local rmdir = helpers.rmdir
local nvim_dir = helpers.nvim_dir
local test_build_dir = helpers.paths.test_build_dir
local test_source_path = helpers.paths.test_source_path
local nvim_prog = helpers.nvim_prog
local is_os = helpers.is_os
local mkdir = helpers.mkdir
local clear = t.clear
local exec_lua = t.exec_lua
local eq = t.eq
local mkdir_p = t.mkdir_p
local rmdir = t.rmdir
local nvim_dir = t.nvim_dir
local test_build_dir = t.paths.test_build_dir
local test_source_path = t.paths.test_source_path
local nvim_prog = t.nvim_prog
local is_os = t.is_os
local mkdir = t.mkdir
local nvim_prog_basename = is_os('win') and 'nvim.exe' or 'nvim'

View File

@@ -1,10 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local exec_lua = helpers.exec_lua
local t = require('test.functional.testutil')(after_each)
local eq = t.eq
local exec_lua = t.exec_lua
describe('glob', function()
before_each(helpers.clear)
after_each(helpers.clear)
before_each(t.clear)
after_each(t.clear)
local match = function(...)
return exec_lua(

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local neq = helpers.neq
local eval = helpers.eval
local command = helpers.command
local clear = helpers.clear
local api = helpers.api
local t = require('test.functional.testutil')(after_each)
local exec_lua = t.exec_lua
local eq = t.eq
local neq = t.neq
local eval = t.eval
local command = t.command
local clear = t.clear
local api = t.api
describe('vim.highlight.on_yank', function()
before_each(function()
@@ -19,7 +19,7 @@ describe('vim.highlight.on_yank', function()
vim.cmd('bwipeout!')
]])
vim.uv.sleep(10)
helpers.feed('<cr>') -- avoid hang if error message exists
t.feed('<cr>') -- avoid hang if error message exists
eq('', eval('v:errmsg'))
end)

View File

@@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local eval = helpers.eval
local clear = helpers.clear
local t = require('test.functional.testutil')(after_each)
local exec_lua = t.exec_lua
local eq = t.eq
local eval = t.eval
local clear = t.clear
describe('vim.inspect_pos', function()
before_each(function()

View File

@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local matches = helpers.matches
local pcall_err = helpers.pcall_err
local t = require('test.functional.testutil')(after_each)
local eq = t.eq
local matches = t.matches
local pcall_err = t.pcall_err
describe('vim.iter', function()
it('new() on iterable class instance', function()
@@ -18,12 +18,12 @@ describe('vim.iter', function()
return v % 2 ~= 0
end
local t = { 1, 2, 3, 4, 5 }
eq({ 1, 3, 5 }, vim.iter(t):filter(odd):totable())
local q = { 1, 2, 3, 4, 5 }
eq({ 1, 3, 5 }, vim.iter(q):filter(odd):totable())
eq(
{ 2, 4 },
vim
.iter(t)
.iter(q)
:filter(function(v)
return not odd(v)
end)
@@ -32,7 +32,7 @@ describe('vim.iter', function()
eq(
{},
vim
.iter(t)
.iter(q)
:filter(function(v)
return v > 5
end)
@@ -40,7 +40,7 @@ describe('vim.iter', function()
)
do
local it = vim.iter(ipairs(t))
local it = vim.iter(ipairs(q))
it:filter(function(i, v)
return i > 1 and v < 5
end)
@@ -60,11 +60,11 @@ describe('vim.iter', function()
end)
it('map()', function()
local t = { 1, 2, 3, 4, 5 }
local q = { 1, 2, 3, 4, 5 }
eq(
{ 2, 4, 6, 8, 10 },
vim
.iter(t)
.iter(q)
:map(function(v)
return 2 * v
end)
@@ -96,10 +96,10 @@ describe('vim.iter', function()
end)
it('for loops', function()
local t = { 1, 2, 3, 4, 5 }
local q = { 1, 2, 3, 4, 5 }
local acc = 0
for v in
vim.iter(t):map(function(v)
vim.iter(q):map(function(v)
return v * 3
end)
do
@@ -146,13 +146,13 @@ describe('vim.iter', function()
it('skip()', function()
do
local t = { 4, 3, 2, 1 }
eq(t, vim.iter(t):skip(0):totable())
eq({ 3, 2, 1 }, vim.iter(t):skip(1):totable())
eq({ 2, 1 }, vim.iter(t):skip(2):totable())
eq({ 1 }, vim.iter(t):skip(#t - 1):totable())
eq({}, vim.iter(t):skip(#t):totable())
eq({}, vim.iter(t):skip(#t + 1):totable())
local q = { 4, 3, 2, 1 }
eq(q, vim.iter(q):skip(0):totable())
eq({ 3, 2, 1 }, vim.iter(q):skip(1):totable())
eq({ 2, 1 }, vim.iter(q):skip(2):totable())
eq({ 1 }, vim.iter(q):skip(#q - 1):totable())
eq({}, vim.iter(q):skip(#q):totable())
eq({}, vim.iter(q):skip(#q + 1):totable())
end
do
@@ -170,13 +170,13 @@ describe('vim.iter', function()
it('skipback()', function()
do
local t = { 4, 3, 2, 1 }
eq(t, vim.iter(t):skipback(0):totable())
eq({ 4, 3, 2 }, vim.iter(t):skipback(1):totable())
eq({ 4, 3 }, vim.iter(t):skipback(2):totable())
eq({ 4 }, vim.iter(t):skipback(#t - 1):totable())
eq({}, vim.iter(t):skipback(#t):totable())
eq({}, vim.iter(t):skipback(#t + 1):totable())
local q = { 4, 3, 2, 1 }
eq(q, vim.iter(q):skipback(0):totable())
eq({ 4, 3, 2 }, vim.iter(q):skipback(1):totable())
eq({ 4, 3 }, vim.iter(q):skipback(2):totable())
eq({ 4 }, vim.iter(q):skipback(#q - 1):totable())
eq({}, vim.iter(q):skipback(#q):totable())
eq({}, vim.iter(q):skipback(#q + 1):totable())
end
local it = vim.iter(vim.gsplit('a|b|c|d', '|'))
@@ -184,14 +184,14 @@ describe('vim.iter', function()
end)
it('slice()', function()
local t = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
eq({ 3, 4, 5, 6, 7 }, vim.iter(t):slice(3, 7):totable())
eq({}, vim.iter(t):slice(6, 5):totable())
eq({}, vim.iter(t):slice(0, 0):totable())
eq({ 1 }, vim.iter(t):slice(1, 1):totable())
eq({ 1, 2 }, vim.iter(t):slice(1, 2):totable())
eq({ 10 }, vim.iter(t):slice(10, 10):totable())
eq({ 8, 9, 10 }, vim.iter(t):slice(8, 11):totable())
local q = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
eq({ 3, 4, 5, 6, 7 }, vim.iter(q):slice(3, 7):totable())
eq({}, vim.iter(q):slice(6, 5):totable())
eq({}, vim.iter(q):slice(0, 0):totable())
eq({ 1 }, vim.iter(q):slice(1, 1):totable())
eq({ 1, 2 }, vim.iter(q):slice(1, 2):totable())
eq({ 10 }, vim.iter(q):slice(10, 10):totable())
eq({ 8, 9, 10 }, vim.iter(q):slice(8, 11):totable())
local it = vim.iter(vim.gsplit('a|b|c|d', '|'))
matches('slice%(%) requires a list%-like table', pcall_err(it.slice, it, 1, 3))
@@ -199,13 +199,13 @@ describe('vim.iter', function()
it('nth()', function()
do
local t = { 4, 3, 2, 1 }
eq(nil, vim.iter(t):nth(0))
eq(4, vim.iter(t):nth(1))
eq(3, vim.iter(t):nth(2))
eq(2, vim.iter(t):nth(3))
eq(1, vim.iter(t):nth(4))
eq(nil, vim.iter(t):nth(5))
local q = { 4, 3, 2, 1 }
eq(nil, vim.iter(q):nth(0))
eq(4, vim.iter(q):nth(1))
eq(3, vim.iter(q):nth(2))
eq(2, vim.iter(q):nth(3))
eq(1, vim.iter(q):nth(4))
eq(nil, vim.iter(q):nth(5))
end
do
@@ -223,13 +223,13 @@ describe('vim.iter', function()
it('nthback()', function()
do
local t = { 4, 3, 2, 1 }
eq(nil, vim.iter(t):nthback(0))
eq(1, vim.iter(t):nthback(1))
eq(2, vim.iter(t):nthback(2))
eq(3, vim.iter(t):nthback(3))
eq(4, vim.iter(t):nthback(4))
eq(nil, vim.iter(t):nthback(5))
local q = { 4, 3, 2, 1 }
eq(nil, vim.iter(q):nthback(0))
eq(1, vim.iter(q):nthback(1))
eq(2, vim.iter(q):nthback(2))
eq(3, vim.iter(q):nthback(3))
eq(4, vim.iter(q):nthback(4))
eq(nil, vim.iter(q):nthback(5))
end
local it = vim.iter(vim.gsplit('a|b|c|d', '|'))
@@ -238,24 +238,24 @@ describe('vim.iter', function()
it('take()', function()
do
local t = { 4, 3, 2, 1 }
eq({}, vim.iter(t):take(0):totable())
eq({ 4 }, vim.iter(t):take(1):totable())
eq({ 4, 3 }, vim.iter(t):take(2):totable())
eq({ 4, 3, 2 }, vim.iter(t):take(3):totable())
eq({ 4, 3, 2, 1 }, vim.iter(t):take(4):totable())
eq({ 4, 3, 2, 1 }, vim.iter(t):take(5):totable())
local q = { 4, 3, 2, 1 }
eq({}, vim.iter(q):take(0):totable())
eq({ 4 }, vim.iter(q):take(1):totable())
eq({ 4, 3 }, vim.iter(q):take(2):totable())
eq({ 4, 3, 2 }, vim.iter(q):take(3):totable())
eq({ 4, 3, 2, 1 }, vim.iter(q):take(4):totable())
eq({ 4, 3, 2, 1 }, vim.iter(q):take(5):totable())
end
do
local t = { 4, 3, 2, 1 }
eq({ 1, 2, 3 }, vim.iter(t):rev():take(3):totable())
eq({ 2, 3, 4 }, vim.iter(t):take(3):rev():totable())
local q = { 4, 3, 2, 1 }
eq({ 1, 2, 3 }, vim.iter(q):rev():take(3):totable())
eq({ 2, 3, 4 }, vim.iter(q):take(3):rev():totable())
end
do
local t = { 4, 3, 2, 1 }
local it = vim.iter(t)
local q = { 4, 3, 2, 1 }
local it = vim.iter(q)
eq({ 4, 3 }, it:take(2):totable())
-- tail is already set from the previous take()
eq({ 4, 3 }, it:take(3):totable())
@@ -275,13 +275,13 @@ describe('vim.iter', function()
end
do
local t = { 4, 8, 9, 10 }
eq(true, vim.iter(t):any(odd))
local q = { 4, 8, 9, 10 }
eq(true, vim.iter(q):any(odd))
end
do
local t = { 4, 8, 10 }
eq(false, vim.iter(t):any(odd))
local q = { 4, 8, 10 }
eq(false, vim.iter(q):any(odd))
end
do
@@ -306,13 +306,13 @@ describe('vim.iter', function()
end
do
local t = { 3, 5, 7, 9 }
eq(true, vim.iter(t):all(odd))
local q = { 3, 5, 7, 9 }
eq(true, vim.iter(q):all(odd))
end
do
local t = { 3, 5, 7, 10 }
eq(false, vim.iter(t):all(odd))
local q = { 3, 5, 7, 10 }
eq(false, vim.iter(q):all(odd))
end
do
@@ -360,18 +360,18 @@ describe('vim.iter', function()
end)
it('find()', function()
local t = { 3, 6, 9, 12 }
eq(12, vim.iter(t):find(12))
eq(nil, vim.iter(t):find(15))
local q = { 3, 6, 9, 12 }
eq(12, vim.iter(q):find(12))
eq(nil, vim.iter(q):find(15))
eq(
12,
vim.iter(t):find(function(v)
vim.iter(q):find(function(v)
return v % 4 == 0
end)
)
do
local it = vim.iter(t)
local it = vim.iter(q)
local pred = function(v)
return v % 3 == 0
end
@@ -395,16 +395,16 @@ describe('vim.iter', function()
end)
it('rfind()', function()
local t = { 1, 2, 3, 2, 1 }
local q = { 1, 2, 3, 2, 1 }
do
local it = vim.iter(t)
local it = vim.iter(q)
eq(1, it:rfind(1))
eq(1, it:rfind(1))
eq(nil, it:rfind(1))
end
do
local it = vim.iter(t):enumerate()
local it = vim.iter(q):enumerate()
local pred = function(i)
return i % 2 ~= 0
end
@@ -452,16 +452,16 @@ describe('vim.iter', function()
end)
it('fold()', function()
local t = { 1, 2, 3, 4, 5 }
local q = { 1, 2, 3, 4, 5 }
eq(
115,
vim.iter(t):fold(100, function(acc, v)
vim.iter(q):fold(100, function(acc, v)
return acc + v
end)
)
eq(
{ 5, 4, 3, 2, 1 },
vim.iter(t):fold({}, function(acc, v)
vim.iter(q):fold({}, function(acc, v)
table.insert(acc, 1, v)
return acc
end)
@@ -469,14 +469,14 @@ describe('vim.iter', function()
end)
it('flatten()', function()
local t = { { 1, { 2 } }, { { { { 3 } } }, { 4 } }, { 5 } }
local q = { { 1, { 2 } }, { { { { 3 } } }, { 4 } }, { 5 } }
eq(t, vim.iter(t):flatten(-1):totable())
eq(t, vim.iter(t):flatten(0):totable())
eq({ 1, { 2 }, { { { 3 } } }, { 4 }, 5 }, vim.iter(t):flatten():totable())
eq({ 1, 2, { { 3 } }, 4, 5 }, vim.iter(t):flatten(2):totable())
eq({ 1, 2, { 3 }, 4, 5 }, vim.iter(t):flatten(3):totable())
eq({ 1, 2, 3, 4, 5 }, vim.iter(t):flatten(4):totable())
eq(q, vim.iter(q):flatten(-1):totable())
eq(q, vim.iter(q):flatten(0):totable())
eq({ 1, { 2 }, { { { 3 } } }, { 4 }, 5 }, vim.iter(q):flatten():totable())
eq({ 1, 2, { { 3 } }, 4, 5 }, vim.iter(q):flatten(2):totable())
eq({ 1, 2, { 3 }, 4, 5 }, vim.iter(q):flatten(3):totable())
eq({ 1, 2, 3, 4, 5 }, vim.iter(q):flatten(4):totable())
local m = { a = 1, b = { 2, 3 }, d = { 4 } }
local it = vim.iter(m)
@@ -507,11 +507,11 @@ describe('vim.iter', function()
end
end)
local t = it:fold({}, function(t, k, v)
t[k] = v
return t
local q = it:fold({}, function(q, k, v)
q[k] = v
return q
end)
eq({ A = 2, C = 6 }, t)
eq({ A = 2, C = 6 }, q)
end)
it('handles table values mid-pipeline', function()

View File

@@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local pcall_err = helpers.pcall_err
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local exec_lua = t.exec_lua
local eq = t.eq
local pcall_err = t.pcall_err
describe('vim.json.decode()', function()
before_each(function()

View File

@@ -1,10 +1,10 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local exec_lua = helpers.exec_lua
local command = helpers.command
local clear = helpers.clear
local eq = helpers.eq
local exec_lua = t.exec_lua
local command = t.command
local clear = t.clear
local eq = t.eq
describe('vim.loader', function()
before_each(clear)
@@ -35,7 +35,7 @@ describe('vim.loader', function()
vim.loader.enable()
]]
local tmp = helpers.tmpname()
local tmp = t.tmpname()
command('edit ' .. tmp)
eq(
@@ -73,15 +73,15 @@ describe('vim.loader', function()
vim.loader.enable()
]]
local t = helpers.tmpname()
assert(os.remove(t))
assert(helpers.mkdir(t))
assert(helpers.mkdir(t .. '/%'))
local tmp1 = t .. '/%/x'
local tmp2 = t .. '/%%x'
local tmp = t.tmpname()
assert(os.remove(tmp))
assert(t.mkdir(tmp))
assert(t.mkdir(tmp .. '/%'))
local tmp1 = tmp .. '/%/x'
local tmp2 = tmp .. '/%%x'
helpers.write_file(tmp1, 'return 1', true)
helpers.write_file(tmp2, 'return 2', true)
t.write_file(tmp1, 'return 1', true)
t.write_file(tmp2, 'return 2', true)
vim.uv.fs_utime(tmp1, 0, 0)
vim.uv.fs_utime(tmp2, 0, 0)
eq(1, exec_lua('return loadfile(...)()', tmp1))

View File

@@ -1,16 +1,16 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local fn = helpers.fn
local api = helpers.api
local clear = helpers.clear
local fn = t.fn
local api = t.api
local clear = t.clear
local sleep = vim.uv.sleep
local feed = helpers.feed
local eq = helpers.eq
local eval = helpers.eval
local matches = helpers.matches
local exec_lua = helpers.exec_lua
local retry = helpers.retry
local feed = t.feed
local eq = t.eq
local eval = t.eval
local matches = t.matches
local exec_lua = t.exec_lua
local retry = t.retry
before_each(clear)

View File

@@ -1,19 +1,19 @@
-- Test suite for testing luaeval() function
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local pcall_err = helpers.pcall_err
local exc_exec = helpers.exc_exec
local remove_trace = helpers.remove_trace
local exec_lua = helpers.exec_lua
local command = helpers.command
local api = helpers.api
local fn = helpers.fn
local clear = helpers.clear
local eval = helpers.eval
local feed = helpers.feed
local pcall_err = t.pcall_err
local exc_exec = t.exc_exec
local remove_trace = t.remove_trace
local exec_lua = t.exec_lua
local command = t.command
local api = t.api
local fn = t.fn
local clear = t.clear
local eval = t.eval
local feed = t.feed
local NIL = vim.NIL
local eq = helpers.eq
local eq = t.eq
before_each(clear)
@@ -38,8 +38,8 @@ describe('luaeval()', function()
describe('second argument', function()
it('is successfully received', function()
local t = {t=true, f=false, --[[n=NIL,]] d={l={'string', 42, 0.42}}}
eq(t, fn.luaeval("_A", t))
local q = {t=true, f=false, --[[n=NIL,]] d={l={'string', 42, 0.42}}}
eq(q, fn.luaeval("_A", q))
-- Not tested: nil, funcrefs, returned object identity: behaviour will
-- most likely change.
end)

View File

@@ -1,9 +1,9 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local exec_lua = helpers.exec_lua
local clear = t.clear
local eq = t.eq
local exec_lua = t.exec_lua
describe('lua vim.mpack', function()
before_each(clear)

View File

@@ -1,19 +1,19 @@
-- Test for Vim overrides of lua built-ins
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local eq = t.eq
local NIL = vim.NIL
local feed = helpers.feed
local clear = helpers.clear
local fn = helpers.fn
local api = helpers.api
local command = helpers.command
local write_file = helpers.write_file
local exec_capture = helpers.exec_capture
local exec_lua = helpers.exec_lua
local pcall_err = helpers.pcall_err
local is_os = helpers.is_os
local feed = t.feed
local clear = t.clear
local fn = t.fn
local api = t.api
local command = t.command
local write_file = t.write_file
local exec_capture = t.exec_capture
local exec_lua = t.exec_lua
local pcall_err = t.pcall_err
local is_os = t.is_os
local fname = 'Xtest-functional-lua-overrides-luafile'

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 eq = helpers.eq
local eval = helpers.eval
local exec = helpers.exec
local fn = helpers.fn
local mkdir_p = helpers.mkdir_p
local rmdir = helpers.rmdir
local write_file = helpers.write_file
local clear = t.clear
local eq = t.eq
local eval = t.eval
local exec = t.exec
local fn = t.fn
local mkdir_p = t.mkdir_p
local rmdir = t.rmdir
local write_file = t.write_file
describe('runtime:', function()
local plug_dir = 'Test_Plugin'
local sep = helpers.get_pathsep()
local sep = t.get_pathsep()
local init = 'dummy_init.lua'
setup(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 eq = helpers.eq
local clear = helpers.clear
local command = helpers.command
local pathsep = helpers.get_pathsep()
local is_os = helpers.is_os
local api = helpers.api
local exec_lua = helpers.exec_lua
local feed_command = helpers.feed_command
local feed = helpers.feed
local fn = helpers.fn
local eq = t.eq
local clear = t.clear
local command = t.command
local pathsep = t.get_pathsep()
local is_os = t.is_os
local api = t.api
local exec_lua = t.exec_lua
local feed_command = t.feed_command
local feed = t.feed
local fn = t.fn
local stdpath = fn.stdpath
local pcall_err = helpers.pcall_err
local matches = helpers.matches
local read_file = helpers.read_file
local pcall_err = t.pcall_err
local matches = t.matches
local read_file = t.read_file
describe('vim.secure', function()
describe('read()', function()
@@ -22,8 +22,8 @@ describe('vim.secure', function()
setup(function()
clear { env = { XDG_STATE_HOME = xstate } }
helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
helpers.write_file(
t.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
t.write_file(
'Xfile',
[[
let g:foobar = 42
@@ -33,7 +33,7 @@ describe('vim.secure', function()
teardown(function()
os.remove('Xfile')
helpers.rmdir(xstate)
t.rmdir(xstate)
end)
it('works', function()
@@ -181,15 +181,15 @@ describe('vim.secure', function()
setup(function()
clear { env = { XDG_STATE_HOME = xstate } }
helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
t.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
end)
teardown(function()
helpers.rmdir(xstate)
t.rmdir(xstate)
end)
before_each(function()
helpers.write_file('test_file', 'test')
t.write_file('test_file', 'test')
end)
after_each(function()

View File

@@ -1,16 +1,16 @@
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local buf_lines = helpers.buf_lines
local clear = helpers.clear
local eq = helpers.eq
local exec_lua = helpers.exec_lua
local feed = helpers.feed
local api = helpers.api
local fn = helpers.fn
local matches = helpers.matches
local pcall_err = helpers.pcall_err
local poke_eventloop = helpers.poke_eventloop
local retry = helpers.retry
local buf_lines = t.buf_lines
local clear = t.clear
local eq = t.eq
local exec_lua = t.exec_lua
local feed = t.feed
local api = t.api
local fn = t.fn
local matches = t.matches
local pcall_err = t.pcall_err
local poke_eventloop = t.poke_eventloop
local retry = t.retry
describe('vim.snippet', function()
before_each(function()

View File

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

View File

@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local exec_lua = t.exec_lua
local eq = t.eq
local function system_sync(cmd, opts)
return exec_lua(

View File

@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local eq = t.eq
describe('vim.text', function()
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 Screen = require('test.functional.ui.screen')
local assert_alive = helpers.assert_alive
local clear = helpers.clear
local feed = helpers.feed
local eq = helpers.eq
local exec_lua = helpers.exec_lua
local next_msg = helpers.next_msg
local assert_alive = t.assert_alive
local clear = t.clear
local feed = t.feed
local eq = t.eq
local exec_lua = t.exec_lua
local next_msg = t.next_msg
local NIL = vim.NIL
local pcall_err = helpers.pcall_err
local pcall_err = t.pcall_err
describe('thread', function()
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 Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local exec_lua = helpers.exec_lua
local clear = helpers.clear
local feed = helpers.feed
local fn = helpers.fn
local assert_log = helpers.assert_log
local check_close = helpers.check_close
local eq = t.eq
local exec_lua = t.exec_lua
local clear = t.clear
local feed = t.feed
local fn = t.fn
local assert_log = t.assert_log
local check_close = t.check_close
local testlog = 'Xtest_lua_ui_event_log'
@@ -112,7 +112,7 @@ describe('vim.ui_attach', function()
it('does not crash on exit', function()
fn.system({
helpers.nvim_prog,
t.nvim_prog,
'-u',
'NONE',
'-i',
@@ -124,7 +124,7 @@ describe('vim.ui_attach', function()
'--cmd',
'quitall!',
})
eq(0, helpers.eval('v:shell_error'))
eq(0, t.eval('v:shell_error'))
end)
it('can receive accurate message kinds even if they are history', function()

View File

@@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local matches = helpers.matches
local exec_lua = helpers.exec_lua
local clear = helpers.clear
local feed = helpers.feed
local eval = helpers.eval
local is_ci = helpers.is_ci
local is_os = helpers.is_os
local poke_eventloop = helpers.poke_eventloop
local t = require('test.functional.testutil')(after_each)
local eq = t.eq
local matches = t.matches
local exec_lua = t.exec_lua
local clear = t.clear
local feed = t.feed
local eval = t.eval
local is_ci = t.is_ci
local is_os = t.is_os
local poke_eventloop = t.poke_eventloop
describe('vim.ui', function()
before_each(function()

View File

@@ -1,10 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local is_os = helpers.is_os
local skip = helpers.skip
local write_file = require('test.helpers').write_file
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local exec_lua = t.exec_lua
local eq = t.eq
local is_os = t.is_os
local skip = t.skip
local write_file = t.write_file
describe('URI methods', function()
before_each(function()
@@ -206,7 +206,7 @@ describe('URI methods', function()
it('Windows paths should not be treated as uris', function()
skip(not is_os('win'), 'Not applicable on non-Windows')
local file = helpers.tmpname()
local file = t.tmpname()
write_file(file, 'Test content')
local test_case = string.format(
[[

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local ok = helpers.ok
local exec_lua = helpers.exec_lua
local matches = helpers.matches
local pcall_err = helpers.pcall_err
local fn = helpers.fn
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local eq = t.eq
local ok = t.ok
local exec_lua = t.exec_lua
local matches = t.matches
local pcall_err = t.pcall_err
local fn = t.fn
local function v(ver)
return vim.version._version(ver)

View File

@@ -1,32 +1,32 @@
-- Test suite for testing interactions with API bindings
local helpers = require('test.functional.helpers')(after_each)
local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local nvim_prog = helpers.nvim_prog
local fn = helpers.fn
local api = helpers.api
local command = helpers.command
local dedent = helpers.dedent
local insert = helpers.insert
local clear = helpers.clear
local eq = helpers.eq
local ok = helpers.ok
local nvim_prog = t.nvim_prog
local fn = t.fn
local api = t.api
local command = t.command
local dedent = t.dedent
local insert = t.insert
local clear = t.clear
local eq = t.eq
local ok = t.ok
local pesc = vim.pesc
local eval = helpers.eval
local feed = helpers.feed
local pcall_err = helpers.pcall_err
local exec_lua = helpers.exec_lua
local matches = helpers.matches
local exec = helpers.exec
local eval = t.eval
local feed = t.feed
local pcall_err = t.pcall_err
local exec_lua = t.exec_lua
local matches = t.matches
local exec = t.exec
local NIL = vim.NIL
local retry = helpers.retry
local next_msg = helpers.next_msg
local remove_trace = helpers.remove_trace
local mkdir_p = helpers.mkdir_p
local rmdir = helpers.rmdir
local write_file = helpers.write_file
local poke_eventloop = helpers.poke_eventloop
local assert_alive = helpers.assert_alive
local retry = t.retry
local next_msg = t.next_msg
local remove_trace = t.remove_trace
local mkdir_p = t.mkdir_p
local rmdir = t.rmdir
local write_file = t.write_file
local poke_eventloop = t.poke_eventloop
local assert_alive = t.assert_alive
describe('lua stdlib', function()
before_each(clear)
@@ -592,8 +592,8 @@ describe('lua stdlib', function()
{ 'x*yz*oo*l', '*', true, false, { 'x', 'yz', 'oo', 'l' } },
}
for _, t in ipairs(tests) do
eq(t[5], vim.split(t[1], t[2], { plain = t[3], trimempty = t[4] }), t[1])
for _, q in ipairs(tests) do
eq(q[5], vim.split(q[1], q[2], { plain = q[3], trimempty = q[4] }), q[1])
end
-- Test old signature
@@ -603,8 +603,8 @@ describe('lua stdlib', function()
{ 'abc', '.-' },
}
for _, t in ipairs(loops) do
matches('Infinite loop detected', pcall_err(vim.split, t[1], t[2]))
for _, q in ipairs(loops) do
matches('Infinite loop detected', pcall_err(vim.split, q[1], q[2]))
end
-- Validates args.
@@ -626,8 +626,8 @@ describe('lua stdlib', function()
{ 'r\n', 'r' },
}
for _, t in ipairs(trims) do
assert(t[2], trim(t[1]))
for _, q in ipairs(trims) do
assert(q[2], trim(q[1]))
end
-- Validates args.
@@ -636,8 +636,8 @@ describe('lua stdlib', function()
it('vim.inspect', function()
-- just make sure it basically works, it has its own test suite
local inspect = function(t, opts)
return exec_lua('return vim.inspect(...)', t, opts)
local inspect = function(q, opts)
return exec_lua('return vim.inspect(...)', q, opts)
end
eq('2', inspect(2))
@@ -1569,7 +1569,7 @@ describe('lua stdlib', function()
eq(NIL, exec_lua([[return vim.g.Unknown_script_func]]))
-- Check if autoload works properly
local pathsep = helpers.get_pathsep()
local pathsep = t.get_pathsep()
local xconfig = 'Xhome' .. pathsep .. 'Xconfig'
local xdata = 'Xhome' .. pathsep .. 'Xdata'
local autoload_folder = table.concat({ xconfig, 'nvim', 'autoload' }, pathsep)
@@ -4071,7 +4071,7 @@ describe('vim.keymap', function()
feed('asdf\n')
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)
it('works with buffer-local mappings', function()
@@ -4095,7 +4095,7 @@ describe('vim.keymap', function()
feed('asdf\n')
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)
it('does not mutate the opts parameter', function()

View File

@@ -1,15 +1,15 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local exec_lua = helpers.exec_lua
local clear = helpers.clear
local is_ci = helpers.is_ci
local is_os = helpers.is_os
local skip = helpers.skip
local t = require('test.functional.testutil')(after_each)
local eq = t.eq
local exec_lua = t.exec_lua
local clear = t.clear
local is_ci = t.is_ci
local is_os = t.is_os
local skip = t.skip
-- Create a file via a rename to avoid multiple
-- events which can happen with some backends on some platforms
local function touch(path)
local tmp = helpers.tmpname()
local tmp = t.tmpname()
io.open(tmp, 'w'):close()
assert(vim.uv.fs_rename(tmp, path))
end
@@ -24,10 +24,7 @@ describe('vim._watch', function()
if watchfunc == 'fswatch' then
skip(is_os('win'), 'not supported on windows')
skip(is_os('mac'), 'flaky test on mac')
skip(
not is_ci() and helpers.fn.executable('fswatch') == 0,
'fswatch not installed and not on CI'
)
skip(not is_ci() and t.fn.executable('fswatch') == 0, 'fswatch not installed and not on CI')
end
if watchfunc == 'watch' then
@@ -40,7 +37,7 @@ describe('vim._watch', function()
)
end
local root_dir = vim.uv.fs_mkdtemp(vim.fs.dirname(helpers.tmpname()) .. '/nvim_XXXXXXXXXX')
local root_dir = vim.uv.fs_mkdtemp(vim.fs.dirname(t.tmpname()) .. '/nvim_XXXXXXXXXX')
local expected_events = 0

View File

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