From dd26bd59745c9fd358624312feb315ec0f106de8 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 1 Sep 2019 11:13:13 +0200 Subject: screen: don't crash on invalid grid cells being recomposed --- test/functional/helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index b29161e34c..bd36bac062 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -38,7 +38,7 @@ module.nvim_prog = ( module.nvim_set = ( 'set shortmess+=IS background=light noswapfile noautoindent' ..' laststatus=1 undodir=. directory=. viewdir=. backupdir=.' - ..' belloff= wildoptions-=pum noshowcmd noruler nomore') + ..' belloff= wildoptions-=pum noshowcmd noruler nomore redrawdebug=invalid') module.nvim_argv = { module.nvim_prog, '-u', 'NONE', '-i', 'NONE', '--cmd', module.nvim_set, '--embed'} -- cgit From e452988960b11e971d839c27dcd2f42e68f3aa4d Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 6 Oct 2019 22:26:54 +0200 Subject: tests/functional: keep $TMPDIR in env (#11163) --- test/functional/helpers.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index bd36bac062..c195983e93 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -437,6 +437,7 @@ function module.new_argv(...) 'NVIM_LOG_FILE', 'NVIM_RPLUGIN_MANIFEST', 'GCOV_ERROR_FILE', + 'TMPDIR', }) do if not env_tbl[k] then env_tbl[k] = os.getenv(k) -- cgit From 51f2826f617532aaf5d682dfc3229f3723427ce6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 10 Oct 2019 04:16:02 -0400 Subject: doc: update shellquote for powershell #11122 shellquote is not treated like shellxquote for non-quote values. --- test/functional/helpers.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index c195983e93..20371b8ab0 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -501,9 +501,20 @@ function module.source(code) end function module.set_shell_powershell() + local shell = iswin() and 'powershell' or 'pwsh' + if not module.eval('executable("'..shell..'")') then + error(shell..' is not executable') + end + local aliases = iswin() and {'cat', 'sleep'} or {} + local cmd = '' + for _, alias in ipairs(aliases) do + cmd = cmd .. 'Remove-Item -Force alias:' .. alias .. ';' + end module.source([[ - set shell=powershell shellquote=( shellpipe=\| shellredir=> shellxquote= - let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command Remove-Item -Force alias:sleep; Remove-Item -Force alias:cat;' + let &shell = ']]..shell..[[' + set shellquote= shellpipe=\| shellxquote= + let &shellredir = '| Out-File -Encoding UTF8' + let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ]]..cmd..[[' ]]) end -- cgit From a7fc2f3f64f05ffd2a97c8ccf2e5c74d905ac808 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 11 Oct 2019 00:30:20 -0400 Subject: test: "!:&" works with powershell #11201 Removed 'echo' alias because it does not behave like POSIX echo. --- test/functional/helpers.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 20371b8ab0..2473fc0d3b 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -502,14 +502,10 @@ end function module.set_shell_powershell() local shell = iswin() and 'powershell' or 'pwsh' - if not module.eval('executable("'..shell..'")') then - error(shell..' is not executable') - end - local aliases = iswin() and {'cat', 'sleep'} or {} - local cmd = '' - for _, alias in ipairs(aliases) do - cmd = cmd .. 'Remove-Item -Force alias:' .. alias .. ';' - end + assert(module.eval('executable("'..shell..'")')) + local cmd = 'Remove-Item -Force '..table.concat(iswin() + and {'alias:cat', 'alias:echo', 'alias:sleep'} + or {'alias:echo'}, ',')..';' module.source([[ let &shell = ']]..shell..[[' set shellquote= shellpipe=\| shellxquote= -- cgit From d89ec55c45e73544c614a3436ae16b9ea17b5535 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 19 Oct 2019 23:15:07 +0200 Subject: test/functional: retry/Screen: failure instead of error #11173 - Running out of retries, or unexpected screen state should make the test FAIL, not ERROR. - Uses levels to report the location of the caller. - Improve message with retry-failure (formatting). Before: [ RUN ] test: 103.53 ms ERR test/functional/helpers.lua:388: retry() attempts: 1 test/functional/ui/screen.lua:587: Row 1 did not match. Expected: |*X^ | |{0:~ }| |{0:~ }| | | Actual: |*^ | |{0:~ }| |{0:~ }| | | To print the expect() call that would assert the current screen state, use screen:snapshot_util(). In case of non-deterministic failures, use screen:redraw_debug() to show all intermediate screen states. stack traceback: test/functional/helpers.lua:388: in function 'retry' test/functional/test_spec.lua:24: in function After: [ RUN ] test: 105.22 ms FAIL test/functional/test_spec.lua:24: stopping after 1 retry() attempts. test/functional/test_spec.lua:25: Row 1 did not match. Expected: |*X^ | |{0:~ }| |{0:~ }| | | Actual: |*^ | |{0:~ }| |{0:~ }| | | To print the expect() call that would assert the current screen state, use screen:snapshot_util(). In case of non-deterministic failures, use screen:redraw_debug() to show all intermediate screen states. stack traceback: test/functional/helpers.lua:389: in function 'retry' test/functional/test_spec.lua:24: in function --- test/functional/helpers.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 2473fc0d3b..a6ff10c0a4 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -1,4 +1,5 @@ require('coxpcall') +local busted = require('busted') local luv = require('luv') local lfs = require('lfs') local mpack = require('mpack') @@ -385,7 +386,7 @@ function module.retry(max, max_ms, fn) end luv.update_time() -- Update cached value of luv.now() (libuv: uv_now()). if (max and tries >= max) or (luv.now() - start_time > timeout) then - error("\nretry() attempts: "..tostring(tries).."\n"..tostring(result)) + busted.fail(string.format("retry() attempts: %d\n%s", tries, tostring(result)), 2) end tries = tries + 1 luv.sleep(20) -- Avoid hot loop... -- cgit From 019c8d13dd7056725c0715dc15e451118b767b7d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 19 Oct 2019 18:04:08 -0700 Subject: build/doc/CI: remove/update quickbuild references #11258 --- test/functional/helpers.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index a6ff10c0a4..1108fbb2ba 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -29,10 +29,8 @@ local module = { } local start_dir = lfs.currentdir() --- XXX: NVIM_PROG takes precedence, QuickBuild sets it. module.nvim_prog = ( - os.getenv('NVIM_PROG') - or os.getenv('NVIM_PRG') + os.getenv('NVIM_PRG') or global_helpers.test_build_dir .. '/bin/nvim' ) -- Default settings for the test session. -- cgit From a3b6c2a3dc5576db45fe4e893cfb8482af591c92 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Dec 2019 00:46:46 -0800 Subject: API: rename nvim_execute_lua => nvim_exec_lua - We already find ourselves renaming nvim_execute_lua in tests and scripts, which suggests "exec" is the verb we actually want. - Add "exec" verb to `:help dev-api`. --- test/functional/helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 1108fbb2ba..0f2b04ea00 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -706,7 +706,7 @@ module.curwinmeths = module.create_callindex(module.curwin) module.curtabmeths = module.create_callindex(module.curtab) function module.exec_lua(code, ...) - return module.meths.execute_lua(code, {...}) + return module.meths.exec_lua(code, {...}) end function module.redir_exec(cmd) -- cgit From 3beef8ee1ca9699d75b8877ec9b77493b58b0ed4 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 1 Oct 2019 23:14:00 +0900 Subject: defaults: set nostartofline Having the cursor change column can be surprising. Force startofline in functional and old tests. Remove the functional breakindent test, as it's a subset of the oldtest one. --- test/functional/helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 1108fbb2ba..9fcd1cf7b1 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -35,7 +35,7 @@ module.nvim_prog = ( ) -- Default settings for the test session. module.nvim_set = ( - 'set shortmess+=IS background=light noswapfile noautoindent' + 'set shortmess+=IS background=light noswapfile noautoindent startofline' ..' laststatus=1 undodir=. directory=. viewdir=. backupdir=.' ..' belloff= wildoptions-=pum noshowcmd noruler nomore redrawdebug=invalid') module.nvim_argv = { -- cgit From 4598e489c797dd3e287b51711ac1924cf6bded1f Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Fri, 9 Nov 2018 23:52:57 +0900 Subject: test: always pass a string to expect_msg_seq Seems like pcall doesn't always return a string as a 2nd element of the tuple. --- test/functional/helpers.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 0f2b04ea00..77d4b573fc 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -186,7 +186,12 @@ function module.expect_msg_seq(...) if status then return result end - final_error = cat_err(final_error, result) + local message = result + if type(result) == "table" then + -- 'eq' returns several things + message = result.message + end + final_error = cat_err(final_error, message) end error(final_error) end -- cgit From 1836853955e51efbaf4aba7dec0718e51747b418 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 31 Dec 2019 14:21:57 -0500 Subject: ci: test powershell core on Linux --- test/functional/helpers.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index eead1ea3e0..0fdfcd70ba 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -504,9 +504,13 @@ function module.source(code) return fname end +function module.has_powershell() + return module.eval('executable("'..(iswin() and 'powershell' or 'pwsh')..'")') == 1 +end + function module.set_shell_powershell() local shell = iswin() and 'powershell' or 'pwsh' - assert(module.eval('executable("'..shell..'")')) + assert(module.has_powershell()) local cmd = 'Remove-Item -Force '..table.concat(iswin() and {'alias:cat', 'alias:echo', 'alias:sleep'} or {'alias:echo'}, ',')..';' -- cgit From 8c8681d594a10c7056d62d09267190b6fab37e85 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 8 Jan 2020 09:32:49 -0800 Subject: test: hoist buf_lines() --- test/functional/helpers.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 0fdfcd70ba..e0012c6ced 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -559,6 +559,11 @@ function module.wait() session:request('nvim_eval', '1') end +function module.buf_lines(bufnr) + return module.exec_lua("return vim.api.nvim_buf_get_lines((...), 0, -1, false)", bufnr) +end + +--@see buf_lines() function module.curbuf_contents() module.wait() -- Before inspecting the buffer, process all input. return table.concat(module.curbuf('get_lines', 0, -1, true), '\n') -- cgit From 156c25e4983d4c106ba70e5e3bcc6bbb012d8065 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 13 Jan 2020 00:19:20 -0800 Subject: WinClosed: sort auevents.lua; improve tests - test: reduce verbosity, condense redundancy, improve readability - auevents.lua: keep events sorted by name. ref afd1d412fa91 --- test/functional/helpers.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index e0012c6ced..de61ff9cc8 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -597,6 +597,19 @@ function module.assert_alive() assert(2 == module.eval('1+1'), 'crash? request failed') end +-- Asserts that buffer is loaded and visible in the current tabpage. +function module.assert_visible(bufnr, visible) + assert(type(visible) == 'boolean') + eq(visible, module.bufmeths.is_loaded(bufnr)) + if visible then + assert(-1 ~= module.funcs.bufwinnr(bufnr), + 'expected buffer to be visible in current tabpage: '..tostring(bufnr)) + else + assert(-1 == module.funcs.bufwinnr(bufnr), + 'expected buffer NOT visible in current tabpage: '..tostring(bufnr)) + end +end + local function do_rmdir(path) local mode, errmsg, errcode = lfs.attributes(path, 'mode') if mode == nil then -- cgit From 3420bd21e19cf5feaeca1524e0dfcbabaac5d7c5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 13 Jan 2020 19:48:59 -0500 Subject: provider/perl: add basic tests --- test/functional/helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index de61ff9cc8..3ffc6137d6 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -768,7 +768,7 @@ function module.new_pipename() end function module.missing_provider(provider) - if provider == 'ruby' or provider == 'node' then + if provider == 'ruby' or provider == 'node' or provider == 'perl' then local prog = module.funcs['provider#' .. provider .. '#Detect']() return prog == '' and (provider .. ' not detected') or false elseif provider == 'python' or provider == 'python3' then -- cgit From 1c3ca4f18fdc403813d8959b49626ac1c99e2c59 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 26 Jan 2020 14:26:01 -0800 Subject: mksession: always unix slashes "/" for filepaths --- test/functional/helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 3ffc6137d6..53c4d140b6 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -794,7 +794,7 @@ function module.alter_slashes(obj) end return ret else - assert(false, 'Could only alter slashes for tables of strings and strings') + assert(false, 'expected string or table of strings, got '..type(obj)) end end -- cgit From e2ed8053bf722d4d111fac7dcdb07179fdea8752 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Tue, 18 Feb 2020 17:41:29 +0900 Subject: lua: move test helper function, map and filter, to vim.shared module --- test/functional/helpers.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/helpers.lua') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 53c4d140b6..e8435cd3b7 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -15,9 +15,9 @@ 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 filter = global_helpers.filter +local filter = global_helpers.tbl_filter local is_os = global_helpers.is_os -local map = global_helpers.map +local map = global_helpers.tbl_map local ok = global_helpers.ok local sleep = global_helpers.sleep local tbl_contains = global_helpers.tbl_contains -- cgit