diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/api/keymap_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/core/channels_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/eval/let_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/helpers.lua | 73 | ||||
-rw-r--r-- | test/functional/options/defaults_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/ui/options_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 7 | ||||
-rw-r--r-- | test/functional/ui/wildmode_spec.lua | 3 |
11 files changed, 30 insertions, 89 deletions
diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index c150787425..b3f6bb7895 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -1,5 +1,4 @@ local helpers = require('test.functional.helpers')(after_each) -local global_helpers = require('test.helpers') local bufmeths = helpers.bufmeths local clear = helpers.clear @@ -12,8 +11,8 @@ local funcs = helpers.funcs local meths = helpers.meths local source = helpers.source -local shallowcopy = global_helpers.shallowcopy -local sleep = global_helpers.sleep +local shallowcopy = helpers.shallowcopy +local sleep = helpers.sleep describe('nvim_get_keymap', function() before_each(clear) diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 4d25ba0819..7d9a8269d9 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -1,7 +1,6 @@ -- Test server -> client RPC scenarios. Note: unlike `rpcnotify`, to evaluate -- `rpcrequest` calls we need the client event loop to be running. local helpers = require('test.functional.helpers')(after_each) -local Paths = require('test.config.paths') local clear, nvim, eval = helpers.clear, helpers.nvim, helpers.eval local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop @@ -243,8 +242,8 @@ describe('server -> client', function() \ 'rpc': v:true \ } ]]) - local lua_prog = Paths.test_lua_prg - meths.set_var("args", {lua_prog, 'test/functional/api/rpc_fixture.lua'}) + meths.set_var("args", {helpers.test_lua_prg, + 'test/functional/api/rpc_fixture.lua'}) jobid = eval("jobstart(g:args, g:job_opts)") neq(0, 'jobid') end) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 2178abab53..a7d8dc59ec 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1,6 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local global_helpers = require('test.helpers') local NIL = helpers.NIL local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq @@ -16,10 +15,10 @@ local request = helpers.request local source = helpers.source local next_msg = helpers.next_msg -local expect_err = global_helpers.expect_err -local format_string = global_helpers.format_string -local intchar2lua = global_helpers.intchar2lua -local mergedicts_copy = global_helpers.mergedicts_copy +local expect_err = helpers.expect_err +local format_string = helpers.format_string +local intchar2lua = helpers.intchar2lua +local mergedicts_copy = helpers.mergedicts_copy describe('API', function() before_each(clear) diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua index 0137092eb5..ddaed1c448 100644 --- a/test/functional/core/channels_spec.lua +++ b/test/functional/core/channels_spec.lua @@ -1,7 +1,5 @@ -local global_helpers = require('test.helpers') -local uname = global_helpers.uname - local helpers = require('test.functional.helpers')(after_each) +local uname = helpers.uname local clear, eq, eval, next_msg, ok, source = helpers.clear, helpers.eq, helpers.eval, helpers.next_msg, helpers.ok, helpers.source local command, funcs, meths = helpers.command, helpers.funcs, helpers.meths diff --git a/test/functional/eval/let_spec.lua b/test/functional/eval/let_spec.lua index 0cbf40137e..63e18f943f 100644 --- a/test/functional/eval/let_spec.lua +++ b/test/functional/eval/let_spec.lua @@ -59,7 +59,7 @@ describe(':let', function() end) it("multibyte env var to child process #8398 #9267", function() - if (not helpers.iswin()) and require('test.helpers').isCI() then + if (not helpers.iswin()) and helpers.isCI() then -- Fails on non-Windows CI. Buffering/timing issue? pending('fails on unix CI', function() end) end diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index fd10a6afcd..35084f6cff 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -8,23 +8,14 @@ local Session = require('nvim.session') local TcpStream = require('nvim.tcp_stream') local SocketStream = require('nvim.socket_stream') local ChildProcessStream = require('nvim.child_process_stream') -local Paths = require('test.config.paths') local check_cores = global_helpers.check_cores local check_logs = global_helpers.check_logs local dedent = global_helpers.dedent local eq = global_helpers.eq -local expect_err = global_helpers.expect_err -local filter = global_helpers.filter -local map = global_helpers.map -local matches = global_helpers.matches -local near = global_helpers.near -local neq = global_helpers.neq local ok = global_helpers.ok -local read_file = global_helpers.read_file local sleep = global_helpers.sleep -local table_contains = global_helpers.table_contains -local table_flatten = global_helpers.table_flatten +local tbl_contains = global_helpers.tbl_contains local write_file = global_helpers.write_file local start_dir = lfs.currentdir() @@ -32,7 +23,7 @@ local start_dir = lfs.currentdir() local nvim_prog = ( os.getenv('NVIM_PROG') or os.getenv('NVIM_PRG') - or Paths.test_build_dir .. '/bin/nvim' + or global_helpers.test_build_dir .. '/bin/nvim' ) -- Default settings for the test session. local nvim_set = 'set shortmess+=I background=light noswapfile noautoindent' @@ -174,7 +165,7 @@ local function expect_msg_seq(...) error(cat_err(final_error, string.format('got %d messages (ignored %d), expected %d', #actual_seq, nr_ignored, #expected_seq))) - elseif table_contains(ignore, msg_type) then + elseif tbl_contains(ignore, msg_type) then nr_ignored = nr_ignored + 1 else table.insert(actual_seq, msg) @@ -348,9 +339,9 @@ local function remove_args(args, args_rm) end local last = '' for _, arg in ipairs(args) do - if table_contains(skip_following, last) then + if tbl_contains(skip_following, last) then last = '' - elseif table_contains(args_rm, arg) then + elseif tbl_contains(args_rm, arg) then last = arg else table.insert(new_args, arg) @@ -747,41 +738,14 @@ local function alter_slashes(obj) end end -local function compute_load_factor() - local timeout = 200 - local times = {} - - clear() - - for _ = 1, 5 do - source([[ - let g:val = 0 - call timer_start(200, {-> nvim_set_var('val', 1)}) - let start = reltime() - while 1 - sleep 10m - if g:val == 1 - let g:waited_in_ms = float2nr(reltimefloat(reltime(start)) * 1000) - break - endif - endwhile - ]]) - table.insert(times, nvim_eval('g:waited_in_ms')) - end - - session:close() - session = nil - - local longest = math.max(unpack(times)) - local factor = (longest + 50.0) / timeout - - return factor -end - --- Compute load factor only once. -local load_factor = compute_load_factor() +local load_factor = nil local function load_adjust(num) + if load_factor == nil then -- Compute load factor only once. + clear() + request('nvim_command', 'source src/nvim/testdir/load.vim') + load_factor = request('nvim_eval', 'g:test_load_factor') + end return math.ceil(num * load_factor) end @@ -802,33 +766,25 @@ local module = { curtabmeths = curtabmeths, curwin = curwin, curwinmeths = curwinmeths, - dedent = dedent, - eq = eq, eval = nvim_eval, exc_exec = exc_exec, expect = expect, expect_any = expect_any, - expect_err = expect_err, expect_msg_seq = expect_msg_seq, expect_twostreams = expect_twostreams, feed = feed, feed_command = feed_command, - filter = filter, funcs = funcs, get_pathsep = get_pathsep, get_session = get_session, insert = insert, iswin = iswin, - map = map, - matches = matches, merge_args = merge_args, meth_pcall = meth_pcall, meths = meths, missing_provider = missing_provider, mkdir = lfs.mkdir, load_adjust = load_adjust, - near = near, - neq = neq, new_pipename = new_pipename, next_msg = next_msg, nvim = nvim, @@ -838,13 +794,11 @@ local module = { nvim_prog = nvim_prog, nvim_prog_abs = nvim_prog_abs, nvim_set = nvim_set, - ok = ok, os_name = os_name, pathroot = pathroot, pending_win32 = pending_win32, prepend_argv = prepend_argv, rawfeed = rawfeed, - read_file = read_file, redir_exec = redir_exec, request = request, retry = retry, @@ -854,20 +808,17 @@ local module = { set_session = set_session, set_shell_powershell = set_shell_powershell, skip_fragile = skip_fragile, - sleep = sleep, source = source, spawn = spawn, stop = stop, - table_flatten = table_flatten, tabmeths = tabmeths, tabpage = tabpage, - tmpname = tmpname, uimeths = uimeths, wait = wait, window = window, winmeths = winmeths, - write_file = write_file, } +module = global_helpers.tbl_extend('error', module, global_helpers) return function(after_each) if after_each then diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index 0fc2876d00..415b526051 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -1,5 +1,4 @@ local helpers = require('test.functional.helpers')(after_each) -local global_helpers = require('test.helpers') local Screen = require('test.functional.ui.screen') @@ -16,7 +15,7 @@ local neq = helpers.neq local mkdir = helpers.mkdir local rmdir = helpers.rmdir local alter_slashes = helpers.alter_slashes -local table_contains = global_helpers.table_contains +local tbl_contains = helpers.tbl_contains describe('startup defaults', function() describe(':filetype', function() @@ -262,7 +261,7 @@ describe('XDG-based defaults', function() for _,v in ipairs(rtp) do local m = string.match(v, [=[[/\]nvim[^/\]*[/\]site.*$]=]) - if m and not table_contains(rv, m) then + if m and not tbl_contains(rv, m) then table.insert(rv, m) end end diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 469d088c57..56d6f68b7a 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -1,8 +1,7 @@ -- TUI acceptance tests. -- Uses :terminal as a way to send keys and assert screen state. -local global_helpers = require('test.helpers') -local uname = global_helpers.uname local helpers = require('test.functional.helpers')(after_each) +local uname = helpers.uname local thelpers = require('test.functional.terminal.helpers') local Screen = require('test.functional.ui.screen') local eq = helpers.eq diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index 7ce21f5d76..93192934c7 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -1,10 +1,9 @@ -local global_helpers = require('test.helpers') local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command local eq = helpers.eq -local shallowcopy = global_helpers.shallowcopy +local shallowcopy = helpers.shallowcopy describe('ui receives option updates', function() local screen diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 53b6642207..a81851cbba 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -71,11 +71,10 @@ -- To help write screen tests, see Screen:snapshot_util(). -- To debug screen tests, see Screen:redraw_debug(). -local global_helpers = require('test.helpers') -local deepcopy = global_helpers.deepcopy -local shallowcopy = global_helpers.shallowcopy -local concat_tables = global_helpers.concat_tables local helpers = require('test.functional.helpers')(nil) +local deepcopy = helpers.deepcopy +local shallowcopy = helpers.shallowcopy +local concat_tables = helpers.concat_tables local request, run_session = helpers.request, helpers.run_session local eq = helpers.eq local dedent = helpers.dedent diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 1c8854bb28..f4b80fd428 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -1,7 +1,6 @@ -local global_helpers = require('test.helpers') -local shallowcopy = global_helpers.shallowcopy local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') +local shallowcopy = helpers.shallowcopy local clear, feed, command = helpers.clear, helpers.feed, helpers.command local iswin = helpers.iswin local funcs = helpers.funcs |