From 0c59771e314d6faaad69676985cd2a11c157ee37 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 22 Mar 2024 11:02:52 +0100 Subject: refactor(tests): all screen tests should use highlights This is the first installment of a multi-PR series significantly refactoring how highlights are being specified. The end goal is to have a base set of 20 ish most common highlights, and then specific files only need to add more groups to that as needed. As a complicating factor, we also want to migrate to the new default color scheme eventually. But by sharing a base set, that future PR will hopefully be a lot smaller since a lot of tests will be migrated just simply by updating the base set in place. As a first step, fix the anti-pattern than Screen defaults to ignoring highlights. Highlights are integral part of the screen state, not something "extra" which we only test "sometimes". For now, we still allow opt-out via the intentionally ugly screen._default_attr_ids = nil The end goal is to get rid of all of these eventually (which will be easier as part of the color scheme migration) --- test/functional/vimscript/execute_spec.lua | 44 +++++++++++++++--------------- test/functional/vimscript/system_spec.lua | 18 ++++++------ 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua index 29488ed31c..ce66545c82 100644 --- a/test/functional/vimscript/execute_spec.lua +++ b/test/functional/vimscript/execute_spec.lua @@ -191,21 +191,21 @@ describe('execute()', function() feed([[:call Test1()]]) screen:expect([[ ^ | - ~ |*4 + {1:~ }|*4 ABCD | ]]) feed([[:call Test2()]]) screen:expect([[ ^ | - ~ |*4 + {1:~ }|*4 1234ABCD | ]]) feed([[:call Test3()]]) screen:expect([[ ^ | - ~ |*4 + {1:~ }|*4 1234ABCDXZYZ | ]]) @@ -215,39 +215,39 @@ describe('execute()', function() -- "ef" was overwritten since msg_col was recovered wrongly screen:expect([[ 1234 | - Error detected while processing function| - Test4: | - line 2: | - abcdABCD | - Press ENTER or type command to continue^ | + {9:Error detected while processing function}| + {9: Test4:} | + {8:line 2:} | + {9:abcd}ABCD | + {6:Press ENTER or type command to continue}^ | ]]) feed([[]]) -- to clear screen feed([[:call Test5()]]) screen:expect([[ ^ | - ~ |*4 + {1:~ }|*4 1234ABCD | ]]) feed([[:call Test6()]]) screen:expect([[ | - Error detected while processing function| - Test6: | - line 2: | - E121ABCD | - Press ENTER or type command to continue^ | + {9:Error detected while processing function}| + {9: Test6:} | + {8:line 2:} | + {9:E121}ABCD | + {6:Press ENTER or type command to continue}^ | ]]) feed([[:call Test7()]]) screen:expect([[ - Error detected while processing function| - Test6: | - line 2: | - E121ABCD | + {9:Error detected while processing function}| + {9: Test6:} | + {8:line 2:} | + {9:E121}ABCD | ABCD | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) end) @@ -265,7 +265,7 @@ describe('execute()', function() command('let g:mes = execute("echon 42", "")') screen:expect([[ ^ | - ~ |*3 + {1:~ }|*3 42 | ]]) eq('42', eval('g:mes')) @@ -289,7 +289,7 @@ describe('execute()', function() command('let g:mes = execute("echon 42")') screen:expect([[ ^ | - ~ |*3 + {1:~ }|*3 | ]]) eq('42', eval('g:mes')) @@ -298,7 +298,7 @@ describe('execute()', function() screen:expect { grid = [[ ^ | - ~ |*3 + {1:~ }|*3 | ]], unchanged = true, diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index d44f68e152..db27c5206f 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -214,7 +214,7 @@ describe('system()', function() feed(':call system("echo")') screen:expect([[ ^ | - ~ |*12 + {1:~ }|*12 :call system("echo") | ]]) end) @@ -262,14 +262,14 @@ describe('system()', function() ) screen:expect([[ | - ~ |*12 + {1:~ }|*12 ]] .. (is_os('win') and [[ :call system("for /L %I in (1,0,2) do @echo y") |]] or [[ :call system("yes") |]])) feed('foo') screen:expect([[ ^ | - ~ |*12 + {1:~ }|*12 Type :qa and press to exit Nvim | ]]) end) @@ -283,15 +283,15 @@ describe('system()', function() ) screen:expect([[ | - ~ |*12 + {1:~ }|*12 ]] .. (is_os('win') and [[ :call system("for /L %I in (1,0,2) do @echo y") |]] or [[ :call system("yes") |]])) feed('foo') screen:expect([[ ^ | - ~ |*12 - -- INSERT -- | + {1:~ }|*12 + {5:-- INSERT --} | ]]) end) end) @@ -447,7 +447,7 @@ describe('systemlist()', function() feed(':call systemlist("echo")') screen:expect([[ ^ | - ~ |*12 + {1:~ }|*12 :call systemlist("echo") | ]]) end) @@ -456,13 +456,13 @@ describe('systemlist()', function() feed(':call systemlist("yes | xargs")') screen:expect([[ | - ~ |*12 + {1:~ }|*12 :call systemlist("yes | xargs") | ]]) feed('') screen:expect([[ ^ | - ~ |*12 + {1:~ }|*12 Type :qa and press to exit Nvim | ]]) end) -- cgit From 35239e977f53c25016b57729cada612aa53e11d4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Mar 2024 09:29:21 +0800 Subject: test: use matches(...) instead of ok(string.find(...)) (#28111) --- test/functional/vimscript/reltime_spec.lua | 5 +++-- test/functional/vimscript/server_spec.lua | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/reltime_spec.lua b/test/functional/vimscript/reltime_spec.lua index 7cdb78e4ce..fc4dd0d87b 100644 --- a/test/functional/vimscript/reltime_spec.lua +++ b/test/functional/vimscript/reltime_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok local neq, command, fn = helpers.neq, helpers.command, helpers.fn +local matches = helpers.matches local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat describe('reltimestr(), reltimefloat()', function() @@ -15,7 +16,7 @@ describe('reltimestr(), reltimefloat()', function() neq('0.0', reltimestr(elapsed)) ok(reltimefloat(elapsed) > 0.0) -- original vim test for < 0.1, but easily fails on travis - ok(nil ~= string.match(reltimestr(elapsed), '0%.')) + matches('0%.', reltimestr(elapsed)) ok(reltimefloat(elapsed) < 1.0) local same = reltime(now, now) @@ -29,7 +30,7 @@ describe('reltimestr(), reltimefloat()', function() neq('0.0', reltimestr(differs)) ok(reltimefloat(differs) > 0.0) -- original vim test for < 0.1, but easily fails on travis - ok(nil ~= string.match(reltimestr(differs), '0%.')) + matches('0%.', reltimestr(differs)) ok(reltimefloat(differs) < 1.0) end) diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index 360fcf0dfe..c6c9e9c0ab 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -100,14 +100,14 @@ describe('server', function() local s = fn.serverstart('127.0.0.1:0') -- assign random port if #s > 0 then - assert(string.match(s, '127.0.0.1:%d+')) + matches('127.0.0.1:%d+', s) eq(s, fn.serverlist()[1]) clear_serverlist() end s = fn.serverstart('127.0.0.1:') -- assign random port if #s > 0 then - assert(string.match(s, '127.0.0.1:%d+')) + matches('127.0.0.1:%d+', s) eq(s, fn.serverlist()[1]) clear_serverlist() end -- cgit From a500c5f808ccf0b678c935f00e0af4503a5bd724 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 Apr 2024 18:04:45 +0800 Subject: vim-patch:8.1.0815: dialog for file changed outside of Vim not tested (#28184) Problem: Dialog for file changed outside of Vim not tested. Solution: Add a test. Move FileChangedShell test. Add 'L' flag to feedkeys(). https://github.com/vim/vim/commit/5e66b42aae7c67a3ef67617d4bd43052ac2b73ce Co-authored-by: Bram Moolenaar --- test/functional/vimscript/input_spec.lua | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index b749d5a7f0..d64ae3b0f1 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -8,7 +8,6 @@ local clear = helpers.clear local source = helpers.source local command = helpers.command local exc_exec = helpers.exc_exec -local pcall_err = helpers.pcall_err local async_meths = helpers.async_meths local NIL = vim.NIL @@ -407,7 +406,6 @@ describe('inputdialog()', function() end) describe('confirm()', function() - -- oldtest: Test_confirm() it('works', function() api.nvim_set_option_value('more', false, {}) -- Avoid hit-enter prompt api.nvim_set_option_value('laststatus', 2, {}) @@ -470,20 +468,6 @@ describe('confirm()', function() screen:expect({ any = '%[No Name%]' }) eq(1, api.nvim_get_var('a')) end - - eq('Vim(call):E730: Using a List as a String', pcall_err(command, 'call confirm([])')) - eq( - 'Vim(call):E730: Using a List as a String', - pcall_err(command, 'call confirm("Are you sure?", [])') - ) - eq( - 'Vim(call):E745: Using a List as a Number', - pcall_err(command, 'call confirm("Are you sure?", "&Yes\n&No\n", [])') - ) - eq( - 'Vim(call):E730: Using a List as a String', - pcall_err(command, 'call confirm("Are you sure?", "&Yes\n&No\n", 0, [])') - ) end) it('shows dialog even if :silent #8788', function() -- cgit From ae28ef327e02ac87ef26f941c401312ed0462d8c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Apr 2024 11:18:43 +0800 Subject: fix: adjust error message for error in UI event callback (#28200) Also close Nvim instance before removing log file, otherwise the Nvim instance will still write to the log file. Also adjust log level in libuv_process_spawn(). Ref #27660 --- test/functional/vimscript/server_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index c6c9e9c0ab..7a48633299 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -5,6 +5,7 @@ local clear, fn, api = helpers.clear, helpers.fn, helpers.api local ok = helpers.ok local matches = helpers.matches local pcall_err = helpers.pcall_err +local check_close = helpers.check_close local mkdir = helpers.mkdir local is_os = helpers.is_os @@ -18,6 +19,7 @@ end describe('server', function() after_each(function() + check_close() os.remove(testlog) end) -- cgit From 406ff528245145b386d1cbe08d59243a94d120de Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Apr 2024 15:19:13 +0800 Subject: test: fix vimscript/server_spec leaving behind a dir (#28204) --- test/functional/vimscript/server_spec.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index 7a48633299..f7fa4783a3 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -7,6 +7,7 @@ local matches = helpers.matches local pcall_err = helpers.pcall_err local check_close = helpers.check_close local mkdir = helpers.mkdir +local rmdir = helpers.rmdir local is_os = helpers.is_os local testlog = 'Xtest-server-log' @@ -26,6 +27,9 @@ describe('server', function() it('serverstart() stores sockets in $XDG_RUNTIME_DIR', function() local dir = 'Xtest_xdg_run' mkdir(dir) + finally(function() + rmdir(dir) + end) clear({ env = { XDG_RUNTIME_DIR = dir } }) matches(dir, fn.stdpath('run')) if not is_os('win') then -- cgit From 7035125b2b26aa68fcfb7cda39377ac79926a0f9 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 8 Apr 2024 11:03:20 +0200 Subject: test: improve test conventions Work on https://github.com/neovim/neovim/issues/27004. --- test/functional/vimscript/api_functions_spec.lua | 18 ++++---- test/functional/vimscript/buf_functions_spec.lua | 22 ++++----- test/functional/vimscript/changedtick_spec.lua | 22 ++++----- .../vimscript/container_functions_spec.lua | 10 ++-- test/functional/vimscript/ctx_functions_spec.lua | 28 +++++------ test/functional/vimscript/environ_spec.lua | 20 ++++---- test/functional/vimscript/errorlist_spec.lua | 20 ++++---- test/functional/vimscript/eval_spec.lua | 50 ++++++++++---------- test/functional/vimscript/executable_spec.lua | 11 ++--- test/functional/vimscript/execute_spec.lua | 22 ++++----- test/functional/vimscript/exepath_spec.lua | 16 +++---- test/functional/vimscript/fnamemodify_spec.lua | 20 ++++---- test/functional/vimscript/functions_spec.lua | 10 ++-- test/functional/vimscript/getline_spec.lua | 10 ++-- test/functional/vimscript/glob_spec.lua | 6 +-- test/functional/vimscript/has_spec.lua | 14 +++--- test/functional/vimscript/hostname_spec.lua | 12 ++--- test/functional/vimscript/input_spec.lua | 18 ++++---- test/functional/vimscript/json_functions_spec.lua | 20 ++++---- test/functional/vimscript/lang_spec.lua | 6 +-- test/functional/vimscript/let_spec.lua | 22 ++++----- test/functional/vimscript/map_functions_spec.lua | 30 ++++++------ test/functional/vimscript/match_functions_spec.lua | 12 ++--- .../functional/vimscript/minmax_functions_spec.lua | 14 +++--- test/functional/vimscript/modeline_spec.lua | 8 ++-- .../vimscript/msgpack_functions_spec.lua | 20 ++++---- test/functional/vimscript/null_spec.lua | 14 +++--- test/functional/vimscript/operators_spec.lua | 8 ++-- test/functional/vimscript/printf_spec.lua | 14 +++--- test/functional/vimscript/reltime_spec.lua | 8 ++-- test/functional/vimscript/screenchar_spec.lua | 6 +-- test/functional/vimscript/screenpos_spec.lua | 8 ++-- test/functional/vimscript/server_spec.lua | 26 +++++------ test/functional/vimscript/setpos_spec.lua | 18 ++++---- test/functional/vimscript/sort_spec.lua | 18 ++++---- test/functional/vimscript/special_vars_spec.lua | 16 +++---- test/functional/vimscript/state_spec.lua | 16 +++---- test/functional/vimscript/string_spec.lua | 22 ++++----- test/functional/vimscript/system_spec.lua | 54 ++++++++++------------ test/functional/vimscript/timer_spec.lua | 16 +++---- test/functional/vimscript/uniq_spec.lua | 12 ++--- test/functional/vimscript/vvar_event_spec.lua | 6 +-- test/functional/vimscript/wait_spec.lua | 26 +++++------ test/functional/vimscript/writefile_spec.lua | 22 ++++----- 44 files changed, 382 insertions(+), 389 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 4985768bb0..10a98b646e 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -1,13 +1,13 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local neq, eq, command = helpers.neq, helpers.eq, helpers.command -local clear = helpers.clear -local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval -local exec_lua = helpers.exec_lua -local insert, pcall_err = helpers.insert, helpers.pcall_err -local matches = helpers.matches -local api = helpers.api -local feed = helpers.feed +local neq, eq, command = t.neq, t.eq, t.command +local clear = t.clear +local exc_exec, expect, eval = t.exc_exec, t.expect, t.eval +local exec_lua = t.exec_lua +local insert, pcall_err = t.insert, t.pcall_err +local matches = t.matches +local api = t.api +local feed = t.feed describe('eval-API', function() before_each(clear) diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index 931fe640a9..5cecafa370 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -1,15 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local eq = helpers.eq -local clear = helpers.clear -local fn = helpers.fn -local api = helpers.api -local command = helpers.command -local exc_exec = helpers.exc_exec -local get_pathsep = helpers.get_pathsep -local rmdir = helpers.rmdir -local pcall_err = helpers.pcall_err -local mkdir = helpers.mkdir +local eq = t.eq +local clear = t.clear +local fn = t.fn +local api = t.api +local command = t.command +local exc_exec = t.exc_exec +local get_pathsep = t.get_pathsep +local rmdir = t.rmdir +local pcall_err = t.pcall_err +local mkdir = t.mkdir local fname = 'Xtest-functional-eval-buf_functions' local fname2 = fname .. '.2' diff --git a/test/functional/vimscript/changedtick_spec.lua b/test/functional/vimscript/changedtick_spec.lua index 85928921c5..09aaea900b 100644 --- a/test/functional/vimscript/changedtick_spec.lua +++ b/test/functional/vimscript/changedtick_spec.lua @@ -1,15 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local eq = helpers.eq -local eval = helpers.eval -local feed = helpers.feed -local clear = helpers.clear -local fn = helpers.fn -local api = helpers.api -local command = helpers.command -local exc_exec = helpers.exc_exec -local pcall_err = helpers.pcall_err -local exec_capture = helpers.exec_capture +local eq = t.eq +local eval = t.eval +local feed = t.feed +local clear = t.clear +local fn = t.fn +local api = t.api +local command = t.command +local exc_exec = t.exc_exec +local pcall_err = t.pcall_err +local exec_capture = t.exec_capture before_each(clear) diff --git a/test/functional/vimscript/container_functions_spec.lua b/test/functional/vimscript/container_functions_spec.lua index 1b34ea0165..c3acaa710f 100644 --- a/test/functional/vimscript/container_functions_spec.lua +++ b/test/functional/vimscript/container_functions_spec.lua @@ -1,9 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local eq = helpers.eq -local eval = helpers.eval -local api = helpers.api -local clear = helpers.clear +local eq = t.eq +local eval = t.eval +local api = t.api +local clear = t.clear before_each(clear) diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua index dc60a474f3..c82ce350b3 100644 --- a/test/functional/vimscript/ctx_functions_spec.lua +++ b/test/functional/vimscript/ctx_functions_spec.lua @@ -1,19 +1,19 @@ -local helpers = require('test.functional.helpers')(after_each) - -local call = helpers.call -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local eval = helpers.eval -local feed = helpers.feed +local t = require('test.functional.testutil')(after_each) + +local call = t.call +local clear = t.clear +local command = t.command +local eq = t.eq +local eval = t.eval +local feed = t.feed local map = vim.tbl_map -local api = helpers.api -local parse_context = helpers.parse_context -local exec_capture = helpers.exec_capture -local source = helpers.source +local api = t.api +local parse_context = t.parse_context +local exec_capture = t.exec_capture +local source = t.source local trim = vim.trim -local write_file = helpers.write_file -local pcall_err = helpers.pcall_err +local write_file = t.write_file +local pcall_err = t.pcall_err describe('context functions', function() local fname1 = 'Xtest-functional-eval-ctx1' diff --git a/test/functional/vimscript/environ_spec.lua b/test/functional/vimscript/environ_spec.lua index 0763def84e..b4c7b30421 100644 --- a/test/functional/vimscript/environ_spec.lua +++ b/test/functional/vimscript/environ_spec.lua @@ -1,13 +1,13 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local environ = helpers.fn.environ -local exists = helpers.fn.exists -local system = helpers.fn.system -local nvim_prog = helpers.nvim_prog -local command = helpers.command -local eval = helpers.eval -local setenv = helpers.fn.setenv +local t = require('test.functional.testutil')(after_each) +local clear = t.clear +local eq = t.eq +local environ = t.fn.environ +local exists = t.fn.exists +local system = t.fn.system +local nvim_prog = t.nvim_prog +local command = t.command +local eval = t.eval +local setenv = t.fn.setenv describe('environment variables', function() it('environ() handles empty env variable', function() diff --git a/test/functional/vimscript/errorlist_spec.lua b/test/functional/vimscript/errorlist_spec.lua index 1e405e7e64..5fcdc65de1 100644 --- a/test/functional/vimscript/errorlist_spec.lua +++ b/test/functional/vimscript/errorlist_spec.lua @@ -1,13 +1,13 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local exc_exec = helpers.exc_exec -local get_win_var = helpers.api.nvim_win_get_var +local clear = t.clear +local command = t.command +local eq = t.eq +local exc_exec = t.exc_exec +local get_win_var = t.api.nvim_win_get_var describe('setqflist()', function() - local setqflist = helpers.fn.setqflist + local setqflist = t.fn.setqflist before_each(clear) @@ -46,7 +46,7 @@ describe('setqflist()', function() end) describe('setloclist()', function() - local setloclist = helpers.fn.setloclist + local setloclist = t.fn.setloclist before_each(clear) @@ -73,7 +73,7 @@ describe('setloclist()', function() end) it("doesn't crash when when window is closed in the middle #13721", function() - helpers.insert([[ + t.insert([[ hello world]]) command('vsplit') @@ -82,6 +82,6 @@ describe('setloclist()', function() command('call setloclist(0, [])') command('lopen') - helpers.assert_alive() + t.assert_alive() end) end) diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index e337959810..0918c5957a 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -9,37 +9,37 @@ -- test/functional/vimscript/_spec.lua -- test/functional/vimscript/functions_spec.lua -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local mkdir = helpers.mkdir -local clear = helpers.clear -local eq = helpers.eq -local exec = helpers.exec -local exc_exec = helpers.exc_exec -local exec_lua = helpers.exec_lua -local exec_capture = helpers.exec_capture -local eval = helpers.eval -local command = helpers.command -local write_file = helpers.write_file -local api = helpers.api +local mkdir = t.mkdir +local clear = t.clear +local eq = t.eq +local exec = t.exec +local exc_exec = t.exc_exec +local exec_lua = t.exec_lua +local exec_capture = t.exec_capture +local eval = t.eval +local command = t.command +local write_file = t.write_file +local api = t.api local sleep = vim.uv.sleep -local matches = helpers.matches -local pcall_err = helpers.pcall_err -local assert_alive = helpers.assert_alive -local poke_eventloop = helpers.poke_eventloop -local feed = helpers.feed -local expect_exit = helpers.expect_exit +local matches = t.matches +local pcall_err = t.pcall_err +local assert_alive = t.assert_alive +local poke_eventloop = t.poke_eventloop +local feed = t.feed +local expect_exit = t.expect_exit describe('Up to MAX_FUNC_ARGS arguments are handled by', function() local max_func_args = 20 -- from eval.h - local range = helpers.fn.range + local range = t.fn.range before_each(clear) it('printf()', function() - local printf = helpers.fn.printf - local rep = helpers.fn['repeat'] + local printf = t.fn.printf + local rep = t.fn['repeat'] local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,' eq(expected, printf(rep('%d,', max_func_args - 1), unpack(range(2, max_func_args)))) local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -47,7 +47,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function() end) it('rpcnotify()', function() - local rpcnotify = helpers.fn.rpcnotify + local rpcnotify = t.fn.rpcnotify local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args))) eq(1, ret) ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -69,17 +69,17 @@ describe('backtick expansion', function() end) teardown(function() - helpers.rmdir('test-backticks') + t.rmdir('test-backticks') end) it("with default 'shell'", function() - if helpers.is_os('win') then + if t.is_os('win') then command(':silent args `dir /b *2`') else command(':silent args `echo ***2`') end eq({ 'file2' }, eval('argv()')) - if helpers.is_os('win') then + if t.is_os('win') then command(':silent args `dir /s/b *4`') eq({ 'subdir\\file4' }, eval('map(argv(), \'fnamemodify(v:val, ":.")\')')) else diff --git a/test/functional/vimscript/executable_spec.lua b/test/functional/vimscript/executable_spec.lua index 1d95f6088e..de16563eed 100644 --- a/test/functional/vimscript/executable_spec.lua +++ b/test/functional/vimscript/executable_spec.lua @@ -1,9 +1,8 @@ -local helpers = require('test.functional.helpers')(after_each) -local eq, clear, call, write_file, command = - helpers.eq, helpers.clear, helpers.call, helpers.write_file, helpers.command -local exc_exec = helpers.exc_exec -local eval = helpers.eval -local is_os = helpers.is_os +local t = require('test.functional.testutil')(after_each) +local eq, clear, call, write_file, command = t.eq, t.clear, t.call, t.write_file, t.command +local exc_exec = t.exc_exec +local eval = t.eval +local is_os = t.is_os describe('executable()', function() before_each(clear) diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua index ce66545c82..b765f50fe4 100644 --- a/test/functional/vimscript/execute_spec.lua +++ b/test/functional/vimscript/execute_spec.lua @@ -1,15 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) -local eq = helpers.eq -local eval = helpers.eval -local clear = helpers.clear -local source = helpers.source -local exc_exec = helpers.exc_exec -local pcall_err = helpers.pcall_err -local fn = helpers.fn +local t = require('test.functional.testutil')(after_each) +local eq = t.eq +local eval = t.eval +local clear = t.clear +local source = t.source +local exc_exec = t.exc_exec +local pcall_err = t.pcall_err +local fn = t.fn local Screen = require('test.functional.ui.screen') -local command = helpers.command -local feed = helpers.feed -local is_os = helpers.is_os +local command = t.command +local feed = t.feed +local is_os = t.is_os describe('execute()', function() before_each(clear) diff --git a/test/functional/vimscript/exepath_spec.lua b/test/functional/vimscript/exepath_spec.lua index 01033a2140..57242a2483 100644 --- a/test/functional/vimscript/exepath_spec.lua +++ b/test/functional/vimscript/exepath_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) -local eq, clear, call = helpers.eq, helpers.clear, helpers.call -local command = helpers.command -local exc_exec = helpers.exc_exec -local matches = helpers.matches -local is_os = helpers.is_os -local set_shell_powershell = helpers.set_shell_powershell -local eval = helpers.eval +local t = require('test.functional.testutil')(after_each) +local eq, clear, call = t.eq, t.clear, t.call +local command = t.command +local exc_exec = t.exc_exec +local matches = t.matches +local is_os = t.is_os +local set_shell_powershell = t.set_shell_powershell +local eval = t.eval local find_dummies = function(ext_pat) local tmp_path = eval('$PATH') diff --git a/test/functional/vimscript/fnamemodify_spec.lua b/test/functional/vimscript/fnamemodify_spec.lua index 4a134fe23c..0706a60f57 100644 --- a/test/functional/vimscript/fnamemodify_spec.lua +++ b/test/functional/vimscript/fnamemodify_spec.lua @@ -1,12 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local fnamemodify = helpers.fn.fnamemodify -local getcwd = helpers.fn.getcwd -local command = helpers.command -local write_file = helpers.write_file -local alter_slashes = helpers.alter_slashes -local is_os = helpers.is_os +local t = require('test.functional.testutil')(after_each) +local clear = t.clear +local eq = t.eq +local fnamemodify = t.fn.fnamemodify +local getcwd = t.fn.getcwd +local command = t.command +local write_file = t.write_file +local alter_slashes = t.alter_slashes +local is_os = t.is_os local function eq_slashconvert(expected, got) eq(alter_slashes(expected), alter_slashes(got)) @@ -24,7 +24,7 @@ describe('fnamemodify()', function() end) it('handles the root path', function() - local root = helpers.pathroot() + local root = t.pathroot() eq(root, fnamemodify([[/]], ':p:h')) eq(root, fnamemodify([[/]], ':p')) if is_os('win') then diff --git a/test/functional/vimscript/functions_spec.lua b/test/functional/vimscript/functions_spec.lua index 09b3334989..cb4d329ae9 100644 --- a/test/functional/vimscript/functions_spec.lua +++ b/test/functional/vimscript/functions_spec.lua @@ -5,12 +5,12 @@ -- -- Core "eval" tests live in eval_spec.lua. -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local clear = helpers.clear -local eval = helpers.eval -local matches = helpers.matches -local is_os = helpers.is_os +local clear = t.clear +local eval = t.eval +local matches = t.matches +local is_os = t.is_os before_each(clear) diff --git a/test/functional/vimscript/getline_spec.lua b/test/functional/vimscript/getline_spec.lua index 08e7711b8c..600730c010 100644 --- a/test/functional/vimscript/getline_spec.lua +++ b/test/functional/vimscript/getline_spec.lua @@ -1,9 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local call = helpers.call -local clear = helpers.clear -local eq = helpers.eq -local expect = helpers.expect +local call = t.call +local clear = t.clear +local eq = t.eq +local expect = t.expect describe('getline()', function() before_each(function() diff --git a/test/functional/vimscript/glob_spec.lua b/test/functional/vimscript/glob_spec.lua index 77351f95fa..708b976dbb 100644 --- a/test/functional/vimscript/glob_spec.lua +++ b/test/functional/vimscript/glob_spec.lua @@ -1,6 +1,6 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, command, eval, eq = helpers.clear, helpers.command, helpers.eval, helpers.eq -local mkdir = helpers.mkdir +local t = require('test.functional.testutil')(after_each) +local clear, command, eval, eq = t.clear, t.command, t.eval, t.eq +local mkdir = t.mkdir before_each(function() clear() diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua index 82b3db5b67..08193f8d02 100644 --- a/test/functional/vimscript/has_spec.lua +++ b/test/functional/vimscript/has_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local connect = helpers.connect -local eq = helpers.eq -local fn = helpers.fn -local is_os = helpers.is_os -local nvim_prog = helpers.nvim_prog +local clear = t.clear +local connect = t.connect +local eq = t.eq +local fn = t.fn +local is_os = t.is_os +local nvim_prog = t.nvim_prog describe('has()', function() before_each(clear) diff --git a/test/functional/vimscript/hostname_spec.lua b/test/functional/vimscript/hostname_spec.lua index 62520e8222..024997f6b0 100644 --- a/test/functional/vimscript/hostname_spec.lua +++ b/test/functional/vimscript/hostname_spec.lua @@ -1,9 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) -local eq = helpers.eq -local ok = helpers.ok -local call = helpers.call -local clear = helpers.clear -local is_os = helpers.is_os +local t = require('test.functional.testutil')(after_each) +local eq = t.eq +local ok = t.ok +local call = t.call +local clear = t.clear +local is_os = t.is_os describe('hostname()', function() before_each(clear) diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index d64ae3b0f1..0ac22c7320 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -1,14 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local eq = helpers.eq -local feed = helpers.feed -local api = helpers.api -local clear = helpers.clear -local source = helpers.source -local command = helpers.command -local exc_exec = helpers.exc_exec -local async_meths = helpers.async_meths +local eq = t.eq +local feed = t.feed +local api = t.api +local clear = t.clear +local source = t.source +local command = t.command +local exc_exec = t.exc_exec +local async_meths = t.async_meths local NIL = vim.NIL local screen diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua index ef0359263e..e4a9c41d59 100644 --- a/test/functional/vimscript/json_functions_spec.lua +++ b/test/functional/vimscript/json_functions_spec.lua @@ -1,14 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local fn = helpers.fn -local api = helpers.api -local eq = helpers.eq -local eval = helpers.eval -local command = helpers.command -local exc_exec = helpers.exc_exec -local pcall_err = helpers.pcall_err +local t = require('test.functional.testutil')(after_each) +local clear = t.clear +local fn = t.fn +local api = t.api +local eq = t.eq +local eval = t.eval +local command = t.command +local exc_exec = t.exc_exec +local pcall_err = t.pcall_err local NIL = vim.NIL -local source = helpers.source +local source = t.source describe('json_decode() function', function() local restart = function(...) diff --git a/test/functional/vimscript/lang_spec.lua b/test/functional/vimscript/lang_spec.lua index 2dde90e334..cad3df9aef 100644 --- a/test/functional/vimscript/lang_spec.lua +++ b/test/functional/vimscript/lang_spec.lua @@ -1,6 +1,6 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq -local exc_exec, source = helpers.exc_exec, helpers.source +local t = require('test.functional.testutil')(after_each) +local clear, eval, eq = t.clear, t.eval, t.eq +local exc_exec, source = t.exc_exec, t.source describe('vimscript', function() before_each(clear) diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index 15d4b189b8..bcfd12cbe8 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -1,15 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local eq = helpers.eq -local clear = helpers.clear -local command = helpers.command -local eval = helpers.eval -local api = helpers.api -local exec = helpers.exec -local exec_capture = helpers.exec_capture -local expect_exit = helpers.expect_exit -local source = helpers.source -local testprg = helpers.testprg +local eq = t.eq +local clear = t.clear +local command = t.command +local eval = t.eval +local api = t.api +local exec = t.exec +local exec_capture = t.exec_capture +local expect_exit = t.expect_exit +local source = t.source +local testprg = t.testprg before_each(clear) diff --git a/test/functional/vimscript/map_functions_spec.lua b/test/functional/vimscript/map_functions_spec.lua index 59d427ca90..fba3a627e9 100644 --- a/test/functional/vimscript/map_functions_spec.lua +++ b/test/functional/vimscript/map_functions_spec.lua @@ -1,18 +1,18 @@ -local helpers = require('test.functional.helpers')(after_each) - -local clear = helpers.clear -local eq = helpers.eq -local eval = helpers.eval -local exec = helpers.exec -local exec_lua = helpers.exec_lua -local expect = helpers.expect -local feed = helpers.feed -local fn = helpers.fn -local api = helpers.api -local source = helpers.source -local command = helpers.command -local exec_capture = helpers.exec_capture -local pcall_err = helpers.pcall_err +local t = require('test.functional.testutil')(after_each) + +local clear = t.clear +local eq = t.eq +local eval = t.eval +local exec = t.exec +local exec_lua = t.exec_lua +local expect = t.expect +local feed = t.feed +local fn = t.fn +local api = t.api +local source = t.source +local command = t.command +local exec_capture = t.exec_capture +local pcall_err = t.pcall_err describe('maparg()', function() before_each(clear) diff --git a/test/functional/vimscript/match_functions_spec.lua b/test/functional/vimscript/match_functions_spec.lua index 3db612e472..2bff221c0b 100644 --- a/test/functional/vimscript/match_functions_spec.lua +++ b/test/functional/vimscript/match_functions_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local eq = helpers.eq -local clear = helpers.clear -local fn = helpers.fn -local command = helpers.command -local exc_exec = helpers.exc_exec +local eq = t.eq +local clear = t.clear +local fn = t.fn +local command = t.command +local exc_exec = t.exc_exec before_each(clear) diff --git a/test/functional/vimscript/minmax_functions_spec.lua b/test/functional/vimscript/minmax_functions_spec.lua index c4a986bc8c..dbdfc06afb 100644 --- a/test/functional/vimscript/minmax_functions_spec.lua +++ b/test/functional/vimscript/minmax_functions_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local eq = helpers.eq -local eval = helpers.eval -local command = helpers.command -local clear = helpers.clear -local fn = helpers.fn -local pcall_err = helpers.pcall_err +local eq = t.eq +local eval = t.eval +local command = t.command +local clear = t.clear +local fn = t.fn +local pcall_err = t.pcall_err before_each(clear) for _, func in ipairs({ 'min', 'max' }) do diff --git a/test/functional/vimscript/modeline_spec.lua b/test/functional/vimscript/modeline_spec.lua index ae63a66f43..fde6dbef30 100644 --- a/test/functional/vimscript/modeline_spec.lua +++ b/test/functional/vimscript/modeline_spec.lua @@ -1,9 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) -local assert_alive = helpers.assert_alive -local clear, command, write_file = helpers.clear, helpers.command, helpers.write_file +local t = require('test.functional.testutil')(after_each) +local assert_alive = t.assert_alive +local clear, command, write_file = t.clear, t.command, t.write_file describe('modeline', function() - local tempfile = helpers.tmpname() + local tempfile = t.tmpname() before_each(clear) after_each(function() diff --git a/test/functional/vimscript/msgpack_functions_spec.lua b/test/functional/vimscript/msgpack_functions_spec.lua index 609a706155..55540712d7 100644 --- a/test/functional/vimscript/msgpack_functions_spec.lua +++ b/test/functional/vimscript/msgpack_functions_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local fn = helpers.fn -local eval, eq = helpers.eval, helpers.eq -local command = helpers.command -local api = helpers.api -local exc_exec = helpers.exc_exec -local is_os = helpers.is_os +local t = require('test.functional.testutil')(after_each) +local clear = t.clear +local fn = t.fn +local eval, eq = t.eval, t.eq +local command = t.command +local api = t.api +local exc_exec = t.exc_exec +local is_os = t.is_os describe('msgpack*() functions', function() before_each(clear) @@ -469,12 +469,12 @@ describe('msgpackparse() function', function() end) it('msgpackparse(systemlist(...)) does not segfault. #3135', function() - local cmd = "sort(keys(msgpackparse(systemlist('" .. helpers.nvim_prog .. " --api-info'))[0]))" + local cmd = "sort(keys(msgpackparse(systemlist('" .. t.nvim_prog .. " --api-info'))[0]))" eval(cmd) eval(cmd) -- do it again (try to force segfault) local api_info = eval(cmd) -- do it again if is_os('win') then - helpers.assert_alive() + t.assert_alive() pending('msgpackparse() has a bug on windows') return end diff --git a/test/functional/vimscript/null_spec.lua b/test/functional/vimscript/null_spec.lua index 805cd13844..99abc9bcf4 100644 --- a/test/functional/vimscript/null_spec.lua +++ b/test/functional/vimscript/null_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local exc_exec = helpers.exc_exec -local command = helpers.command -local clear = helpers.clear -local api = helpers.api -local fn = helpers.fn -local eq = helpers.eq +local exc_exec = t.exc_exec +local command = t.command +local clear = t.clear +local api = t.api +local fn = t.fn +local eq = t.eq local function redir_exec(cmd) api.nvim_set_var('__redir_exec_cmd', cmd) diff --git a/test/functional/vimscript/operators_spec.lua b/test/functional/vimscript/operators_spec.lua index 64f6b60238..e3357d1dfd 100644 --- a/test/functional/vimscript/operators_spec.lua +++ b/test/functional/vimscript/operators_spec.lua @@ -1,7 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) -local eq = helpers.eq -local eval = helpers.eval -local clear = helpers.clear +local t = require('test.functional.testutil')(after_each) +local eq = t.eq +local eval = t.eval +local clear = t.clear describe('Division operator', function() before_each(clear) diff --git a/test/functional/vimscript/printf_spec.lua b/test/functional/vimscript/printf_spec.lua index 4fa4ea7f4c..365c10119a 100644 --- a/test/functional/vimscript/printf_spec.lua +++ b/test/functional/vimscript/printf_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local eval = helpers.eval -local fn = helpers.fn -local api = helpers.api -local exc_exec = helpers.exc_exec +local clear = t.clear +local eq = t.eq +local eval = t.eval +local fn = t.fn +local api = t.api +local exc_exec = t.exc_exec describe('printf()', function() before_each(clear) diff --git a/test/functional/vimscript/reltime_spec.lua b/test/functional/vimscript/reltime_spec.lua index fc4dd0d87b..22c0bd5bb9 100644 --- a/test/functional/vimscript/reltime_spec.lua +++ b/test/functional/vimscript/reltime_spec.lua @@ -1,7 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok -local neq, command, fn = helpers.neq, helpers.command, helpers.fn -local matches = helpers.matches +local t = require('test.functional.testutil')(after_each) +local clear, eq, ok = t.clear, t.eq, t.ok +local neq, command, fn = t.neq, t.command, t.fn +local matches = t.matches local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat describe('reltimestr(), reltimefloat()', function() diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua index 48b6893865..08341193e0 100644 --- a/test/functional/vimscript/screenchar_spec.lua +++ b/test/functional/vimscript/screenchar_spec.lua @@ -1,6 +1,6 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq -local command, api, fn = helpers.command, helpers.api, helpers.fn +local t = require('test.functional.testutil')(after_each) +local clear, eq, neq = t.clear, t.eq, t.neq +local command, api, fn = t.command, t.api, t.fn local tbl_deep_extend = vim.tbl_deep_extend -- Set up two overlapping floating windows diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua index b951d830a6..8c43a12810 100644 --- a/test/functional/vimscript/screenpos_spec.lua +++ b/test/functional/vimscript/screenpos_spec.lua @@ -1,7 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, eq, api = helpers.clear, helpers.eq, helpers.api -local command, fn = helpers.command, helpers.fn -local feed = helpers.feed +local t = require('test.functional.testutil')(after_each) +local clear, eq, api = t.clear, t.eq, t.api +local command, fn = t.command, t.fn +local feed = t.feed before_each(clear) diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index f7fa4783a3..9b2c2eaf65 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -1,14 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) -local assert_log = helpers.assert_log -local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval -local clear, fn, api = helpers.clear, helpers.fn, helpers.api -local ok = helpers.ok -local matches = helpers.matches -local pcall_err = helpers.pcall_err -local check_close = helpers.check_close -local mkdir = helpers.mkdir -local rmdir = helpers.rmdir -local is_os = helpers.is_os +local t = require('test.functional.testutil')(after_each) +local assert_log = t.assert_log +local eq, neq, eval = t.eq, t.neq, t.eval +local clear, fn, api = t.clear, t.fn, t.api +local ok = t.ok +local matches = t.matches +local pcall_err = t.pcall_err +local check_close = t.check_close +local mkdir = t.mkdir +local rmdir = t.rmdir +local is_os = t.is_os local testlog = 'Xtest-server-log' @@ -176,11 +176,11 @@ end) describe('startup --listen', function() it('validates', function() clear() - local cmd = { unpack(helpers.nvim_argv) } + local cmd = { unpack(t.nvim_argv) } table.insert(cmd, '--listen') matches('nvim.*: Argument missing after: "%-%-listen"', fn.system(cmd)) - cmd = { unpack(helpers.nvim_argv) } + cmd = { unpack(t.nvim_argv) } table.insert(cmd, '--listen2') matches('nvim.*: Garbage after option argument: "%-%-listen2"', fn.system(cmd)) end) diff --git a/test/functional/vimscript/setpos_spec.lua b/test/functional/vimscript/setpos_spec.lua index a26e48f469..6398aba79d 100644 --- a/test/functional/vimscript/setpos_spec.lua +++ b/test/functional/vimscript/setpos_spec.lua @@ -1,12 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) -local setpos = helpers.fn.setpos -local getpos = helpers.fn.getpos -local insert = helpers.insert -local clear = helpers.clear -local command = helpers.command -local eval = helpers.eval -local eq = helpers.eq -local exc_exec = helpers.exc_exec +local t = require('test.functional.testutil')(after_each) +local setpos = t.fn.setpos +local getpos = t.fn.getpos +local insert = t.insert +local clear = t.clear +local command = t.command +local eval = t.eval +local eq = t.eq +local exc_exec = t.exc_exec describe('setpos() function', function() before_each(function() diff --git a/test/functional/vimscript/sort_spec.lua b/test/functional/vimscript/sort_spec.lua index bd3d0da146..b1fa88e329 100644 --- a/test/functional/vimscript/sort_spec.lua +++ b/test/functional/vimscript/sort_spec.lua @@ -1,14 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local eq = helpers.eq +local eq = t.eq local NIL = vim.NIL -local eval = helpers.eval -local clear = helpers.clear -local api = helpers.api -local fn = helpers.fn -local command = helpers.command -local exc_exec = helpers.exc_exec -local pcall_err = helpers.pcall_err +local eval = t.eval +local clear = t.clear +local api = t.api +local fn = t.fn +local command = t.command +local exc_exec = t.exc_exec +local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/vimscript/special_vars_spec.lua b/test/functional/vimscript/special_vars_spec.lua index 590d409141..79ec76f622 100644 --- a/test/functional/vimscript/special_vars_spec.lua +++ b/test/functional/vimscript/special_vars_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) -local exc_exec = helpers.exc_exec -local command = helpers.command -local fn = helpers.fn -local clear = helpers.clear -local eval = helpers.eval -local eq = helpers.eq -local api = helpers.api +local t = require('test.functional.testutil')(after_each) +local exc_exec = t.exc_exec +local command = t.command +local fn = t.fn +local clear = t.clear +local eval = t.eval +local eq = t.eq +local api = t.api local NIL = vim.NIL describe('Special values', function() diff --git a/test/functional/vimscript/state_spec.lua b/test/functional/vimscript/state_spec.lua index 7179806e36..f5f9b829f8 100644 --- a/test/functional/vimscript/state_spec.lua +++ b/test/functional/vimscript/state_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local exec = helpers.exec -local exec_lua = helpers.exec_lua -local feed = helpers.feed -local api = helpers.api -local poke_eventloop = helpers.poke_eventloop +local t = require('test.functional.testutil')(after_each) +local clear = t.clear +local eq = t.eq +local exec = t.exec +local exec_lua = t.exec_lua +local feed = t.feed +local api = t.api +local poke_eventloop = t.poke_eventloop before_each(clear) diff --git a/test/functional/vimscript/string_spec.lua b/test/functional/vimscript/string_spec.lua index 6a7fe1bad9..859757c93c 100644 --- a/test/functional/vimscript/string_spec.lua +++ b/test/functional/vimscript/string_spec.lua @@ -1,14 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local command = helpers.command -local api = helpers.api -local eval = helpers.eval -local exc_exec = helpers.exc_exec -local pcall_err = helpers.pcall_err -local fn = helpers.fn +local t = require('test.functional.testutil')(after_each) +local clear = t.clear +local eq = t.eq +local command = t.command +local api = t.api +local eval = t.eval +local exc_exec = t.exc_exec +local pcall_err = t.pcall_err +local fn = t.fn local NIL = vim.NIL -local source = helpers.source +local source = t.source describe('string() function', function() before_each(clear) @@ -190,7 +190,7 @@ describe('string() function', function() eval('add(l, l)') -- Regression: the below line used to crash (add returns original list and -- there was error in dumping partials). Tested explicitly in - -- test/unit/api/private_helpers_spec.lua. + -- test/unit/api/private_t_spec.lua. eval('add(l, function("Test1", l))') eq( [=[Vim(echo):E724: unable to correctly dump variable with self-referencing container]=], diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index db27c5206f..1cbe9422e2 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -1,24 +1,18 @@ -- Tests for system() and :! shell. -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local assert_alive = helpers.assert_alive -local testprg = helpers.testprg +local assert_alive = t.assert_alive +local testprg = t.testprg local eq, call, clear, eval, feed_command, feed, api = - helpers.eq, - helpers.call, - helpers.clear, - helpers.eval, - helpers.feed_command, - helpers.feed, - helpers.api -local command = helpers.command -local insert = helpers.insert -local expect = helpers.expect -local exc_exec = helpers.exc_exec -local os_kill = helpers.os_kill -local pcall_err = helpers.pcall_err -local is_os = helpers.is_os + t.eq, t.call, t.clear, t.eval, t.feed_command, t.feed, t.api +local command = t.command +local insert = t.insert +local expect = t.expect +local exc_exec = t.exc_exec +local os_kill = t.os_kill +local pcall_err = t.pcall_err +local is_os = t.is_os local Screen = require('test.functional.ui.screen') @@ -189,7 +183,7 @@ describe('system()', function() end) it('with powershell', function() - helpers.set_shell_powershell() + t.set_shell_powershell() eq('a\nb\n', eval([[system('Write-Output a b')]])) eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]])) eq('a b\n', eval([[system('Write-Output "a b"')]])) @@ -197,11 +191,11 @@ describe('system()', function() end it('powershell w/ UTF-8 text #13713', function() - if not helpers.has_powershell() then + if not t.has_powershell() then pending('powershell not found', function() end) return end - helpers.set_shell_powershell() + t.set_shell_powershell() eq('ああ\n', eval([[system('Write-Output "ああ"')]])) -- Sanity test w/ default encoding -- * on Windows, expected to default to Western European enc @@ -234,7 +228,7 @@ describe('system()', function() end) it('self and total time recorded separately', function() - local tempfile = helpers.tmpname() + local tempfile = t.tmpname() feed(':function! AlmostNoSelfTime()') feed('echo system("echo hi")') @@ -247,11 +241,11 @@ describe('system()', function() feed(':edit ' .. tempfile .. '') - local command_total_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[2]) - local command_self_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[3]) + local command_total_time = tonumber(t.fn.split(t.fn.getline(7))[2]) + local command_self_time = tonumber(t.fn.split(t.fn.getline(7))[3]) - helpers.neq(nil, command_total_time) - helpers.neq(nil, command_self_time) + t.neq(nil, command_total_time) + t.neq(nil, command_self_time) end) it('`yes` interrupted with CTRL-C', function() @@ -554,11 +548,11 @@ describe('systemlist()', function() end) it('powershell w/ UTF-8 text #13713', function() - if not helpers.has_powershell() then + if not t.has_powershell() then pending('powershell not found', function() end) return end - helpers.set_shell_powershell() + t.set_shell_powershell() eq({ is_os('win') and 'あ\r' or 'あ' }, eval([[systemlist('Write-Output あ')]])) -- Sanity test w/ default encoding -- * on Windows, expected to default to Western European enc @@ -574,7 +568,7 @@ describe('shell :!', function() it(':{range}! with powershell filter/redirect #16271 #19250', function() local screen = Screen.new(500, 8) screen:attach() - local found = helpers.set_shell_powershell(true) + local found = t.set_shell_powershell(true) insert([[ 3 1 @@ -621,12 +615,12 @@ describe('shell :!', function() } end feed('') - helpers.set_shell_powershell(true) + t.set_shell_powershell(true) feed(':4verbose %w !sort') screen:expect { any = [[Executing command: .?& { Get%-Content .* | & sort }]], } feed('') - helpers.expect_exit(command, 'qall!') + t.expect_exit(command, 'qall!') end) end) diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua index 046d451888..2ec951448c 100644 --- a/test/functional/vimscript/timer_spec.lua +++ b/test/functional/vimscript/timer_spec.lua @@ -1,12 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local feed, eq, eval, ok = helpers.feed, helpers.eq, helpers.eval, helpers.ok -local source, async_meths, run = helpers.source, helpers.async_meths, helpers.run -local clear, command, fn = helpers.clear, helpers.command, helpers.fn -local exc_exec = helpers.exc_exec -local api = helpers.api -local load_adjust = helpers.load_adjust -local retry = helpers.retry +local feed, eq, eval, ok = t.feed, t.eq, t.eval, t.ok +local source, async_meths, run = t.source, t.async_meths, t.run +local clear, command, fn = t.clear, t.command, t.fn +local exc_exec = t.exc_exec +local api = t.api +local load_adjust = t.load_adjust +local retry = t.retry describe('timers', function() before_each(function() diff --git a/test/functional/vimscript/uniq_spec.lua b/test/functional/vimscript/uniq_spec.lua index 8fd4004be4..ed87d50abf 100644 --- a/test/functional/vimscript/uniq_spec.lua +++ b/test/functional/vimscript/uniq_spec.lua @@ -1,10 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local eq = helpers.eq -local clear = helpers.clear -local command = helpers.command -local exc_exec = helpers.exc_exec -local pcall_err = helpers.pcall_err +local eq = t.eq +local clear = t.clear +local command = t.command +local exc_exec = t.exc_exec +local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/vimscript/vvar_event_spec.lua b/test/functional/vimscript/vvar_event_spec.lua index 68eda05363..57c849b45a 100644 --- a/test/functional/vimscript/vvar_event_spec.lua +++ b/test/functional/vimscript/vvar_event_spec.lua @@ -1,6 +1,6 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq -local command = helpers.command +local t = require('test.functional.testutil')(after_each) +local clear, eval, eq = t.clear, t.eval, t.eq +local command = t.command describe('v:event', function() before_each(clear) it('is empty before any autocommand', function() diff --git a/test/functional/vimscript/wait_spec.lua b/test/functional/vimscript/wait_spec.lua index 50cdb2cfb4..15e04af6c9 100644 --- a/test/functional/vimscript/wait_spec.lua +++ b/test/functional/vimscript/wait_spec.lua @@ -1,15 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) -local call = helpers.call -local clear = helpers.clear -local command = helpers.command -local eval = helpers.eval -local eq = helpers.eq -local feed = helpers.feed -local feed_command = helpers.feed_command -local next_msg = helpers.next_msg -local api = helpers.api -local source = helpers.source -local pcall_err = helpers.pcall_err +local t = require('test.functional.testutil')(after_each) +local call = t.call +local clear = t.clear +local command = t.command +local eval = t.eval +local eq = t.eq +local feed = t.feed +local feed_command = t.feed_command +local next_msg = t.next_msg +local api = t.api +local source = t.source +local pcall_err = t.pcall_err before_each(function() clear() @@ -60,7 +60,7 @@ describe('wait()', function() ]]) -- XXX: flaky (#11137) - helpers.retry(nil, nil, function() + t.retry(nil, nil, function() api.nvim_set_var('counter', 0) eq(-1, call('wait', 20, 'Count() >= 5', 99999)) end) diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua index 051e3794a3..47fbd2ef1b 100644 --- a/test/functional/vimscript/writefile_spec.lua +++ b/test/functional/vimscript/writefile_spec.lua @@ -1,15 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) -local mkdir = helpers.mkdir -local clear = helpers.clear -local eq = helpers.eq -local fn = helpers.fn -local api = helpers.api -local exc_exec = helpers.exc_exec -local read_file = helpers.read_file -local write_file = helpers.write_file -local pcall_err = helpers.pcall_err -local command = helpers.command +local mkdir = t.mkdir +local clear = t.clear +local eq = t.eq +local fn = t.fn +local api = t.api +local exc_exec = t.exc_exec +local read_file = t.read_file +local write_file = t.write_file +local pcall_err = t.pcall_err +local command = t.command local fname = 'Xtest-functional-eval-writefile' local dname = fname .. '.d' -- cgit From 81fc27124b9e1b375e0ce9605ae69c3c2a2d9222 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 9 Apr 2024 12:26:16 +0100 Subject: refactor(test): inject after_each differently --- test/functional/vimscript/api_functions_spec.lua | 2 +- test/functional/vimscript/buf_functions_spec.lua | 2 +- test/functional/vimscript/changedtick_spec.lua | 2 +- test/functional/vimscript/container_functions_spec.lua | 2 +- test/functional/vimscript/ctx_functions_spec.lua | 2 +- test/functional/vimscript/environ_spec.lua | 2 +- test/functional/vimscript/errorlist_spec.lua | 2 +- test/functional/vimscript/eval_spec.lua | 2 +- test/functional/vimscript/executable_spec.lua | 2 +- test/functional/vimscript/execute_spec.lua | 2 +- test/functional/vimscript/exepath_spec.lua | 2 +- test/functional/vimscript/fnamemodify_spec.lua | 2 +- test/functional/vimscript/functions_spec.lua | 2 +- test/functional/vimscript/getline_spec.lua | 2 +- test/functional/vimscript/glob_spec.lua | 2 +- test/functional/vimscript/has_spec.lua | 2 +- test/functional/vimscript/hostname_spec.lua | 2 +- test/functional/vimscript/input_spec.lua | 2 +- test/functional/vimscript/json_functions_spec.lua | 2 +- test/functional/vimscript/lang_spec.lua | 2 +- test/functional/vimscript/let_spec.lua | 2 +- test/functional/vimscript/map_functions_spec.lua | 2 +- test/functional/vimscript/match_functions_spec.lua | 2 +- test/functional/vimscript/minmax_functions_spec.lua | 2 +- test/functional/vimscript/modeline_spec.lua | 2 +- test/functional/vimscript/msgpack_functions_spec.lua | 2 +- test/functional/vimscript/null_spec.lua | 2 +- test/functional/vimscript/operators_spec.lua | 2 +- test/functional/vimscript/printf_spec.lua | 2 +- test/functional/vimscript/reltime_spec.lua | 2 +- test/functional/vimscript/screenchar_spec.lua | 2 +- test/functional/vimscript/screenpos_spec.lua | 2 +- test/functional/vimscript/server_spec.lua | 2 +- test/functional/vimscript/setpos_spec.lua | 2 +- test/functional/vimscript/sort_spec.lua | 2 +- test/functional/vimscript/special_vars_spec.lua | 2 +- test/functional/vimscript/state_spec.lua | 2 +- test/functional/vimscript/string_spec.lua | 2 +- test/functional/vimscript/system_spec.lua | 2 +- test/functional/vimscript/timer_spec.lua | 2 +- test/functional/vimscript/uniq_spec.lua | 2 +- test/functional/vimscript/vvar_event_spec.lua | 2 +- test/functional/vimscript/wait_spec.lua | 2 +- test/functional/vimscript/writefile_spec.lua | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 10a98b646e..bb10db8cd3 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local neq, eq, command = t.neq, t.eq, t.command local clear = t.clear diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index 5cecafa370..4889db0cb7 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local clear = t.clear diff --git a/test/functional/vimscript/changedtick_spec.lua b/test/functional/vimscript/changedtick_spec.lua index 09aaea900b..ad8d42b4d5 100644 --- a/test/functional/vimscript/changedtick_spec.lua +++ b/test/functional/vimscript/changedtick_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local eval = t.eval diff --git a/test/functional/vimscript/container_functions_spec.lua b/test/functional/vimscript/container_functions_spec.lua index c3acaa710f..a1bbee1e15 100644 --- a/test/functional/vimscript/container_functions_spec.lua +++ b/test/functional/vimscript/container_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local eval = t.eval diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua index c82ce350b3..956abe12e6 100644 --- a/test/functional/vimscript/ctx_functions_spec.lua +++ b/test/functional/vimscript/ctx_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local call = t.call local clear = t.clear diff --git a/test/functional/vimscript/environ_spec.lua b/test/functional/vimscript/environ_spec.lua index b4c7b30421..9ef0edd815 100644 --- a/test/functional/vimscript/environ_spec.lua +++ b/test/functional/vimscript/environ_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local eq = t.eq local environ = t.fn.environ diff --git a/test/functional/vimscript/errorlist_spec.lua b/test/functional/vimscript/errorlist_spec.lua index 5fcdc65de1..4e473b9e44 100644 --- a/test/functional/vimscript/errorlist_spec.lua +++ b/test/functional/vimscript/errorlist_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local command = t.command diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index 0918c5957a..b7c0803ef7 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -9,7 +9,7 @@ -- test/functional/vimscript/_spec.lua -- test/functional/vimscript/functions_spec.lua -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local mkdir = t.mkdir diff --git a/test/functional/vimscript/executable_spec.lua b/test/functional/vimscript/executable_spec.lua index de16563eed..75d36c26d9 100644 --- a/test/functional/vimscript/executable_spec.lua +++ b/test/functional/vimscript/executable_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq, clear, call, write_file, command = t.eq, t.clear, t.call, t.write_file, t.command local exc_exec = t.exc_exec local eval = t.eval diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua index b765f50fe4..32477323a1 100644 --- a/test/functional/vimscript/execute_spec.lua +++ b/test/functional/vimscript/execute_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local eval = t.eval local clear = t.clear diff --git a/test/functional/vimscript/exepath_spec.lua b/test/functional/vimscript/exepath_spec.lua index 57242a2483..a1a2afb4ed 100644 --- a/test/functional/vimscript/exepath_spec.lua +++ b/test/functional/vimscript/exepath_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq, clear, call = t.eq, t.clear, t.call local command = t.command local exc_exec = t.exc_exec diff --git a/test/functional/vimscript/fnamemodify_spec.lua b/test/functional/vimscript/fnamemodify_spec.lua index 0706a60f57..fd2c79d9a5 100644 --- a/test/functional/vimscript/fnamemodify_spec.lua +++ b/test/functional/vimscript/fnamemodify_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local eq = t.eq local fnamemodify = t.fn.fnamemodify diff --git a/test/functional/vimscript/functions_spec.lua b/test/functional/vimscript/functions_spec.lua index cb4d329ae9..1d57b60b95 100644 --- a/test/functional/vimscript/functions_spec.lua +++ b/test/functional/vimscript/functions_spec.lua @@ -5,7 +5,7 @@ -- -- Core "eval" tests live in eval_spec.lua. -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local eval = t.eval diff --git a/test/functional/vimscript/getline_spec.lua b/test/functional/vimscript/getline_spec.lua index 600730c010..18f7eabc25 100644 --- a/test/functional/vimscript/getline_spec.lua +++ b/test/functional/vimscript/getline_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local call = t.call local clear = t.clear diff --git a/test/functional/vimscript/glob_spec.lua b/test/functional/vimscript/glob_spec.lua index 708b976dbb..c66865611f 100644 --- a/test/functional/vimscript/glob_spec.lua +++ b/test/functional/vimscript/glob_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear, command, eval, eq = t.clear, t.command, t.eval, t.eq local mkdir = t.mkdir diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua index 08193f8d02..05d5b04a29 100644 --- a/test/functional/vimscript/has_spec.lua +++ b/test/functional/vimscript/has_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local clear = t.clear local connect = t.connect diff --git a/test/functional/vimscript/hostname_spec.lua b/test/functional/vimscript/hostname_spec.lua index 024997f6b0..e5be1cf4c3 100644 --- a/test/functional/vimscript/hostname_spec.lua +++ b/test/functional/vimscript/hostname_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local ok = t.ok local call = t.call diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index 0ac22c7320..e974d71356 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local eq = t.eq diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua index e4a9c41d59..f17cf7017c 100644 --- a/test/functional/vimscript/json_functions_spec.lua +++ b/test/functional/vimscript/json_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local fn = t.fn local api = t.api diff --git a/test/functional/vimscript/lang_spec.lua b/test/functional/vimscript/lang_spec.lua index cad3df9aef..bb6b3ea5a7 100644 --- a/test/functional/vimscript/lang_spec.lua +++ b/test/functional/vimscript/lang_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear, eval, eq = t.clear, t.eval, t.eq local exc_exec, source = t.exc_exec, t.source diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index bcfd12cbe8..f8b9ba89d0 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local clear = t.clear diff --git a/test/functional/vimscript/map_functions_spec.lua b/test/functional/vimscript/map_functions_spec.lua index fba3a627e9..7bf835102c 100644 --- a/test/functional/vimscript/map_functions_spec.lua +++ b/test/functional/vimscript/map_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local eq = t.eq diff --git a/test/functional/vimscript/match_functions_spec.lua b/test/functional/vimscript/match_functions_spec.lua index 2bff221c0b..98a2169676 100644 --- a/test/functional/vimscript/match_functions_spec.lua +++ b/test/functional/vimscript/match_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local eq = t.eq diff --git a/test/functional/vimscript/minmax_functions_spec.lua b/test/functional/vimscript/minmax_functions_spec.lua index dbdfc06afb..1748c97849 100644 --- a/test/functional/vimscript/minmax_functions_spec.lua +++ b/test/functional/vimscript/minmax_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local eval = t.eval diff --git a/test/functional/vimscript/modeline_spec.lua b/test/functional/vimscript/modeline_spec.lua index fde6dbef30..7dfaba217b 100644 --- a/test/functional/vimscript/modeline_spec.lua +++ b/test/functional/vimscript/modeline_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local assert_alive = t.assert_alive local clear, command, write_file = t.clear, t.command, t.write_file diff --git a/test/functional/vimscript/msgpack_functions_spec.lua b/test/functional/vimscript/msgpack_functions_spec.lua index 55540712d7..c945efab5a 100644 --- a/test/functional/vimscript/msgpack_functions_spec.lua +++ b/test/functional/vimscript/msgpack_functions_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local fn = t.fn local eval, eq = t.eval, t.eq diff --git a/test/functional/vimscript/null_spec.lua b/test/functional/vimscript/null_spec.lua index 99abc9bcf4..fc051371ba 100644 --- a/test/functional/vimscript/null_spec.lua +++ b/test/functional/vimscript/null_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local exc_exec = t.exc_exec local command = t.command diff --git a/test/functional/vimscript/operators_spec.lua b/test/functional/vimscript/operators_spec.lua index e3357d1dfd..b6294f1f5a 100644 --- a/test/functional/vimscript/operators_spec.lua +++ b/test/functional/vimscript/operators_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local eval = t.eval local clear = t.clear diff --git a/test/functional/vimscript/printf_spec.lua b/test/functional/vimscript/printf_spec.lua index 365c10119a..027edd3b3a 100644 --- a/test/functional/vimscript/printf_spec.lua +++ b/test/functional/vimscript/printf_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local eq = t.eq diff --git a/test/functional/vimscript/reltime_spec.lua b/test/functional/vimscript/reltime_spec.lua index 22c0bd5bb9..4d77c911e4 100644 --- a/test/functional/vimscript/reltime_spec.lua +++ b/test/functional/vimscript/reltime_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear, eq, ok = t.clear, t.eq, t.ok local neq, command, fn = t.neq, t.command, t.fn local matches = t.matches diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua index 08341193e0..442d7904a0 100644 --- a/test/functional/vimscript/screenchar_spec.lua +++ b/test/functional/vimscript/screenchar_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear, eq, neq = t.clear, t.eq, t.neq local command, api, fn = t.command, t.api, t.fn local tbl_deep_extend = vim.tbl_deep_extend diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua index 8c43a12810..057e740205 100644 --- a/test/functional/vimscript/screenpos_spec.lua +++ b/test/functional/vimscript/screenpos_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear, eq, api = t.clear, t.eq, t.api local command, fn = t.command, t.fn local feed = t.feed diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index 9b2c2eaf65..a079429730 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local assert_log = t.assert_log local eq, neq, eval = t.eq, t.neq, t.eval local clear, fn, api = t.clear, t.fn, t.api diff --git a/test/functional/vimscript/setpos_spec.lua b/test/functional/vimscript/setpos_spec.lua index 6398aba79d..16a974c511 100644 --- a/test/functional/vimscript/setpos_spec.lua +++ b/test/functional/vimscript/setpos_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local setpos = t.fn.setpos local getpos = t.fn.getpos local insert = t.insert diff --git a/test/functional/vimscript/sort_spec.lua b/test/functional/vimscript/sort_spec.lua index b1fa88e329..539b74984c 100644 --- a/test/functional/vimscript/sort_spec.lua +++ b/test/functional/vimscript/sort_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local NIL = vim.NIL diff --git a/test/functional/vimscript/special_vars_spec.lua b/test/functional/vimscript/special_vars_spec.lua index 79ec76f622..0ce8703735 100644 --- a/test/functional/vimscript/special_vars_spec.lua +++ b/test/functional/vimscript/special_vars_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local exc_exec = t.exc_exec local command = t.command local fn = t.fn diff --git a/test/functional/vimscript/state_spec.lua b/test/functional/vimscript/state_spec.lua index f5f9b829f8..4a340f9717 100644 --- a/test/functional/vimscript/state_spec.lua +++ b/test/functional/vimscript/state_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local eq = t.eq local exec = t.exec diff --git a/test/functional/vimscript/string_spec.lua b/test/functional/vimscript/string_spec.lua index 859757c93c..c57e4e978b 100644 --- a/test/functional/vimscript/string_spec.lua +++ b/test/functional/vimscript/string_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local eq = t.eq local command = t.command diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index 1cbe9422e2..77ba4e8f97 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -1,6 +1,6 @@ -- Tests for system() and :! shell. -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local assert_alive = t.assert_alive local testprg = t.testprg diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua index 2ec951448c..6cd8590500 100644 --- a/test/functional/vimscript/timer_spec.lua +++ b/test/functional/vimscript/timer_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local feed, eq, eval, ok = t.feed, t.eq, t.eval, t.ok local source, async_meths, run = t.source, t.async_meths, t.run diff --git a/test/functional/vimscript/uniq_spec.lua b/test/functional/vimscript/uniq_spec.lua index ed87d50abf..6ef6dd9960 100644 --- a/test/functional/vimscript/uniq_spec.lua +++ b/test/functional/vimscript/uniq_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local eq = t.eq local clear = t.clear diff --git a/test/functional/vimscript/vvar_event_spec.lua b/test/functional/vimscript/vvar_event_spec.lua index 57c849b45a..e8b8ff36c0 100644 --- a/test/functional/vimscript/vvar_event_spec.lua +++ b/test/functional/vimscript/vvar_event_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear, eval, eq = t.clear, t.eval, t.eq local command = t.command describe('v:event', function() diff --git a/test/functional/vimscript/wait_spec.lua b/test/functional/vimscript/wait_spec.lua index 15e04af6c9..81c406d0cc 100644 --- a/test/functional/vimscript/wait_spec.lua +++ b/test/functional/vimscript/wait_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local call = t.call local clear = t.clear local command = t.command diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua index 47fbd2ef1b..6ad527d922 100644 --- a/test/functional/vimscript/writefile_spec.lua +++ b/test/functional/vimscript/writefile_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local mkdir = t.mkdir local clear = t.clear -- cgit From 7fa24948a936a95519f0c8c496402488b6508c14 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Apr 2024 14:05:09 +0800 Subject: test: make mapping tests more consistent (#28368) - Test maparg() and maplist() in the same test. - Use matches() instead of string.match(). - Avoid overlong lines and strange spacing in exec_lua(). - Revert code change from last PR as the variable may be needed. --- test/functional/vimscript/map_functions_spec.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/map_functions_spec.lua b/test/functional/vimscript/map_functions_spec.lua index 7bf835102c..249b79aa4e 100644 --- a/test/functional/vimscript/map_functions_spec.lua +++ b/test/functional/vimscript/map_functions_spec.lua @@ -233,7 +233,9 @@ describe('mapset()', function() 0, exec_lua([[ GlobalCount = 0 - vim.api.nvim_set_keymap('n', 'asdf', '', {callback = function() GlobalCount = GlobalCount + 1 end }) + vim.api.nvim_set_keymap('n', 'asdf', '', { + callback = function() GlobalCount = GlobalCount + 1 end, + }) return GlobalCount ]]) ) @@ -242,7 +244,9 @@ describe('mapset()', function() exec_lua([[ _G.saved_asdf_map = vim.fn.maparg('asdf', 'n', false, true) - vim.api.nvim_set_keymap('n', 'asdf', '', {callback = function() GlobalCount = GlobalCount + 10 end }) + vim.api.nvim_set_keymap('n', 'asdf', '', { + callback = function() GlobalCount = GlobalCount + 10 end, + }) ]]) feed('asdf') eq(11, exec_lua([[return GlobalCount]])) @@ -253,7 +257,10 @@ describe('mapset()', function() exec([[ let g:saved_asdf_map = maparg('asdf', 'n', v:false, v:true) - lua vim.api.nvim_set_keymap('n', 'asdf', '', {callback = function() GlobalCount = GlobalCount + 10 end }) + lua << + vim.api.nvim_set_keymap('n', 'asdf', '', { + callback = function() GlobalCount = GlobalCount + 10 end, + }) ]]) feed('asdf') eq(22, exec_lua([[return GlobalCount]])) -- cgit From 052498ed42780a76daea589d063cd8947a894673 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 20 Apr 2024 17:44:13 +0200 Subject: test: improve test conventions Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004. --- test/functional/vimscript/api_functions_spec.lua | 18 +++++----- test/functional/vimscript/buf_functions_spec.lua | 17 ++++----- test/functional/vimscript/changedtick_spec.lua | 19 +++++----- .../vimscript/container_functions_spec.lua | 9 ++--- test/functional/vimscript/ctx_functions_spec.lua | 21 +++++------ test/functional/vimscript/environ_spec.lua | 20 ++++++----- test/functional/vimscript/errorlist_spec.lua | 19 +++++----- test/functional/vimscript/eval_spec.lua | 37 +++++++++---------- test/functional/vimscript/executable_spec.lua | 10 +++--- test/functional/vimscript/execute_spec.lua | 20 ++++++----- test/functional/vimscript/exepath_spec.lua | 14 ++++---- test/functional/vimscript/fnamemodify_spec.lua | 16 +++++---- test/functional/vimscript/functions_spec.lua | 7 ++-- test/functional/vimscript/getline_spec.lua | 9 ++--- test/functional/vimscript/glob_spec.lua | 6 ++-- test/functional/vimscript/has_spec.lua | 12 ++++--- test/functional/vimscript/hostname_spec.lua | 8 +++-- test/functional/vimscript/input_spec.lua | 17 ++++----- test/functional/vimscript/json_functions_spec.lua | 18 +++++----- test/functional/vimscript/lang_spec.lua | 8 +++-- test/functional/vimscript/let_spec.lua | 21 +++++------ test/functional/vimscript/map_functions_spec.lua | 25 ++++++------- test/functional/vimscript/match_functions_spec.lua | 11 +++--- .../functional/vimscript/minmax_functions_spec.lua | 11 +++--- test/functional/vimscript/modeline_spec.lua | 8 +++-- .../vimscript/msgpack_functions_spec.lua | 20 ++++++----- test/functional/vimscript/null_spec.lua | 13 +++---- test/functional/vimscript/operators_spec.lua | 8 +++-- test/functional/vimscript/printf_spec.lua | 13 +++---- test/functional/vimscript/reltime_spec.lua | 8 +++-- test/functional/vimscript/screenchar_spec.lua | 8 +++-- test/functional/vimscript/screenpos_spec.lua | 10 +++--- test/functional/vimscript/server_spec.lua | 24 +++++++------ test/functional/vimscript/setpos_spec.lua | 18 +++++----- test/functional/vimscript/sort_spec.lua | 15 ++++---- test/functional/vimscript/special_vars_spec.lua | 16 +++++---- test/functional/vimscript/state_spec.lua | 16 +++++---- test/functional/vimscript/string_spec.lua | 18 +++++----- test/functional/vimscript/system_spec.lua | 42 +++++++++++----------- test/functional/vimscript/timer_spec.lua | 16 +++++---- test/functional/vimscript/uniq_spec.lua | 9 ++--- test/functional/vimscript/vvar_event_spec.lua | 8 +++-- test/functional/vimscript/wait_spec.lua | 22 ++++++------ test/functional/vimscript/writefile_spec.lua | 13 +++---- 44 files changed, 373 insertions(+), 305 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index bb10db8cd3..40d96ec281 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local neq, eq, command = t.neq, t.eq, t.command -local clear = t.clear -local exc_exec, expect, eval = t.exc_exec, t.expect, t.eval -local exec_lua = t.exec_lua -local insert, pcall_err = t.insert, t.pcall_err + +local neq, eq, command = t.neq, t.eq, n.command +local clear = n.clear +local exc_exec, expect, eval = n.exc_exec, n.expect, n.eval +local exec_lua = n.exec_lua +local insert, pcall_err = n.insert, t.pcall_err local matches = t.matches -local api = t.api -local feed = t.feed +local api = n.api +local feed = n.feed describe('eval-API', function() before_each(clear) diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index 4889db0cb7..625fbe7e03 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -1,13 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local fn = t.fn -local api = t.api -local command = t.command -local exc_exec = t.exc_exec -local get_pathsep = t.get_pathsep -local rmdir = t.rmdir +local clear = n.clear +local fn = n.fn +local api = n.api +local command = n.command +local exc_exec = n.exc_exec +local get_pathsep = n.get_pathsep +local rmdir = n.rmdir local pcall_err = t.pcall_err local mkdir = t.mkdir diff --git a/test/functional/vimscript/changedtick_spec.lua b/test/functional/vimscript/changedtick_spec.lua index ad8d42b4d5..baea53a700 100644 --- a/test/functional/vimscript/changedtick_spec.lua +++ b/test/functional/vimscript/changedtick_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local eval = t.eval -local feed = t.feed -local clear = t.clear -local fn = t.fn -local api = t.api -local command = t.command -local exc_exec = t.exc_exec +local eval = n.eval +local feed = n.feed +local clear = n.clear +local fn = n.fn +local api = n.api +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err -local exec_capture = t.exec_capture +local exec_capture = n.exec_capture before_each(clear) diff --git a/test/functional/vimscript/container_functions_spec.lua b/test/functional/vimscript/container_functions_spec.lua index a1bbee1e15..1d95bf6470 100644 --- a/test/functional/vimscript/container_functions_spec.lua +++ b/test/functional/vimscript/container_functions_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local eval = t.eval -local api = t.api -local clear = t.clear +local eval = n.eval +local api = n.api +local clear = n.clear before_each(clear) diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua index 956abe12e6..5e9a803b5d 100644 --- a/test/functional/vimscript/ctx_functions_spec.lua +++ b/test/functional/vimscript/ctx_functions_spec.lua @@ -1,16 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local call = t.call -local clear = t.clear -local command = t.command +local call = n.call +local clear = n.clear +local command = n.command local eq = t.eq -local eval = t.eval -local feed = t.feed +local eval = n.eval +local feed = n.feed local map = vim.tbl_map -local api = t.api -local parse_context = t.parse_context -local exec_capture = t.exec_capture -local source = t.source +local api = n.api +local parse_context = n.parse_context +local exec_capture = n.exec_capture +local source = n.source local trim = vim.trim local write_file = t.write_file local pcall_err = t.pcall_err diff --git a/test/functional/vimscript/environ_spec.lua b/test/functional/vimscript/environ_spec.lua index 9ef0edd815..abb093a6c8 100644 --- a/test/functional/vimscript/environ_spec.lua +++ b/test/functional/vimscript/environ_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local environ = t.fn.environ -local exists = t.fn.exists -local system = t.fn.system -local nvim_prog = t.nvim_prog -local command = t.command -local eval = t.eval -local setenv = t.fn.setenv +local environ = n.fn.environ +local exists = n.fn.exists +local system = n.fn.system +local nvim_prog = n.nvim_prog +local command = n.command +local eval = n.eval +local setenv = n.fn.setenv describe('environment variables', function() it('environ() handles empty env variable', function() diff --git a/test/functional/vimscript/errorlist_spec.lua b/test/functional/vimscript/errorlist_spec.lua index 4e473b9e44..ef9111f788 100644 --- a/test/functional/vimscript/errorlist_spec.lua +++ b/test/functional/vimscript/errorlist_spec.lua @@ -1,13 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local command = t.command +local clear = n.clear +local command = n.command local eq = t.eq -local exc_exec = t.exc_exec -local get_win_var = t.api.nvim_win_get_var +local exc_exec = n.exc_exec +local get_win_var = n.api.nvim_win_get_var describe('setqflist()', function() - local setqflist = t.fn.setqflist + local setqflist = n.fn.setqflist before_each(clear) @@ -46,7 +47,7 @@ describe('setqflist()', function() end) describe('setloclist()', function() - local setloclist = t.fn.setloclist + local setloclist = n.fn.setloclist before_each(clear) @@ -73,7 +74,7 @@ describe('setloclist()', function() end) it("doesn't crash when when window is closed in the middle #13721", function() - t.insert([[ + n.insert([[ hello world]]) command('vsplit') @@ -82,6 +83,6 @@ describe('setloclist()', function() command('call setloclist(0, [])') command('lopen') - t.assert_alive() + n.assert_alive() end) end) diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index b7c0803ef7..0c812d968e 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -9,37 +9,38 @@ -- test/functional/vimscript/_spec.lua -- test/functional/vimscript/functions_spec.lua -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local mkdir = t.mkdir -local clear = t.clear +local clear = n.clear local eq = t.eq -local exec = t.exec -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local exec_capture = t.exec_capture -local eval = t.eval -local command = t.command +local exec = n.exec +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local exec_capture = n.exec_capture +local eval = n.eval +local command = n.command local write_file = t.write_file -local api = t.api +local api = n.api local sleep = vim.uv.sleep local matches = t.matches local pcall_err = t.pcall_err -local assert_alive = t.assert_alive -local poke_eventloop = t.poke_eventloop -local feed = t.feed -local expect_exit = t.expect_exit +local assert_alive = n.assert_alive +local poke_eventloop = n.poke_eventloop +local feed = n.feed +local expect_exit = n.expect_exit describe('Up to MAX_FUNC_ARGS arguments are handled by', function() local max_func_args = 20 -- from eval.h - local range = t.fn.range + local range = n.fn.range before_each(clear) it('printf()', function() - local printf = t.fn.printf - local rep = t.fn['repeat'] + local printf = n.fn.printf + local rep = n.fn['repeat'] local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,' eq(expected, printf(rep('%d,', max_func_args - 1), unpack(range(2, max_func_args)))) local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -47,7 +48,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function() end) it('rpcnotify()', function() - local rpcnotify = t.fn.rpcnotify + local rpcnotify = n.fn.rpcnotify local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args))) eq(1, ret) ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -69,7 +70,7 @@ describe('backtick expansion', function() end) teardown(function() - t.rmdir('test-backticks') + n.rmdir('test-backticks') end) it("with default 'shell'", function() diff --git a/test/functional/vimscript/executable_spec.lua b/test/functional/vimscript/executable_spec.lua index 75d36c26d9..e5530926c4 100644 --- a/test/functional/vimscript/executable_spec.lua +++ b/test/functional/vimscript/executable_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local eq, clear, call, write_file, command = t.eq, t.clear, t.call, t.write_file, t.command -local exc_exec = t.exc_exec -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, clear, call, write_file, command = t.eq, n.clear, n.call, t.write_file, n.command +local exc_exec = n.exc_exec +local eval = n.eval local is_os = t.is_os describe('executable()', function() diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua index 32477323a1..8caaea39a7 100644 --- a/test/functional/vimscript/execute_spec.lua +++ b/test/functional/vimscript/execute_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') + local eq = t.eq -local eval = t.eval -local clear = t.clear -local source = t.source -local exc_exec = t.exc_exec +local eval = n.eval +local clear = n.clear +local source = n.source +local exc_exec = n.exc_exec local pcall_err = t.pcall_err -local fn = t.fn -local Screen = require('test.functional.ui.screen') -local command = t.command -local feed = t.feed +local fn = n.fn +local command = n.command +local feed = n.feed local is_os = t.is_os describe('execute()', function() diff --git a/test/functional/vimscript/exepath_spec.lua b/test/functional/vimscript/exepath_spec.lua index a1a2afb4ed..97747619ad 100644 --- a/test/functional/vimscript/exepath_spec.lua +++ b/test/functional/vimscript/exepath_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local eq, clear, call = t.eq, t.clear, t.call -local command = t.command -local exc_exec = t.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, clear, call = t.eq, n.clear, n.call +local command = n.command +local exc_exec = n.exc_exec local matches = t.matches local is_os = t.is_os -local set_shell_powershell = t.set_shell_powershell -local eval = t.eval +local set_shell_powershell = n.set_shell_powershell +local eval = n.eval local find_dummies = function(ext_pat) local tmp_path = eval('$PATH') diff --git a/test/functional/vimscript/fnamemodify_spec.lua b/test/functional/vimscript/fnamemodify_spec.lua index fd2c79d9a5..51b1e8489a 100644 --- a/test/functional/vimscript/fnamemodify_spec.lua +++ b/test/functional/vimscript/fnamemodify_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local fnamemodify = t.fn.fnamemodify -local getcwd = t.fn.getcwd -local command = t.command +local fnamemodify = n.fn.fnamemodify +local getcwd = n.fn.getcwd +local command = n.command local write_file = t.write_file -local alter_slashes = t.alter_slashes +local alter_slashes = n.alter_slashes local is_os = t.is_os local function eq_slashconvert(expected, got) @@ -24,7 +26,7 @@ describe('fnamemodify()', function() end) it('handles the root path', function() - local root = t.pathroot() + local root = n.pathroot() eq(root, fnamemodify([[/]], ':p:h')) eq(root, fnamemodify([[/]], ':p')) if is_os('win') then diff --git a/test/functional/vimscript/functions_spec.lua b/test/functional/vimscript/functions_spec.lua index 1d57b60b95..7d9e80a32b 100644 --- a/test/functional/vimscript/functions_spec.lua +++ b/test/functional/vimscript/functions_spec.lua @@ -5,10 +5,11 @@ -- -- Core "eval" tests live in eval_spec.lua. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear -local eval = t.eval +local clear = n.clear +local eval = n.eval local matches = t.matches local is_os = t.is_os diff --git a/test/functional/vimscript/getline_spec.lua b/test/functional/vimscript/getline_spec.lua index 18f7eabc25..32be6b5702 100644 --- a/test/functional/vimscript/getline_spec.lua +++ b/test/functional/vimscript/getline_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local call = t.call -local clear = t.clear +local call = n.call +local clear = n.clear local eq = t.eq -local expect = t.expect +local expect = n.expect describe('getline()', function() before_each(function() diff --git a/test/functional/vimscript/glob_spec.lua b/test/functional/vimscript/glob_spec.lua index c66865611f..754381231e 100644 --- a/test/functional/vimscript/glob_spec.lua +++ b/test/functional/vimscript/glob_spec.lua @@ -1,5 +1,7 @@ -local t = require('test.functional.testutil')() -local clear, command, eval, eq = t.clear, t.command, t.eval, t.eq +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, command, eval, eq = n.clear, n.command, n.eval, t.eq local mkdir = t.mkdir before_each(function() diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua index 05d5b04a29..1d2187be6b 100644 --- a/test/functional/vimscript/has_spec.lua +++ b/test/functional/vimscript/has_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = t.clear -local connect = t.connect + +local clear = n.clear +local connect = n.connect local eq = t.eq -local fn = t.fn +local fn = n.fn local is_os = t.is_os -local nvim_prog = t.nvim_prog +local nvim_prog = n.nvim_prog describe('has()', function() before_each(clear) diff --git a/test/functional/vimscript/hostname_spec.lua b/test/functional/vimscript/hostname_spec.lua index e5be1cf4c3..e6b2499775 100644 --- a/test/functional/vimscript/hostname_spec.lua +++ b/test/functional/vimscript/hostname_spec.lua @@ -1,8 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq local ok = t.ok -local call = t.call -local clear = t.clear +local call = n.call +local clear = n.clear local is_os = t.is_os describe('hostname()', function() diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index e974d71356..552ae6d5cc 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -1,14 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq -local feed = t.feed -local api = t.api -local clear = t.clear -local source = t.source -local command = t.command -local exc_exec = t.exc_exec -local async_meths = t.async_meths +local feed = n.feed +local api = n.api +local clear = n.clear +local source = n.source +local command = n.command +local exc_exec = n.exc_exec +local async_meths = n.async_meths local NIL = vim.NIL local screen diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua index f17cf7017c..ae56e8873d 100644 --- a/test/functional/vimscript/json_functions_spec.lua +++ b/test/functional/vimscript/json_functions_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local fn = t.fn -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local fn = n.fn +local api = n.api local eq = t.eq -local eval = t.eval -local command = t.command -local exc_exec = t.exc_exec +local eval = n.eval +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err local NIL = vim.NIL -local source = t.source +local source = n.source describe('json_decode() function', function() local restart = function(...) diff --git a/test/functional/vimscript/lang_spec.lua b/test/functional/vimscript/lang_spec.lua index bb6b3ea5a7..923c8c215d 100644 --- a/test/functional/vimscript/lang_spec.lua +++ b/test/functional/vimscript/lang_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eval, eq = t.clear, t.eval, t.eq -local exc_exec, source = t.exc_exec, t.source +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eval, eq = n.clear, n.eval, t.eq +local exc_exec, source = n.exc_exec, n.source describe('vimscript', function() before_each(clear) diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index f8b9ba89d0..412e06df20 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local command = t.command -local eval = t.eval -local api = t.api -local exec = t.exec -local exec_capture = t.exec_capture -local expect_exit = t.expect_exit -local source = t.source -local testprg = t.testprg +local clear = n.clear +local command = n.command +local eval = n.eval +local api = n.api +local exec = n.exec +local exec_capture = n.exec_capture +local expect_exit = n.expect_exit +local source = n.source +local testprg = n.testprg before_each(clear) diff --git a/test/functional/vimscript/map_functions_spec.lua b/test/functional/vimscript/map_functions_spec.lua index 249b79aa4e..44be5b3185 100644 --- a/test/functional/vimscript/map_functions_spec.lua +++ b/test/functional/vimscript/map_functions_spec.lua @@ -1,17 +1,18 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local exec = t.exec -local exec_lua = t.exec_lua -local expect = t.expect -local feed = t.feed -local fn = t.fn -local api = t.api -local source = t.source -local command = t.command -local exec_capture = t.exec_capture +local eval = n.eval +local exec = n.exec +local exec_lua = n.exec_lua +local expect = n.expect +local feed = n.feed +local fn = n.fn +local api = n.api +local source = n.source +local command = n.command +local exec_capture = n.exec_capture local pcall_err = t.pcall_err describe('maparg()', function() diff --git a/test/functional/vimscript/match_functions_spec.lua b/test/functional/vimscript/match_functions_spec.lua index 98a2169676..87c57f1c15 100644 --- a/test/functional/vimscript/match_functions_spec.lua +++ b/test/functional/vimscript/match_functions_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local eq = t.eq -local clear = t.clear -local fn = t.fn -local command = t.command -local exc_exec = t.exc_exec +local clear = n.clear +local fn = n.fn +local command = n.command +local exc_exec = n.exc_exec before_each(clear) diff --git a/test/functional/vimscript/minmax_functions_spec.lua b/test/functional/vimscript/minmax_functions_spec.lua index 1748c97849..bf223c436e 100644 --- a/test/functional/vimscript/minmax_functions_spec.lua +++ b/test/functional/vimscript/minmax_functions_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local eval = t.eval -local command = t.command -local clear = t.clear -local fn = t.fn +local eval = n.eval +local command = n.command +local clear = n.clear +local fn = n.fn local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/vimscript/modeline_spec.lua b/test/functional/vimscript/modeline_spec.lua index 7dfaba217b..53a5e9b692 100644 --- a/test/functional/vimscript/modeline_spec.lua +++ b/test/functional/vimscript/modeline_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local assert_alive = t.assert_alive -local clear, command, write_file = t.clear, t.command, t.write_file +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local clear, command, write_file = n.clear, n.command, t.write_file describe('modeline', function() local tempfile = t.tmpname() diff --git a/test/functional/vimscript/msgpack_functions_spec.lua b/test/functional/vimscript/msgpack_functions_spec.lua index c945efab5a..d59dceef31 100644 --- a/test/functional/vimscript/msgpack_functions_spec.lua +++ b/test/functional/vimscript/msgpack_functions_spec.lua @@ -1,10 +1,12 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local fn = t.fn -local eval, eq = t.eval, t.eq -local command = t.command -local api = t.api -local exc_exec = t.exc_exec +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local fn = n.fn +local eval, eq = n.eval, t.eq +local command = n.command +local api = n.api +local exc_exec = n.exc_exec local is_os = t.is_os describe('msgpack*() functions', function() @@ -469,12 +471,12 @@ describe('msgpackparse() function', function() end) it('msgpackparse(systemlist(...)) does not segfault. #3135', function() - local cmd = "sort(keys(msgpackparse(systemlist('" .. t.nvim_prog .. " --api-info'))[0]))" + local cmd = "sort(keys(msgpackparse(systemlist('" .. n.nvim_prog .. " --api-info'))[0]))" eval(cmd) eval(cmd) -- do it again (try to force segfault) local api_info = eval(cmd) -- do it again if is_os('win') then - t.assert_alive() + n.assert_alive() pending('msgpackparse() has a bug on windows') return end diff --git a/test/functional/vimscript/null_spec.lua b/test/functional/vimscript/null_spec.lua index fc051371ba..9a27239a6d 100644 --- a/test/functional/vimscript/null_spec.lua +++ b/test/functional/vimscript/null_spec.lua @@ -1,10 +1,11 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local exc_exec = t.exc_exec -local command = t.command -local clear = t.clear -local api = t.api -local fn = t.fn +local exc_exec = n.exc_exec +local command = n.command +local clear = n.clear +local api = n.api +local fn = n.fn local eq = t.eq local function redir_exec(cmd) diff --git a/test/functional/vimscript/operators_spec.lua b/test/functional/vimscript/operators_spec.lua index b6294f1f5a..9c4a91d655 100644 --- a/test/functional/vimscript/operators_spec.lua +++ b/test/functional/vimscript/operators_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq = t.eq -local eval = t.eval -local clear = t.clear +local eval = n.eval +local clear = n.clear describe('Division operator', function() before_each(clear) diff --git a/test/functional/vimscript/printf_spec.lua b/test/functional/vimscript/printf_spec.lua index 027edd3b3a..3c66e07618 100644 --- a/test/functional/vimscript/printf_spec.lua +++ b/test/functional/vimscript/printf_spec.lua @@ -1,11 +1,12 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = t.clear +local clear = n.clear local eq = t.eq -local eval = t.eval -local fn = t.fn -local api = t.api -local exc_exec = t.exc_exec +local eval = n.eval +local fn = n.fn +local api = n.api +local exc_exec = n.exc_exec describe('printf()', function() before_each(clear) diff --git a/test/functional/vimscript/reltime_spec.lua b/test/functional/vimscript/reltime_spec.lua index 4d77c911e4..fa110d602a 100644 --- a/test/functional/vimscript/reltime_spec.lua +++ b/test/functional/vimscript/reltime_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eq, ok = t.clear, t.eq, t.ok -local neq, command, fn = t.neq, t.command, t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, ok = n.clear, t.eq, t.ok +local neq, command, fn = t.neq, n.command, n.fn local matches = t.matches local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua index 442d7904a0..b6137d7741 100644 --- a/test/functional/vimscript/screenchar_spec.lua +++ b/test/functional/vimscript/screenchar_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eq, neq = t.clear, t.eq, t.neq -local command, api, fn = t.command, t.api, t.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, neq = n.clear, t.eq, t.neq +local command, api, fn = n.command, n.api, n.fn local tbl_deep_extend = vim.tbl_deep_extend -- Set up two overlapping floating windows diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua index 057e740205..630e19b841 100644 --- a/test/functional/vimscript/screenpos_spec.lua +++ b/test/functional/vimscript/screenpos_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local clear, eq, api = t.clear, t.eq, t.api -local command, fn = t.command, t.fn -local feed = t.feed +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, api = n.clear, t.eq, n.api +local command, fn = n.command, n.fn +local feed = n.feed before_each(clear) diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index a079429730..4b0dc087f6 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -1,13 +1,15 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local assert_log = t.assert_log -local eq, neq, eval = t.eq, t.neq, t.eval -local clear, fn, api = t.clear, t.fn, t.api +local eq, neq, eval = t.eq, t.neq, n.eval +local clear, fn, api = n.clear, n.fn, n.api local ok = t.ok local matches = t.matches local pcall_err = t.pcall_err -local check_close = t.check_close +local check_close = n.check_close local mkdir = t.mkdir -local rmdir = t.rmdir +local rmdir = n.rmdir local is_os = t.is_os local testlog = 'Xtest-server-log' @@ -148,7 +150,7 @@ describe('server', function() it('serverlist() returns the list of servers', function() clear() -- There should already be at least one server. - local n = eval('len(serverlist())') + local _n = eval('len(serverlist())') -- Add some servers. local servs = ( @@ -162,25 +164,25 @@ describe('server', function() local new_servs = eval('serverlist()') -- Exactly #servs servers should be added. - eq(n + #servs, #new_servs) + eq(_n + #servs, #new_servs) -- The new servers should be at the end of the list. for i = 1, #servs do - eq(servs[i], new_servs[i + n]) + eq(servs[i], new_servs[i + _n]) eq(1, eval("serverstop('" .. servs[i] .. "')")) end -- After serverstop() the servers should NOT be in the list. - eq(n, eval('len(serverlist())')) + eq(_n, eval('len(serverlist())')) end) end) describe('startup --listen', function() it('validates', function() clear() - local cmd = { unpack(t.nvim_argv) } + local cmd = { unpack(n.nvim_argv) } table.insert(cmd, '--listen') matches('nvim.*: Argument missing after: "%-%-listen"', fn.system(cmd)) - cmd = { unpack(t.nvim_argv) } + cmd = { unpack(n.nvim_argv) } table.insert(cmd, '--listen2') matches('nvim.*: Garbage after option argument: "%-%-listen2"', fn.system(cmd)) end) diff --git a/test/functional/vimscript/setpos_spec.lua b/test/functional/vimscript/setpos_spec.lua index 16a974c511..968da4d8f4 100644 --- a/test/functional/vimscript/setpos_spec.lua +++ b/test/functional/vimscript/setpos_spec.lua @@ -1,12 +1,14 @@ -local t = require('test.functional.testutil')() -local setpos = t.fn.setpos -local getpos = t.fn.getpos -local insert = t.insert -local clear = t.clear -local command = t.command -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local setpos = n.fn.setpos +local getpos = n.fn.getpos +local insert = n.insert +local clear = n.clear +local command = n.command +local eval = n.eval local eq = t.eq -local exc_exec = t.exc_exec +local exc_exec = n.exc_exec describe('setpos() function', function() before_each(function() diff --git a/test/functional/vimscript/sort_spec.lua b/test/functional/vimscript/sort_spec.lua index 539b74984c..c8c1651ed8 100644 --- a/test/functional/vimscript/sort_spec.lua +++ b/test/functional/vimscript/sort_spec.lua @@ -1,13 +1,14 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq local NIL = vim.NIL -local eval = t.eval -local clear = t.clear -local api = t.api -local fn = t.fn -local command = t.command -local exc_exec = t.exc_exec +local eval = n.eval +local clear = n.clear +local api = n.api +local fn = n.fn +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/vimscript/special_vars_spec.lua b/test/functional/vimscript/special_vars_spec.lua index 0ce8703735..70e195ba0b 100644 --- a/test/functional/vimscript/special_vars_spec.lua +++ b/test/functional/vimscript/special_vars_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local exc_exec = t.exc_exec -local command = t.command -local fn = t.fn -local clear = t.clear -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local exc_exec = n.exc_exec +local command = n.command +local fn = n.fn +local clear = n.clear +local eval = n.eval local eq = t.eq -local api = t.api +local api = n.api local NIL = vim.NIL describe('Special values', function() diff --git a/test/functional/vimscript/state_spec.lua b/test/functional/vimscript/state_spec.lua index 4a340f9717..211d79928a 100644 --- a/test/functional/vimscript/state_spec.lua +++ b/test/functional/vimscript/state_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local exec = t.exec -local exec_lua = t.exec_lua -local feed = t.feed -local api = t.api -local poke_eventloop = t.poke_eventloop +local exec = n.exec +local exec_lua = n.exec_lua +local feed = n.feed +local api = n.api +local poke_eventloop = n.poke_eventloop before_each(clear) diff --git a/test/functional/vimscript/string_spec.lua b/test/functional/vimscript/string_spec.lua index c57e4e978b..32aa04c0d0 100644 --- a/test/functional/vimscript/string_spec.lua +++ b/test/functional/vimscript/string_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq -local command = t.command -local api = t.api -local eval = t.eval -local exc_exec = t.exc_exec +local command = n.command +local api = n.api +local eval = n.eval +local exc_exec = n.exc_exec local pcall_err = t.pcall_err -local fn = t.fn +local fn = n.fn local NIL = vim.NIL -local source = t.source +local source = n.source describe('string() function', function() before_each(clear) diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index 77ba4e8f97..792e4c46c3 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -1,21 +1,21 @@ -- Tests for system() and :! shell. -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') -local assert_alive = t.assert_alive -local testprg = t.testprg +local assert_alive = n.assert_alive +local testprg = n.testprg local eq, call, clear, eval, feed_command, feed, api = - t.eq, t.call, t.clear, t.eval, t.feed_command, t.feed, t.api -local command = t.command -local insert = t.insert -local expect = t.expect -local exc_exec = t.exc_exec -local os_kill = t.os_kill + t.eq, n.call, n.clear, n.eval, n.feed_command, n.feed, n.api +local command = n.command +local insert = n.insert +local expect = n.expect +local exc_exec = n.exc_exec +local os_kill = n.os_kill local pcall_err = t.pcall_err local is_os = t.is_os -local Screen = require('test.functional.ui.screen') - local function create_file_with_nuls(name) return function() feed('ipart1000part2000part3:w ' .. name .. '') @@ -183,7 +183,7 @@ describe('system()', function() end) it('with powershell', function() - t.set_shell_powershell() + n.set_shell_powershell() eq('a\nb\n', eval([[system('Write-Output a b')]])) eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]])) eq('a b\n', eval([[system('Write-Output "a b"')]])) @@ -191,11 +191,11 @@ describe('system()', function() end it('powershell w/ UTF-8 text #13713', function() - if not t.has_powershell() then + if not n.has_powershell() then pending('powershell not found', function() end) return end - t.set_shell_powershell() + n.set_shell_powershell() eq('ああ\n', eval([[system('Write-Output "ああ"')]])) -- Sanity test w/ default encoding -- * on Windows, expected to default to Western European enc @@ -241,8 +241,8 @@ describe('system()', function() feed(':edit ' .. tempfile .. '') - local command_total_time = tonumber(t.fn.split(t.fn.getline(7))[2]) - local command_self_time = tonumber(t.fn.split(t.fn.getline(7))[3]) + local command_total_time = tonumber(n.fn.split(n.fn.getline(7))[2]) + local command_self_time = tonumber(n.fn.split(n.fn.getline(7))[3]) t.neq(nil, command_total_time) t.neq(nil, command_self_time) @@ -548,11 +548,11 @@ describe('systemlist()', function() end) it('powershell w/ UTF-8 text #13713', function() - if not t.has_powershell() then + if not n.has_powershell() then pending('powershell not found', function() end) return end - t.set_shell_powershell() + n.set_shell_powershell() eq({ is_os('win') and 'あ\r' or 'あ' }, eval([[systemlist('Write-Output あ')]])) -- Sanity test w/ default encoding -- * on Windows, expected to default to Western European enc @@ -568,7 +568,7 @@ describe('shell :!', function() it(':{range}! with powershell filter/redirect #16271 #19250', function() local screen = Screen.new(500, 8) screen:attach() - local found = t.set_shell_powershell(true) + local found = n.set_shell_powershell(true) insert([[ 3 1 @@ -615,12 +615,12 @@ describe('shell :!', function() } end feed('') - t.set_shell_powershell(true) + n.set_shell_powershell(true) feed(':4verbose %w !sort') screen:expect { any = [[Executing command: .?& { Get%-Content .* | & sort }]], } feed('') - t.expect_exit(command, 'qall!') + n.expect_exit(command, 'qall!') end) end) diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua index 6cd8590500..f075e382bc 100644 --- a/test/functional/vimscript/timer_spec.lua +++ b/test/functional/vimscript/timer_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed, eq, eval, ok = t.feed, t.eq, t.eval, t.ok -local source, async_meths, run = t.source, t.async_meths, t.run -local clear, command, fn = t.clear, t.command, t.fn -local exc_exec = t.exc_exec -local api = t.api -local load_adjust = t.load_adjust + +local feed, eq, eval, ok = n.feed, t.eq, n.eval, t.ok +local source, async_meths, run = n.source, n.async_meths, n.run +local clear, command, fn = n.clear, n.command, n.fn +local exc_exec = n.exc_exec +local api = n.api +local load_adjust = n.load_adjust local retry = t.retry describe('timers', function() diff --git a/test/functional/vimscript/uniq_spec.lua b/test/functional/vimscript/uniq_spec.lua index 6ef6dd9960..4e1ef699a4 100644 --- a/test/functional/vimscript/uniq_spec.lua +++ b/test/functional/vimscript/uniq_spec.lua @@ -1,9 +1,10 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local eq = t.eq -local clear = t.clear -local command = t.command -local exc_exec = t.exc_exec +local clear = n.clear +local command = n.command +local exc_exec = n.exc_exec local pcall_err = t.pcall_err before_each(clear) diff --git a/test/functional/vimscript/vvar_event_spec.lua b/test/functional/vimscript/vvar_event_spec.lua index e8b8ff36c0..16fa2c9f9f 100644 --- a/test/functional/vimscript/vvar_event_spec.lua +++ b/test/functional/vimscript/vvar_event_spec.lua @@ -1,6 +1,8 @@ -local t = require('test.functional.testutil')() -local clear, eval, eq = t.clear, t.eval, t.eq -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eval, eq = n.clear, n.eval, t.eq +local command = n.command describe('v:event', function() before_each(clear) it('is empty before any autocommand', function() diff --git a/test/functional/vimscript/wait_spec.lua b/test/functional/vimscript/wait_spec.lua index 81c406d0cc..0932bd3593 100644 --- a/test/functional/vimscript/wait_spec.lua +++ b/test/functional/vimscript/wait_spec.lua @@ -1,14 +1,16 @@ -local t = require('test.functional.testutil')() -local call = t.call -local clear = t.clear -local command = t.command -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local call = n.call +local clear = n.clear +local command = n.command +local eval = n.eval local eq = t.eq -local feed = t.feed -local feed_command = t.feed_command -local next_msg = t.next_msg -local api = t.api -local source = t.source +local feed = n.feed +local feed_command = n.feed_command +local next_msg = n.next_msg +local api = n.api +local source = n.source local pcall_err = t.pcall_err before_each(function() diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua index 6ad527d922..404aceb92b 100644 --- a/test/functional/vimscript/writefile_spec.lua +++ b/test/functional/vimscript/writefile_spec.lua @@ -1,15 +1,16 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local mkdir = t.mkdir -local clear = t.clear +local clear = n.clear local eq = t.eq -local fn = t.fn -local api = t.api -local exc_exec = t.exc_exec +local fn = n.fn +local api = n.api +local exc_exec = n.exc_exec local read_file = t.read_file local write_file = t.write_file local pcall_err = t.pcall_err -local command = t.command +local command = n.command local fname = 'Xtest-functional-eval-writefile' local dname = fname .. '.d' -- cgit From aec4938a21a02d279d13a9eb64ef3b7cc592c374 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 17 May 2024 07:37:39 -0700 Subject: feat(api): broadcast events to ALL channels #28487 Problem: `vim.rpcnotify(0)` and `rpcnotify(0)` are documented as follows: If {channel} is 0, the event is broadcast to all channels. But that's not actually true. Channels must call `nvim_subscribe` to receive "broadcast" events, so it's actually "multicast". - Assuming there is a use-case for "broadcast", the current model adds an extra step for broadcasting: all channels need to "subscribe". - The presence of `nvim_subscribe` is a source of confusion for users, because its name implies something more generally useful than what it does. Presumably the use-case of `nvim_subscribe` is to avoid "noise" on RPC channels not expected a broadcast notification, and potentially an error if the channel client reports an unknown event. Solution: - Deprecate `nvim_subscribe`/`nvim_unsubscribe`. - If applications want to multicast, they can keep their own multicast list. Or they can use `nvim_list_chans()` and `nvim_get_chan_info()` to enumerate and filter the clients they want to target. - Always send "broadcast" events to ALL channels. Don't require channels to "subscribe" to receive broadcasts. This matches the documented behavior of `rpcnotify()`. --- test/functional/vimscript/api_functions_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 40d96ec281..b2865d2b4c 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -181,8 +181,8 @@ describe('eval-API', function() eq('Vim(call):E117: Unknown function: buffer_get_line', err) -- some api functions are only useful from a msgpack-rpc channel - err = exc_exec('call nvim_subscribe("fancyevent")') - eq('Vim(call):E117: Unknown function: nvim_subscribe', err) + err = exc_exec('call nvim_set_client_info()') + eq('Vim(call):E117: Unknown function: nvim_set_client_info', err) end) it('have metadata accessible with api_info()', function() -- cgit