unittests: Allow failing test to fail

This commit is contained in:
ZyX 2016-11-04 18:20:58 +03:00
parent ff5dca6630
commit b442574862

View File

@ -375,7 +375,7 @@ local function gen_itp(it)
assert:register('assertion', 'just_fail', just_fail,
'assertion.just_fail.positive',
'assertion.just_fail.negative')
local function itp(name, func)
local function itp(name, func, allow_failure)
it(name, function()
local rd, wr = sc.pipe()
local pid = sc.fork()
@ -397,6 +397,7 @@ local function gen_itp(it)
else
sc.close(wr)
sc.wait(pid)
local function check()
local res = sc.read(rd, 2)
eq(2, #res)
if res == '+\n' then
@ -409,6 +410,16 @@ local function gen_itp(it)
local err = sc.read(rd, len + 1)
assert.just_fail(err)
end
if allow_failure then
local err, emsg = pcall(check)
if not err then
io.stderr:write('Errorred out:\n' .. tostring(emsg) .. '\n')
os.execute([[sh -c "source .ci/common/test.sh ; check_core_dumps --delete \"\$(which luajit)\""]])
end
else
check()
end
end
end)
end
return itp