From 2d6735d8cecc587eb5549f65260ee9ddeb8e1d78 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 9 Sep 2022 00:12:42 +0200 Subject: ci: move BSD jobs from sourcehut to Cirrus CI #19616 dispatch.sr.ht is being deprecated, meaning that using sourcehut CI won't be possible (see https://github.com/neovim/neovim/issues/19609). Since Github Actions doesn't provide any BSD runners an external service is required and Cirrus CI seems like a good replacement for sourcehut. Initially experimented with using FreeBSD and OpenBSD virtual machines in GitHub Actions, but Cirrus has been a much better fit with better performance, logs and overall experience. Failing tests are automatically skipped on FreeBSD regardless if it's on CI or not. Ideally these tests should only be skipped in CI with the help of `isCI` helper function. Unfortunately, the tests don't recognize the environment variable CIRRUS_CI even if it's set manually. This workaround is good enough for the time being, but we might want to only skip tests when using the CI (or even better, fix the failing tests). Closes: https://github.com/neovim/neovim/issues/19609 --- test/helpers.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 7ec9beea92..499b91488b 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -790,10 +790,9 @@ end function module.isCI(name) local any = (name == nil) - assert(any or name == 'sourcehut' or name == 'github') - local sh = ((any or name == 'sourcehut') and nil ~= os.getenv('SOURCEHUT')) + assert(any or name == 'github') local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS')) - return sh or gh + return gh end -- cgit From abe2d90693e5cec3428c0162c48f0ea38972ff31 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 20 Sep 2022 11:15:32 +0100 Subject: feat(lua): move compat module from runtime to test (#20257) --- 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 499b91488b..a7eda60f87 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -1,4 +1,4 @@ -require('vim.compat') +require('test.compat') local shared = require('vim.shared') local assert = require('luassert') local luv = require('luv') -- cgit From 5046b4b4adb154bbdb50a5e96e29f777b5f807ac Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 17 Oct 2022 17:16:31 +0200 Subject: ci: add cirrus to isCI function to skip tests (#20526) The environment variable CIRRUS_CI is manually passed to RunTests.cmake as it doesn't get passed when using cmake script mode. --- test/helpers.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index a7eda60f87..225a4d35b4 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -790,10 +790,10 @@ end function module.isCI(name) local any = (name == nil) - assert(any or name == 'github') + assert(any or name == 'github' or name == 'cirrus') local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS')) - return gh - + local cirrus = ((any or name == 'cirrus') and nil ~= os.getenv('CIRRUS_CI')) + return gh or cirrus end -- Gets the (tail) contents of `logfile`. -- cgit From e8cc489accc435076afb4fdf89778b64f0a48473 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 14 Nov 2022 10:01:35 +0000 Subject: feat(test): add Lua forms for API methods (#20152) --- test/helpers.lua | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 225a4d35b4..68c1b17dbc 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -114,25 +114,13 @@ function module.assert_nolog(pat, logfile, nrlines) return module.assert_log(pat, logfile, nrlines, true) end --- Invokes `fn` and returns the error string (with truncated paths), or raises --- an error if `fn` succeeds. --- --- Replaces line/column numbers with zero: --- shared.lua:0: in function 'gsplit' --- shared.lua:0: in function ' --- --- Usage: --- -- Match exact string. --- eq('e', pcall_err(function(a, b) error('e') end, 'arg1', 'arg2')) --- -- Match Lua pattern. --- matches('e[or]+$', pcall_err(function(a, b) error('some error') end, 'arg1', 'arg2')) --- -function module.pcall_err_withfile(fn, ...) +function module.pcall(fn, ...) assert(type(fn) == 'function') local status, rv = pcall(fn, ...) - if status == true then - error('expected failure, but got success') + if status then + return status, rv end + -- From: -- C:/long/path/foo.lua:186: Expected string, got number -- to: @@ -150,13 +138,37 @@ function module.pcall_err_withfile(fn, ...) -- We remove this so that the tests are not lua dependent. errmsg = errmsg:gsub('%s*%(tail call%): %?', '') - return errmsg + return status, errmsg +end + +-- Invokes `fn` and returns the error string (with truncated paths), or raises +-- an error if `fn` succeeds. +-- +-- Replaces line/column numbers with zero: +-- shared.lua:0: in function 'gsplit' +-- shared.lua:0: in function ' +-- +-- Usage: +-- -- Match exact string. +-- eq('e', pcall_err(function(a, b) error('e') end, 'arg1', 'arg2')) +-- -- Match Lua pattern. +-- matches('e[or]+$', pcall_err(function(a, b) error('some error') end, 'arg1', 'arg2')) +-- +function module.pcall_err_withfile(fn, ...) + assert(type(fn) == 'function') + local status, rv = module.pcall(fn, ...) + if status == true then + error('expected failure, but got success') + end + return rv end function module.pcall_err_withtrace(fn, ...) local errmsg = module.pcall_err_withfile(fn, ...) - return errmsg:gsub('.../helpers.lua:0: ', '') + return errmsg:gsub('^%.%.%./helpers%.lua:0: ', '') + :gsub('^Error executing lua:- ' ,'') + :gsub('^%[string ""%]:0: ' ,'') end function module.pcall_err(...) -- cgit From 5eb5f4948826e9d47685ea9e257409cc3e693614 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 22 Nov 2022 01:13:30 +0100 Subject: test: simplify platform detection (#21020) Extend the capabilities of is_os to detect more platforms such as freebsd and openbsd. Also remove `iswin()` helper function as it can be replaced by `is_os("win")`. --- test/helpers.lua | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 68c1b17dbc..eef47563a0 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -269,14 +269,10 @@ function module.check_logs() table.concat(runtime_errors, ', '))) end -function module.iswin() - return package.config:sub(1,1) == '\\' -end - --- Gets (lowercase) OS name from CMake, uname, or "win" if iswin(). -module.uname = (function() +-- Gets (lowercase) OS name from CMake, uname, or manually check if on Windows +do local platform = nil - return (function() + function module.uname() if platform then return platform end @@ -290,22 +286,28 @@ module.uname = (function() if status then platform = string.lower(f:read("*l")) f:close() - elseif module.iswin() then + elseif package.config:sub(1,1) == '\\' then platform = 'windows' else error('unknown platform') end return platform - end) -end)() + end +end function module.is_os(s) - if not (s == 'win' or s == 'mac' or s == 'unix') then + if not (s == 'win' + or s == 'mac' + or s == 'freebsd' + or s == 'openbsd' + or s == 'bsd') then error('unknown platform: '..tostring(s)) end - return ((s == 'win' and module.iswin()) + return ((s == 'win' and module.uname() == 'windows') or (s == 'mac' and module.uname() == 'darwin') - or (s == 'unix')) + or (s == 'freebsd' and module.uname() == 'freebsd') + or (s == 'openbsd' and module.uname() == 'openbsd') + or (s == 'bsd' and string.find(module.uname(), 'bsd'))) end local function tmpdir_get() @@ -331,11 +333,11 @@ module.tmpname = (function() return fname else local fname = os.tmpname() - if module.uname() == 'windows' and fname:sub(1, 2) == '\\s' then + if module.is_os('win') and fname:sub(1, 2) == '\\s' then -- In Windows tmpname() returns a filename starting with -- special sequence \s, prepend $TEMP path return tmpdir..fname - elseif fname:match('^/tmp') and module.uname() == 'darwin' then + elseif fname:match('^/tmp') and module.is_os('mac') then -- In OS X /tmp links to /private/tmp return '/private'..fname else @@ -378,14 +380,14 @@ function module.check_cores(app, force) exc_re = { os.getenv('NVIM_TEST_CORE_EXC_RE'), local_tmpdir } db_cmd = os.getenv('NVIM_TEST_CORE_DB_CMD') or gdb_db_cmd random_skip = os.getenv('NVIM_TEST_CORE_RANDOM_SKIP') - elseif 'darwin' == module.uname() then + elseif module.is_os('mac') then initial_path = '/cores' re = nil exc_re = { local_tmpdir } db_cmd = lldb_db_cmd else initial_path = '.' - if 'freebsd' == module.uname() then + if module.is_os('freebsd') then re = '/nvim.core$' else re = '/core[^/]*$' @@ -800,7 +802,7 @@ function module.write_file(name, text, no_dedent, append) file:close() end -function module.isCI(name) +function module.is_ci(name) local any = (name == nil) assert(any or name == 'github' or name == 'cirrus') local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS')) @@ -812,7 +814,7 @@ end -- Also moves the file to "${NVIM_LOG_FILE}.displayed" on CI environments. function module.read_nvim_log(logfile, ci_rename) logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog' - local is_ci = module.isCI() + local is_ci = module.is_ci() local keep = is_ci and 100 or 10 local lines = module.read_file_list(logfile, -keep) or {} local log = (('-'):rep(78)..'\n' -- cgit From dcc686a208677a173430ace5e8a1ac73da9651d0 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 2 Dec 2022 05:36:31 +0100 Subject: test: use luv.os_uname for fast platform detection (#21157) --- test/helpers.lua | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index eef47563a0..3fe4322501 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -269,29 +269,10 @@ function module.check_logs() table.concat(runtime_errors, ', '))) end --- Gets (lowercase) OS name from CMake, uname, or manually check if on Windows -do - local platform = nil - function module.uname() - if platform then - return platform - end - - if os.getenv("SYSTEM_NAME") then -- From CMAKE_HOST_SYSTEM_NAME. - platform = string.lower(os.getenv("SYSTEM_NAME")) - return platform - end - - local status, f = pcall(module.popen_r, 'uname', '-s') - if status then - platform = string.lower(f:read("*l")) - f:close() - elseif package.config:sub(1,1) == '\\' then - platform = 'windows' - else - error('unknown platform') - end - return platform +function module.sysname() + local platform = luv.os_uname() + if platform and platform.sysname then + return platform.sysname:lower() end end @@ -303,11 +284,11 @@ function module.is_os(s) or s == 'bsd') then error('unknown platform: '..tostring(s)) end - return ((s == 'win' and module.uname() == 'windows') - or (s == 'mac' and module.uname() == 'darwin') - or (s == 'freebsd' and module.uname() == 'freebsd') - or (s == 'openbsd' and module.uname() == 'openbsd') - or (s == 'bsd' and string.find(module.uname(), 'bsd'))) + return ((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') + or (s == 'bsd' and module.sysname():find('bsd'))) end local function tmpdir_get() -- cgit