mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
tests: Skip dumping elapsed times when not available
Should provide some compatibility with old busted. And also removes duplicate parts from successString and skippedString, making them more like failureString and errorString which do not have times for technical reasons (busted for some reason did not yet compute duration before running the relevant handlers).
This commit is contained in:
parent
bc61058dd8
commit
accc7a0b6c
@ -34,14 +34,15 @@ return function(options)
|
|||||||
local globalSetup = c.sect('[----------]') .. ' Global test environment setup.\n'
|
local globalSetup = c.sect('[----------]') .. ' Global test environment setup.\n'
|
||||||
local fileStartString = c.sect('[----------]') .. ' Running tests from ' .. c.file('%s') .. '\n'
|
local fileStartString = c.sect('[----------]') .. ' Running tests from ' .. c.file('%s') .. '\n'
|
||||||
local runString = c.sect('[ RUN ]') .. ' ' .. c.test('%s') .. ': '
|
local runString = c.sect('[ RUN ]') .. ' ' .. c.test('%s') .. ': '
|
||||||
local successString = c.time('%.2f ms') .. ' ' .. c.succ('OK') .. '\n'
|
local successString = c.succ('OK') .. '\n'
|
||||||
local skippedString = c.time('%.2f ms') .. ' ' .. c.skip('SKIP') .. '\n'
|
local skippedString = c.skip('SKIP') .. '\n'
|
||||||
local failureString = c.fail('FAIL') .. '\n'
|
local failureString = c.fail('FAIL') .. '\n'
|
||||||
local errorString = c.errr('ERR') .. '\n'
|
local errorString = c.errr('ERR') .. '\n'
|
||||||
local fileEndString = c.sect('[----------]') .. ' '.. c.nmbr('%d') .. ' %s from ' .. c.file('%s') .. ' ' .. c.time('(%.2f ms total)') .. '\n\n'
|
local fileEndString = c.sect('[----------]') .. ' '.. c.nmbr('%d') .. ' %s from ' .. c.file('%s') .. ' ' .. c.time('(%.2f ms total)') .. '\n\n'
|
||||||
local globalTeardown = c.sect('[----------]') .. ' Global test environment teardown.\n'
|
local globalTeardown = c.sect('[----------]') .. ' Global test environment teardown.\n'
|
||||||
local suiteEndString = c.sect('[==========]') .. ' ' .. c.nmbr('%d') .. ' %s from ' .. c.nmbr('%d') .. ' test %s ran. ' .. c.time('(%.2f ms total)') .. '\n'
|
local suiteEndString = c.sect('[==========]') .. ' ' .. c.nmbr('%d') .. ' %s from ' .. c.nmbr('%d') .. ' test %s ran. ' .. c.time('(%.2f ms total)') .. '\n'
|
||||||
local successStatus = c.succ('[ PASSED ]') .. ' ' .. c.nmbr('%d') .. ' %s.\n'
|
local successStatus = c.succ('[ PASSED ]') .. ' ' .. c.nmbr('%d') .. ' %s.\n'
|
||||||
|
local timeString = c.time('%.2f ms')
|
||||||
|
|
||||||
local summaryStrings = {
|
local summaryStrings = {
|
||||||
skipped = {
|
skipped = {
|
||||||
@ -186,8 +187,16 @@ return function(options)
|
|||||||
return nil, true
|
return nil, true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getElapsedTime(tbl)
|
||||||
|
if tbl.duration then
|
||||||
|
return tbl.duration * 1000
|
||||||
|
else
|
||||||
|
return tonumber('nan')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
handler.suiteEnd = function(suite, count, total)
|
handler.suiteEnd = function(suite, count, total)
|
||||||
local elapsedTime_ms = suite.duration * 1000
|
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')
|
||||||
io.write(globalTeardown)
|
io.write(globalTeardown)
|
||||||
@ -206,7 +215,7 @@ return function(options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
handler.fileEnd = function(file)
|
handler.fileEnd = function(file)
|
||||||
local elapsedTime_ms = file.duration * 1000
|
local elapsedTime_ms = getElapsedTime(file)
|
||||||
local tests = (fileTestCount == 1 and 'test' or 'tests')
|
local tests = (fileTestCount == 1 and 'test' or 'tests')
|
||||||
fileCount = fileCount + 1
|
fileCount = fileCount + 1
|
||||||
io.write(fileEndString:format(fileTestCount, tests, file.name, elapsedTime_ms))
|
io.write(fileEndString:format(fileTestCount, tests, file.name, elapsedTime_ms))
|
||||||
@ -222,7 +231,7 @@ return function(options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
handler.testEnd = function(element, parent, status, debug)
|
handler.testEnd = function(element, parent, status, debug)
|
||||||
local elapsedTime_ms = element.duration * 1000
|
local elapsedTime_ms = getElapsedTime(element)
|
||||||
local string
|
local string
|
||||||
|
|
||||||
fileTestCount = fileTestCount + 1
|
fileTestCount = fileTestCount + 1
|
||||||
@ -242,7 +251,10 @@ return function(options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if string ~= nil then
|
if string ~= nil then
|
||||||
io.write(string:format(elapsedTime_ms))
|
if elapsedTime_ms == elapsedTime_ms then
|
||||||
|
string = timeString:format(elapsedTime_ms) .. ' ' .. string
|
||||||
|
end
|
||||||
|
io.write(string)
|
||||||
io.flush()
|
io.flush()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user