aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/unit/helpers.lua50
-rw-r--r--third-party/cmake/BuildLuarocks.cmake9
2 files changed, 58 insertions, 1 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index 4af078b486..482bedd6c0 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -4,6 +4,9 @@ local Set = require('test.unit.set')
local Preprocess = require('test.unit.preprocess')
local Paths = require('test.config.paths')
local global_helpers = require('test.helpers')
+local posix = require('posix')
+local assert = require('luassert')
+local say = require('say')
local neq = global_helpers.neq
local eq = global_helpers.eq
@@ -216,6 +219,52 @@ do
main.event_init()
end
+local function gen_itp(it)
+ local function just_fail(_)
+ return false
+ end
+ say:set('assertion.just_fail.positive', '%s')
+ say:set('assertion.just_fail.negative', '%s')
+ assert:register('assertion', 'just_fail', just_fail,
+ 'assertion.just_fail.positive',
+ 'assertion.just_fail.negative')
+ local function itp(name, func)
+ it(name, function()
+ local rd, wr = posix.pipe()
+ local pid = posix.fork()
+ if pid == 0 then
+ posix.close(rd)
+ local err, emsg = pcall(func)
+ emsg = tostring(emsg)
+ if not err then
+ posix.write(wr, ('-\n%05u\n%s'):format(#emsg, emsg))
+ posix.close(wr)
+ posix._exit(1)
+ else
+ posix.write(wr, '+\n')
+ posix.close(wr)
+ posix._exit(0)
+ end
+ else
+ posix.close(wr)
+ posix.wait(pid)
+ local res = posix.read(rd, 2)
+ eq(2, #res)
+ if res == '+\n' then
+ return
+ end
+ eq('-\n', res)
+ local len_s = posix.read(rd, 5)
+ local len = tonumber(len_s)
+ neq(0, len)
+ local err = posix.read(rd, len + 1)
+ assert.just_fail(err)
+ end
+ end)
+ end
+ return itp
+end
+
return {
cimport = cimport,
cppimport = cppimport,
@@ -231,4 +280,5 @@ return {
OK = OK,
FAIL = FAIL,
alloc_log_new = alloc_log_new,
+ gen_itp = gen_itp,
}
diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake
index 9ea96b7cc5..6ab87b9bc3 100644
--- a/third-party/cmake/BuildLuarocks.cmake
+++ b/third-party/cmake/BuildLuarocks.cmake
@@ -172,5 +172,12 @@ if(USE_BUNDLED_BUSTED)
add_custom_target(nvim-client
DEPENDS ${HOSTDEPS_LIB_DIR}/luarocks/rocks/nvim-client)
- list(APPEND THIRD_PARTY_DEPS busted luacheck nvim-client)
+ add_custom_command(OUTPUT ${HOSTDEPS_BIN_DIR}/luaposix
+ COMMAND ${LUAROCKS_BINARY}
+ ARGS build https://raw.githubusercontent.com/luaposix/luaposix/release-v33.4.0/luaposix-33.4.0-1.rockspec ${LUAROCKS_BUILDARGS}
+ DEPENDS luarocks)
+ add_custom_target(luaposix
+ DEPENDS ${HOSTDEPS_BIN_DIR}/luaposix)
+
+ list(APPEND THIRD_PARTY_DEPS busted luacheck nvim-client luaposix)
endif()