2015-02-28 01:11:56 +01:00
|
|
|
-- Run all unit tests in 'unit' directory
|
|
|
|
|
|
|
|
local telescope = require "telescope"
|
2018-09-19 15:51:01 +02:00
|
|
|
require "rspamd_assertions"
|
2018-09-25 16:22:28 +02:00
|
|
|
local loaded, luacov = pcall(require, 'luacov.runner')
|
|
|
|
if not loaded then
|
|
|
|
luacov = {
|
|
|
|
init = function() end,
|
|
|
|
shutdown = function() end,
|
|
|
|
run_report = function() end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
luacov.init()
|
2015-02-28 01:11:56 +01:00
|
|
|
|
|
|
|
local contexts = {}
|
|
|
|
|
|
|
|
for _,t in ipairs(tests_list) do
|
|
|
|
telescope.load_contexts(t, contexts)
|
|
|
|
end
|
2018-09-20 12:26:36 +02:00
|
|
|
local function test_filter(test)
|
|
|
|
return test.name:match(test_pattern)
|
|
|
|
end
|
|
|
|
if not test_pattern then
|
|
|
|
test_filter = function(_) return true end
|
|
|
|
end
|
2018-09-25 16:22:28 +02:00
|
|
|
|
2015-02-28 01:11:56 +01:00
|
|
|
local buffer = {}
|
2018-09-20 12:26:36 +02:00
|
|
|
local results = telescope.run(contexts, callbacks, test_filter)
|
2015-02-28 01:11:56 +01:00
|
|
|
local summary, data = telescope.summary_report(contexts, results)
|
2015-02-28 01:24:13 +01:00
|
|
|
|
2015-02-28 01:11:56 +01:00
|
|
|
table.insert(buffer, telescope.test_report(contexts, results))
|
2015-02-28 01:24:13 +01:00
|
|
|
table.insert(buffer, summary)
|
|
|
|
|
|
|
|
local report = telescope.error_report(contexts, results)
|
|
|
|
|
|
|
|
if report then
|
|
|
|
table.insert(buffer, "")
|
|
|
|
table.insert(buffer, report)
|
|
|
|
end
|
2015-02-28 01:11:56 +01:00
|
|
|
|
|
|
|
if #buffer > 0 then print(table.concat(buffer, "\n")) end
|
|
|
|
|
|
|
|
for _, v in pairs(results) do
|
|
|
|
if v.status_code == telescope.status_codes.err or
|
|
|
|
v.status_code == telescope.status_codes.fail then
|
|
|
|
os.exit(1)
|
|
|
|
end
|
2018-09-25 16:22:28 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
luacov:shutdown()
|
|
|
|
luacov:run_report()
|