tests: move "busted" dir to "test" (#10518)
* tests: move "busted" dir to "test" It is used for outputHandlers only, and clearly belongs to the tests. Use the full module name with the `-o` option to `busted` then for clarity. * luacheck * test/busted/outputHandlers/TAP.lua: use/extend upstream
This commit is contained in:
parent
3a1d3e9ef1
commit
34c6e5beaf
|
@ -11,6 +11,7 @@ cache = true
|
||||||
|
|
||||||
ignore = {
|
ignore = {
|
||||||
"631", -- max_line_length
|
"631", -- max_line_length
|
||||||
|
"212/_.*", -- unused argument, for vars with "_" prefix
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Global objects defined by the C code
|
-- Global objects defined by the C code
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
-- TODO(jkeyes): Use the upstream version when busted releases it. (But how to
|
|
||||||
-- inject our call to global_helpers.read_nvim_log() ?)
|
|
||||||
|
|
||||||
local pretty = require 'pl.pretty'
|
|
||||||
local global_helpers = require('test.helpers')
|
|
||||||
|
|
||||||
return function(options)
|
|
||||||
local busted = require 'busted'
|
|
||||||
local handler = require 'busted.outputHandlers.base'()
|
|
||||||
|
|
||||||
local success = 'ok %u - %s'
|
|
||||||
local failure = 'not ' .. success
|
|
||||||
local skip = 'ok %u - # SKIP %s'
|
|
||||||
local counter = 0
|
|
||||||
|
|
||||||
handler.suiteReset = function()
|
|
||||||
counter = 0
|
|
||||||
return nil, true
|
|
||||||
end
|
|
||||||
|
|
||||||
handler.suiteEnd = function()
|
|
||||||
io.write(global_helpers.read_nvim_log())
|
|
||||||
print('1..' .. counter)
|
|
||||||
io.flush()
|
|
||||||
return nil, true
|
|
||||||
end
|
|
||||||
|
|
||||||
local function showFailure(t)
|
|
||||||
local message = t.message
|
|
||||||
local trace = t.trace or {}
|
|
||||||
|
|
||||||
if message == nil then
|
|
||||||
message = 'Nil error'
|
|
||||||
elseif type(message) ~= 'string' then
|
|
||||||
message = pretty.write(message)
|
|
||||||
end
|
|
||||||
|
|
||||||
print(failure:format(counter, t.name))
|
|
||||||
print('# ' .. t.element.trace.short_src .. ' @ ' .. t.element.trace.currentline)
|
|
||||||
if t.randomseed then print('# Random seed: ' .. t.randomseed) end
|
|
||||||
print('# Failure message: ' .. message:gsub('\n', '\n# '))
|
|
||||||
if options.verbose and trace.traceback then
|
|
||||||
print('# ' .. trace.traceback:gsub('^\n', '', 1):gsub('\n', '\n# '))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
handler.testStart = function(element, parent)
|
|
||||||
local trace = element.trace
|
|
||||||
if options.verbose and trace and trace.short_src then
|
|
||||||
local fileline = trace.short_src .. ' @ ' .. trace.currentline .. ': '
|
|
||||||
local testName = fileline .. handler.getFullName(element)
|
|
||||||
print('# ' .. testName)
|
|
||||||
end
|
|
||||||
io.flush()
|
|
||||||
|
|
||||||
return nil, true
|
|
||||||
end
|
|
||||||
|
|
||||||
handler.testEnd = function(element, parent, status, trace)
|
|
||||||
counter = counter + 1
|
|
||||||
if status == 'success' then
|
|
||||||
local t = handler.successes[#handler.successes]
|
|
||||||
print(success:format(counter, t.name))
|
|
||||||
elseif status == 'pending' then
|
|
||||||
local t = handler.pendings[#handler.pendings]
|
|
||||||
print(skip:format(counter, (t.message or t.name)))
|
|
||||||
elseif status == 'failure' then
|
|
||||||
showFailure(handler.failures[#handler.failures])
|
|
||||||
elseif status == 'error' then
|
|
||||||
showFailure(handler.errors[#handler.errors])
|
|
||||||
end
|
|
||||||
io.flush()
|
|
||||||
|
|
||||||
return nil, true
|
|
||||||
end
|
|
||||||
|
|
||||||
handler.error = function(element, parent, message, debug)
|
|
||||||
if element.descriptor ~= 'it' then
|
|
||||||
counter = counter + 1
|
|
||||||
showFailure(handler.errors[#handler.errors])
|
|
||||||
end
|
|
||||||
io.flush()
|
|
||||||
|
|
||||||
return nil, true
|
|
||||||
end
|
|
||||||
|
|
||||||
busted.subscribe({ 'suite', 'reset' }, handler.suiteReset)
|
|
||||||
busted.subscribe({ 'suite', 'end' }, handler.suiteEnd)
|
|
||||||
busted.subscribe({ 'test', 'start' }, handler.testStart, { predicate = handler.cancelOnPending })
|
|
||||||
busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending })
|
|
||||||
busted.subscribe({ 'error' }, handler.error)
|
|
||||||
|
|
||||||
return handler
|
|
||||||
end
|
|
|
@ -43,7 +43,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory $ENV{TMPDIR})
|
||||||
|
|
||||||
set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/helpers.lua.
|
set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/helpers.lua.
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${BUSTED_PRG} -v -o ${BUSTED_OUTPUT_TYPE}
|
COMMAND ${BUSTED_PRG} -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE}
|
||||||
--lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
|
--lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
|
||||||
--lpath=${BUILD_DIR}/?.lua
|
--lpath=${BUILD_DIR}/?.lua
|
||||||
--lpath=${WORKING_DIR}/runtime/lua/?.lua
|
--lpath=${WORKING_DIR}/runtime/lua/?.lua
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
-- Extends the upstream TAP handler, to display the log with suiteEnd.
|
||||||
|
|
||||||
|
local global_helpers = require('test.helpers')
|
||||||
|
|
||||||
|
return function(options)
|
||||||
|
local handler = require 'busted.outputHandlers.TAP'(options)
|
||||||
|
|
||||||
|
handler.suiteEnd = function()
|
||||||
|
io.write(global_helpers.read_nvim_log())
|
||||||
|
return handler.suiteEnd()
|
||||||
|
end
|
||||||
|
|
||||||
|
return handler
|
||||||
|
end
|
|
@ -1,6 +1,4 @@
|
||||||
local s = require 'say'
|
|
||||||
local pretty = require 'pl.pretty'
|
local pretty = require 'pl.pretty'
|
||||||
local term = require 'term'
|
|
||||||
local global_helpers = require('test.helpers')
|
local global_helpers = require('test.helpers')
|
||||||
|
|
||||||
local colors
|
local colors
|
||||||
|
@ -65,8 +63,6 @@ return function(options)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
c = nil
|
|
||||||
|
|
||||||
local fileCount = 0
|
local fileCount = 0
|
||||||
local fileTestCount = 0
|
local fileTestCount = 0
|
||||||
local testCount = 0
|
local testCount = 0
|
||||||
|
@ -76,7 +72,6 @@ return function(options)
|
||||||
local errorCount = 0
|
local errorCount = 0
|
||||||
|
|
||||||
local pendingDescription = function(pending)
|
local pendingDescription = function(pending)
|
||||||
local name = pending.name
|
|
||||||
local string = ''
|
local string = ''
|
||||||
|
|
||||||
if type(pending.message) == 'string' then
|
if type(pending.message) == 'string' then
|
||||||
|
@ -175,7 +170,7 @@ return function(options)
|
||||||
return nil, true
|
return nil, true
|
||||||
end
|
end
|
||||||
|
|
||||||
handler.suiteStart = function(suite, count, total, randomseed)
|
handler.suiteStart = function(_suite, count, total, randomseed)
|
||||||
if total > 1 then
|
if total > 1 then
|
||||||
io.write(repeatSuiteString:format(count, total))
|
io.write(repeatSuiteString:format(count, total))
|
||||||
end
|
end
|
||||||
|
@ -196,7 +191,7 @@ return function(options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
handler.suiteEnd = function(suite, count, total)
|
handler.suiteEnd = function(suite, _count, _total)
|
||||||
local elapsedTime_ms = getElapsedTime(suite)
|
local elapsedTime_ms = getElapsedTime(suite)
|
||||||
local tests = (testCount == 1 and 'test' or 'tests')
|
local tests = (testCount == 1 and 'test' or 'tests')
|
||||||
local files = (fileCount == 1 and 'file' or 'files')
|
local files = (fileCount == 1 and 'file' or 'files')
|
||||||
|
@ -225,14 +220,14 @@ return function(options)
|
||||||
return nil, true
|
return nil, true
|
||||||
end
|
end
|
||||||
|
|
||||||
handler.testStart = function(element, parent)
|
handler.testStart = function(element, _parent)
|
||||||
io.write(runString:format(handler.getFullName(element)))
|
io.write(runString:format(handler.getFullName(element)))
|
||||||
io.flush()
|
io.flush()
|
||||||
|
|
||||||
return nil, true
|
return nil, true
|
||||||
end
|
end
|
||||||
|
|
||||||
handler.testEnd = function(element, parent, status, debug)
|
handler.testEnd = function(element, _parent, status, _debug)
|
||||||
local elapsedTime_ms = getElapsedTime(element)
|
local elapsedTime_ms = getElapsedTime(element)
|
||||||
local string
|
local string
|
||||||
|
|
||||||
|
@ -263,7 +258,7 @@ return function(options)
|
||||||
return nil, true
|
return nil, true
|
||||||
end
|
end
|
||||||
|
|
||||||
handler.testFailure = function(element, parent, message, debug)
|
handler.testFailure = function(_element, _parent, _message, _debug)
|
||||||
io.write(failureString)
|
io.write(failureString)
|
||||||
io.flush()
|
io.flush()
|
||||||
|
|
||||||
|
@ -272,7 +267,7 @@ return function(options)
|
||||||
return nil, true
|
return nil, true
|
||||||
end
|
end
|
||||||
|
|
||||||
handler.testError = function(element, parent, message, debug)
|
handler.testError = function(_element, _parent, _message, _debug)
|
||||||
io.write(errorString)
|
io.write(errorString)
|
||||||
io.flush()
|
io.flush()
|
||||||
|
|
||||||
|
@ -281,7 +276,7 @@ return function(options)
|
||||||
return nil, true
|
return nil, true
|
||||||
end
|
end
|
||||||
|
|
||||||
handler.error = function(element, parent, message, debug)
|
handler.error = function(element, _parent, _message, _debug)
|
||||||
if element.descriptor ~= 'it' then
|
if element.descriptor ~= 'it' then
|
||||||
io.write(failureDescription(handler.errors[#handler.errors]))
|
io.write(failureDescription(handler.errors[#handler.errors]))
|
||||||
io.flush()
|
io.flush()
|
Loading…
Reference in New Issue