From d6279f9392073cb1422d76c57baf3fd283ed954e Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 31 Jan 2023 23:35:04 +0100 Subject: refactor(tests): move lua-client into core and use it for functionaltests Eliminates lua-client and non-static libluv as test time dependencies Note: the API for a public lua-client is not yet finished. The interface needs to be adjusted to work in the embedded loop of a nvim instance (to use it to talk between instances) --- test/helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 82ff23bef8..d45536b42b 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -1,5 +1,5 @@ require('test.compat') -local shared = require('vim.shared') +local shared = vim local assert = require('luassert') local busted = require('busted') local luv = require('luv') -- cgit From ce597235a26839826de88ecd8b949ec54c310fbd Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 27 Feb 2023 16:31:05 +0100 Subject: feat(ui): restore has('gui_running') Problem: has('gui_running') is still common in the wild and our answer has changed over time, causing frustration. https://github.com/vimpostor/vim-tpipeline/commit/95a6ccbe9f33bc42dd4cee45731d8bc3fbcd92d1 Solution: Use stdin_tty/stdout_tty to decide if a UI is (not) a GUI. --- test/helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index d45536b42b..117b6b4aaa 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -312,7 +312,7 @@ function module.is_os(s) or s == 'bsd') then error('unknown platform: '..tostring(s)) end - return ((s == 'win' and module.sysname():find('windows')) + return not not ((s == 'win' and module.sysname():find('windows')) or (s == 'mac' and module.sysname() == 'darwin') or (s == 'freebsd' and module.sysname() == 'freebsd') or (s == 'openbsd' and module.sysname() == 'openbsd') -- cgit From 2ddb50fa1bf84284e36e9345bde2de786f3b4f72 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 5 Mar 2023 14:50:55 +0100 Subject: ci: skip core dump check The core dump check interferes with CI as it interprets any file with "core" in it to be a core dump, which is incorrect. --- test/helpers.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 117b6b4aaa..008b91073f 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -371,8 +371,12 @@ end local tests_skipped = 0 -function module.check_cores(app, force) - app = app or 'build/bin/nvim' +function module.check_cores(app, force) -- luacheck: ignore + -- Temporary workaround: skip core check as it interferes with CI. + if true then + return + end + app = app or 'build/bin/nvim' -- luacheck: ignore local initial_path, re, exc_re local gdb_db_cmd = 'gdb -n -batch -ex "thread apply all bt full" "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"' local lldb_db_cmd = 'lldb -Q -o "bt all" -f "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"' -- cgit From d4e2bfbe9cd2a09471da9089f45f89b74d720697 Mon Sep 17 00:00:00 2001 From: Enan Ajmain <3nan.ajmain@gmail.com> Date: Wed, 15 Mar 2023 17:17:30 +0600 Subject: test: Windows not detected in msys shells #22671 Problem: The functional tests have `is_os(s)` to determine if the current os is. E.g. `is_os("win")` returns true if the current os is Windows. This is done by checking if the sysname as detected by luv contains the substring 'windows'. In MSYS shells, the sysname is looks like MINGWXX_NT, where XX is either 32 or 64. So if you're using busted or luv that you built separately, not the nvim-bundled versions, then `is_os(s)` won't work. Solution: Treat sysname containing "mingw" as Windows. --- test/helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 008b91073f..b01e966464 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -312,7 +312,7 @@ function module.is_os(s) or s == 'bsd') then error('unknown platform: '..tostring(s)) end - return not not ((s == 'win' and module.sysname():find('windows')) + return not not ((s == 'win' and (module.sysname():find('windows') or module.sysname():find('mingw'))) or (s == 'mac' and module.sysname() == 'darwin') or (s == 'freebsd' and module.sysname() == 'freebsd') or (s == 'openbsd' and module.sysname() == 'openbsd') -- cgit From 743860de40502227b3f0ed64317eb937d24d4a36 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 4 Apr 2023 21:59:06 +0200 Subject: test: replace lfs with luv and vim.fs test: replace lfs with luv luv already pretty much does everything lfs does, so this duplication of dependencies isn't needed. --- test/helpers.lua | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index b01e966464..94dcf86c4d 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -3,7 +3,6 @@ local shared = vim local assert = require('luassert') local busted = require('busted') local luv = require('luv') -local lfs = require('lfs') local relpath = require('pl.path').relpath local Paths = require('test.cmakeconfig.paths') @@ -22,6 +21,28 @@ local module = { REMOVE_THIS = {}, } +function module.isdir(path) + if not path then + return false + end + local stat = luv.fs_stat(path) + if not stat then + return false + end + return stat.type == 'directory' +end + +function module.isfile(path) + if not path then + return false + end + local stat = luv.fs_stat(path) + if not stat then + return false + end + return stat.type == 'file' +end + function module.argss_to_cmd(...) local cmd = '' for i = 1, select('#', ...) do @@ -228,16 +249,16 @@ function module.glob(initial_path, re, exc_re) while #paths_to_check > 0 do local cur_path = paths_to_check[#paths_to_check] paths_to_check[#paths_to_check] = nil - for e in lfs.dir(cur_path) do + for e in vim.fs.dir(cur_path) do local full_path = cur_path .. '/' .. e local checked_path = full_path:sub(#initial_path + 1) if (not is_excluded(checked_path)) and e:sub(1, 1) ~= '.' then - local attrs = lfs.attributes(full_path) - if attrs then - local check_key = attrs.dev .. ':' .. tostring(attrs.ino) + local stat = luv.fs_stat(full_path) + if stat then + local check_key = stat.dev .. ':' .. tostring(stat.ino) if not checked_files[check_key] then checked_files[check_key] = true - if attrs.mode == 'directory' then + if stat.type == 'directory' then paths_to_check[#paths_to_check + 1] = full_path elseif not re or checked_path:match(re) then ret[#ret + 1] = full_path @@ -253,8 +274,8 @@ end function module.check_logs() local log_dir = os.getenv('LOG_DIR') local runtime_errors = {} - if log_dir and lfs.attributes(log_dir, 'mode') == 'directory' then - for tail in lfs.dir(log_dir) do + if log_dir and module.isdir(log_dir) then + for tail in vim.fs.dir(log_dir) do if tail:sub(1, 30) == 'valgrind-' or tail:find('san%.') then local file = log_dir .. '/' .. tail local fd = io.open(file) @@ -843,6 +864,11 @@ function module.read_nvim_log(logfile, ci_rename) return log end +function module.mkdir(path) + -- 493 is 0755 in decimal + return luv.fs_mkdir(path, 493) +end + module = shared.tbl_extend('error', module, Paths, shared, require('test.deprecated')) return module -- cgit From 3a3ec37260592b6c5ab96c4e8f7f96a7b411829f Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 14 Apr 2023 00:09:56 +0200 Subject: test: remove penlight usage --- test/helpers.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 94dcf86c4d..34c2036798 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -3,7 +3,6 @@ local shared = vim local assert = require('luassert') local busted = require('busted') local luv = require('luv') -local relpath = require('pl.path').relpath local Paths = require('test.cmakeconfig.paths') assert:set_parameter('TableFormatLevel', 100) @@ -21,6 +20,12 @@ local module = { REMOVE_THIS = {}, } +local function relpath(p) + p = vim.fs.normalize(p) + local cwd = luv.cwd() + return p:gsub("^" .. cwd) +end + function module.isdir(path) if not path then return false -- cgit From 3d29424fb9960085f09f7e322abf204eab9287b9 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 3 Apr 2023 12:01:23 +0100 Subject: refactor(unit): add type annotations --- test/helpers.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 34c2036798..8f06311a3c 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -20,12 +20,16 @@ local module = { REMOVE_THIS = {}, } +--- @param p string +--- @return string local function relpath(p) p = vim.fs.normalize(p) local cwd = luv.cwd() return p:gsub("^" .. cwd) end +--- @param path string +--- @return boolean function module.isdir(path) if not path then return false @@ -37,6 +41,8 @@ function module.isdir(path) return stat.type == 'directory' end +--- @param path string +--- @return boolean function module.isfile(path) if not path then return false @@ -48,6 +54,7 @@ function module.isfile(path) return stat.type == 'file' end +--- @return string function module.argss_to_cmd(...) local cmd = '' for i = 1, select('#', ...) do @@ -462,6 +469,7 @@ function module.check_cores(app, force) -- luacheck: ignore end end +--- @return string? function module.repeated_read_cmd(...) for _ = 1, 10 do local stream = module.popen_r(...) @@ -561,6 +569,9 @@ function module.concat_tables(...) return ret end +--- @param str string +--- @param leave_indent? boolean +--- @return string function module.dedent(str, leave_indent) -- find minimum common indent across lines local indent = nil -- cgit From 2ca076e45fb3f1c08f6a1a374834df0701b8d778 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 10 Aug 2023 14:21:56 +0100 Subject: feat(treesitter)!: incremental injection parsing Problem: Treesitter highlighting is slow for large files with lots of injections. Solution: Only parse injections we are going to render during a redraw cycle. --- - `LanguageTree:parse()` will no longer parse injections by default and now requires an explicit range argument to be passed. - `TSHighlighter` now parses injections incrementally during on_win callbacks for the line range being rendered. - Plugins which require certain injections to be parsed must run `parser:parse({ start_row, end_row })` before using the tree. --- test/helpers.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 8f06311a3c..f0e8576a3a 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -570,21 +570,23 @@ function module.concat_tables(...) end --- @param str string ---- @param leave_indent? boolean +--- @param leave_indent? integer --- @return string function module.dedent(str, leave_indent) -- find minimum common indent across lines - local indent = nil + local indent --- @type string? for line in str:gmatch('[^\n]+') do local line_indent = line:match('^%s+') or '' if indent == nil or #line_indent < #indent then indent = line_indent end end - if indent == nil or #indent == 0 then + + if not indent or #indent == 0 then -- no minimum common indent return str end + local left_indent = (' '):rep(leave_indent or 0) -- create a pattern for the indent indent = indent:gsub('%s', '[ \t]') -- cgit From d8e330bcec91c13feff87cf8c59ae34b687401f7 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sun, 13 Aug 2023 08:23:12 +0100 Subject: fix(test): remove test/compat.lua --- test/helpers.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index f0e8576a3a..51114611ab 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -1,4 +1,3 @@ -require('test.compat') local shared = vim local assert = require('luassert') local busted = require('busted') -- cgit From 845d5b8b64190e0e09a6a6dd97bdbc0e6f96eb02 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Wed, 19 Jul 2023 05:02:49 -0400 Subject: feat(treesitter): improve query error message --- test/helpers.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 51114611ab..02192e4924 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -188,10 +188,16 @@ function module.pcall(fn, ...) local errmsg = tostring(rv):gsub('([%s<])vim[/\\]([^%s:/\\]+):%d+', '%1\xffvim\xff%2:0') :gsub('[^%s<]-[/\\]([^%s:/\\]+):%d+', '.../%1:0') :gsub('\xffvim\xff', 'vim/') + -- Scrub numbers in paths/stacktraces: -- shared.lua:0: in function 'gsplit' -- shared.lua:0: in function ' - errmsg = errmsg:gsub('([^%s]):%d+', '%1:0') + errmsg = errmsg:gsub('([^%s].lua):%d+', '%1:0') + -- [string ""]:0: + -- [string ":lua"]:0: + -- [string ":luado"]:0: + errmsg = errmsg:gsub('(%[string "[^"]+"%]):%d+', '%1:0') + -- Scrub tab chars: errmsg = errmsg:gsub('\t', ' ') -- In Lua 5.1, we sometimes get a "(tail call): ?" on the last line. -- cgit From 468292dcb743c79714b030557cf2754b7b5bf07d Mon Sep 17 00:00:00 2001 From: LW Date: Fri, 3 Nov 2023 15:56:45 -0700 Subject: fix(rpc): "grid_line" event parsing crashes (#25581) refactor: use a more idiomatic loop to iterate over the cells There are two cases in which the following assertion would fail: ```c assert(g->icell < g->ncells); ``` 1. If `g->ncells = 0`. Update this to be legal. 2. If an EOF is reached while parsing `wrap`. In this case, the unpacker attempts to resume from `cells`, which is a bug. Create a new state for parsing `wrap`. Reference: https://neovim.io/doc/user/ui.html#ui-event-grid_line --- test/helpers.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 02192e4924..f9405c011d 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -15,6 +15,7 @@ local function shell_quote(str) end end +--- @class test.helpers local module = { REMOVE_THIS = {}, } -- cgit