blob: b46350ec80baac03f2e8d6a5f89be9c081cb0ec0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
local pretty = require 'pl.pretty'
return function(options, busted)
local handler = require 'busted.outputHandlers.base'(busted)
handler.suiteEnd = function()
local total = handler.successesCount + handler.errorsCount + handler.failuresCount
print('1..' .. total)
local success = 'ok %u - %s'
local failure = 'not ' .. success
local counter = 0
for i,t in pairs(handler.successes) do
counter = counter + 1
print(success:format(counter, t.name))
end
local showFailure = function(t)
counter = counter + 1
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)
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
for i,t in pairs(handler.errors) do
showFailure(t)
end
for i,t in pairs(handler.failures) do
showFailure(t)
end
return nil, true
end
busted.subscribe({ 'suite', 'end' }, handler.suiteEnd)
return handler
end
|