diff --git a/.luacheckrc b/.luacheckrc index f350ff014a..b945835bba 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -11,6 +11,7 @@ cache = true ignore = { "631", -- max_line_length + "212/_.*", -- unused argument, for vars with "_" prefix } -- Global objects defined by the C code diff --git a/busted/outputHandlers/TAP.lua b/busted/outputHandlers/TAP.lua deleted file mode 100644 index 612e633576..0000000000 --- a/busted/outputHandlers/TAP.lua +++ /dev/null @@ -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 diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake index f5b3f01778..5406a07fc8 100644 --- a/cmake/RunTests.cmake +++ b/cmake/RunTests.cmake @@ -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. 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 --lpath=${BUILD_DIR}/?.lua --lpath=${WORKING_DIR}/runtime/lua/?.lua diff --git a/test/busted/outputHandlers/TAP.lua b/test/busted/outputHandlers/TAP.lua new file mode 100644 index 0000000000..3dd171dc1b --- /dev/null +++ b/test/busted/outputHandlers/TAP.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 diff --git a/busted/outputHandlers/nvim.lua b/test/busted/outputHandlers/nvim.lua similarity index 94% rename from busted/outputHandlers/nvim.lua rename to test/busted/outputHandlers/nvim.lua index d137300a7e..1b500fc999 100644 --- a/busted/outputHandlers/nvim.lua +++ b/test/busted/outputHandlers/nvim.lua @@ -1,6 +1,4 @@ -local s = require 'say' local pretty = require 'pl.pretty' -local term = require 'term' local global_helpers = require('test.helpers') local colors @@ -65,8 +63,6 @@ return function(options) }, } - c = nil - local fileCount = 0 local fileTestCount = 0 local testCount = 0 @@ -76,7 +72,6 @@ return function(options) local errorCount = 0 local pendingDescription = function(pending) - local name = pending.name local string = '' if type(pending.message) == 'string' then @@ -175,7 +170,7 @@ return function(options) return nil, true end - handler.suiteStart = function(suite, count, total, randomseed) + handler.suiteStart = function(_suite, count, total, randomseed) if total > 1 then io.write(repeatSuiteString:format(count, total)) end @@ -196,7 +191,7 @@ return function(options) end end - handler.suiteEnd = function(suite, count, total) + handler.suiteEnd = function(suite, _count, _total) local elapsedTime_ms = getElapsedTime(suite) local tests = (testCount == 1 and 'test' or 'tests') local files = (fileCount == 1 and 'file' or 'files') @@ -225,14 +220,14 @@ return function(options) return nil, true end - handler.testStart = function(element, parent) + handler.testStart = function(element, _parent) io.write(runString:format(handler.getFullName(element))) io.flush() return nil, true end - handler.testEnd = function(element, parent, status, debug) + handler.testEnd = function(element, _parent, status, _debug) local elapsedTime_ms = getElapsedTime(element) local string @@ -263,7 +258,7 @@ return function(options) return nil, true end - handler.testFailure = function(element, parent, message, debug) + handler.testFailure = function(_element, _parent, _message, _debug) io.write(failureString) io.flush() @@ -272,7 +267,7 @@ return function(options) return nil, true end - handler.testError = function(element, parent, message, debug) + handler.testError = function(_element, _parent, _message, _debug) io.write(errorString) io.flush() @@ -281,7 +276,7 @@ return function(options) return nil, true end - handler.error = function(element, parent, message, debug) + handler.error = function(element, _parent, _message, _debug) if element.descriptor ~= 'it' then io.write(failureDescription(handler.errors[#handler.errors])) io.flush()