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
|
local app = require 'pl.app'
local io = io
local io_popen = io.popen
local math_random = math.random
return function(options)
local busted = require 'busted'
local handler = require 'busted.outputHandlers.base'()
local language = require('busted.languages.' .. options.language)
handler.suiteEnd = function()
local system = app.platform()
local sayer_pre, sayer_post
local messages
if system == 'Linux' then
sayer_pre = 'espeak -s 160 '
sayer_post = ' > /dev/null 2>&1'
elseif system and system:match('^Windows') then
sayer_pre = 'echo '
sayer_post = ' | ptts'
else
sayer_pre = 'say '
sayer_post = ''
end
if handler.failuresCount > 0 then
messages = language.failure_messages
else
messages = language.success_messages
end
io_popen(sayer_pre .. '"' .. messages[math_random(1, #messages)] .. '"' .. sayer_post)
return nil, true
end
busted.subscribe({ 'suite', 'end' }, handler.suiteEnd)
return handler
end
|