aboutsummaryrefslogtreecommitdiff
path: root/test/busted/outputHandlers/nvim.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/busted/outputHandlers/nvim.lua')
-rw-r--r--test/busted/outputHandlers/nvim.lua95
1 files changed, 66 insertions, 29 deletions
diff --git a/test/busted/outputHandlers/nvim.lua b/test/busted/outputHandlers/nvim.lua
index 4bfa21fe49..28855df261 100644
--- a/test/busted/outputHandlers/nvim.lua
+++ b/test/busted/outputHandlers/nvim.lua
@@ -1,12 +1,21 @@
local pretty = require 'pl.pretty'
local global_helpers = require('test.helpers')
-local colors = setmetatable({}, {__index = function() return function(s) return s == nil and '' or tostring(s) end end})
+local colors = setmetatable({}, {
+ __index = function()
+ return function(s)
+ return s == nil and '' or tostring(s)
+ end
+ end,
+})
local enable_colors = true
-if os.getenv "TEST_COLORS" then
- local test_colors = os.getenv("TEST_COLORS"):lower()
- local disable_colors = test_colors == 'false' or test_colors == '0' or test_colors == 'no' or test_colors == 'off'
+if os.getenv 'TEST_COLORS' then
+ local test_colors = os.getenv('TEST_COLORS'):lower()
+ local disable_colors = test_colors == 'false'
+ or test_colors == '0'
+ or test_colors == 'no'
+ or test_colors == 'off'
enable_colors = not disable_colors
end
if enable_colors then
@@ -18,49 +27,73 @@ return function(options)
local handler = require 'busted.outputHandlers.base'()
local c = {
- succ = function(s) return colors.bright(colors.green(s)) end,
- skip = function(s) return colors.bright(colors.yellow(s)) end,
- fail = function(s) return colors.bright(colors.magenta(s)) end,
- errr = function(s) return colors.bright(colors.red(s)) end,
+ succ = function(s)
+ return colors.bright(colors.green(s))
+ end,
+ skip = function(s)
+ return colors.bright(colors.yellow(s))
+ end,
+ fail = function(s)
+ return colors.bright(colors.magenta(s))
+ end,
+ errr = function(s)
+ return colors.bright(colors.red(s))
+ end,
test = tostring,
file = colors.cyan,
time = colors.dim,
note = colors.yellow,
- sect = function(s) return colors.green(colors.dim(s)) end,
+ sect = function(s)
+ return colors.green(colors.dim(s))
+ end,
nmbr = colors.bright,
}
local repeatSuiteString = '\nRepeating all tests (run %d of %d) . . .\n\n'
- local randomizeString = c.note('Note: Randomizing test order with a seed of %d.\n')
- local globalSetup = c.sect('--------') .. ' Global test environment setup.\n'
- local fileStartString = c.sect('--------') .. ' Running tests from ' .. c.file('%s') .. '\n'
- local runString = c.sect('RUN ') .. ' ' .. c.test('%s') .. ': '
- local successString = c.succ('OK') .. '\n'
- local skippedString = c.skip('SKIP') .. '\n'
- local failureString = c.fail('FAIL') .. '\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 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 successStatus = c.succ('PASSED ') .. ' ' .. c.nmbr('%d') .. ' %s.\n'
- local timeString = c.time('%.2f ms')
+ local randomizeString = c.note('Note: Randomizing test order with a seed of %d.\n')
+ local globalSetup = c.sect('--------') .. ' Global test environment setup.\n'
+ local fileStartString = c.sect('--------') .. ' Running tests from ' .. c.file('%s') .. '\n'
+ local runString = c.sect('RUN ') .. ' ' .. c.test('%s') .. ': '
+ local successString = c.succ('OK') .. '\n'
+ local skippedString = c.skip('SKIP') .. '\n'
+ local failureString = c.fail('FAIL') .. '\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 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 successStatus = c.succ('PASSED ') .. ' ' .. c.nmbr('%d') .. ' %s.\n'
+ local timeString = c.time('%.2f ms')
local summaryStrings = {
skipped = {
header = c.skip('SKIPPED ') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n',
- test = c.skip('SKIPPED ') .. ' %s\n',
+ test = c.skip('SKIPPED ') .. ' %s\n',
footer = ' ' .. c.nmbr('%d') .. ' SKIPPED %s\n',
},
failure = {
header = c.fail('FAILED ') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n',
- test = c.fail('FAILED ') .. ' %s\n',
+ test = c.fail('FAILED ') .. ' %s\n',
footer = ' ' .. c.nmbr('%d') .. ' FAILED %s\n',
},
error = {
header = c.errr('ERROR ') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n',
- test = c.errr('ERROR ') .. ' %s\n',
+ test = c.errr('ERROR ') .. ' %s\n',
footer = ' ' .. c.nmbr('%d') .. ' %s\n',
},
}
@@ -107,8 +140,10 @@ return function(options)
local getFileLine = function(element)
local fileline = ''
if element.trace or element.trace.short_src then
- fileline = colors.cyan(element.trace.short_src) .. ' @ ' ..
- colors.cyan(element.trace.currentline) .. ': '
+ fileline = colors.cyan(element.trace.short_src)
+ .. ' @ '
+ .. colors.cyan(element.trace.currentline)
+ .. ': '
end
return fileline
end
@@ -219,7 +254,9 @@ return function(options)
local elapsedTime_ms = getElapsedTime(file)
local tests = (fileTestCount == 1 and 'test' or 'tests')
fileCount = fileCount + 1
- io.write(fileEndString:format(fileTestCount, tests, vim.fs.normalize(file.name), elapsedTime_ms))
+ io.write(
+ fileEndString:format(fileTestCount, tests, vim.fs.normalize(file.name), elapsedTime_ms)
+ )
io.flush()
return nil, true
end
@@ -256,7 +293,7 @@ return function(options)
errorCount = errorCount + 1
string = errorString .. failureDescription(handler.errors[#handler.errors])
else
- string = "unexpected test status! ("..status..")"
+ string = 'unexpected test status! (' .. status .. ')'
end
write_status(element, string)