Mon, 10 Sep 2018 13:52:35 +0100
Revamp console output to be driven by log_data()
local pretty = require "scansion.pretty".new({}); local function lines(l) return table.concat(l, "\n"); end local handlers = { ["script"] = function (data) return "TEST: "..(data.title or data.filename); end; ["test-passed"] = function () return "PASS"; end; ["test-failed"] = function (data) local error_text; if data.error and data.error.type == "unexpected-stanza" then error_text = "Received unexpected stanza:\n\n"..pretty(data.error.data.stanza, 4); if data.error.data.expected then error_text = error_text.."\n\nExpected:\n\n"..pretty(data.error.data.expected, 4); end else error_text = tostring(data.error); end return "FAIL: "..error_text end; ["test-error"] = function (data) return "ERROR: "..tostring(data.error); end; ["action"] = function (data) local action = data.action; local obj_type = data.object_type; local l = {}; if data.annotation then table.insert(l, action.annotation); end table.insert(l, data.object.." "..action); if data.extra and obj_type == "client" and (action == "sends" or action == "receives") then table.insert(l, "\n"..pretty(lines(data.extra), 4).."\n"); end return lines(l); end; }; return { handlers = handlers; }