mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-10 20:42:14 +00:00
I regret optimizing the structure for toml when this module was created, as it makes it difficult to define a regular schema. This commit introduces typed records for the queue helper data structure, and, unfortunately, a parsing layer to adapt between the toml data and the well-defined types. It also adjusts how lua tests are run; previously we'd co-opt the main flow of parsing by looking at an env var, but since the modules can now potentially require each other (especially the typing module) we need to de-couple from that, otherwise what happens is that we'd only ever run the typing module tests and exit. So we now have a script that imports all the modules and runs their respective `:test()` methods. refs: #211
42 lines
983 B
Bash
Executable File
42 lines
983 B
Bash
Executable File
#!/bin/bash
|
|
# This is a little helper script that is used to run unit
|
|
# tests that may be defined in .lua files.
|
|
# The "protocol" is that the module defines a mod:test() method
|
|
# that will be called to perform regression tests
|
|
CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-${PWD}/target}
|
|
|
|
for candidate in /opt/kumomta/sbin/kumod "${CARGO_TARGET_DIR}/release/kumod" "${CARGO_TARGET_DIR}/debug/kumod" ; do
|
|
if test -x "${candidate}" ; then
|
|
KUMOD="${candidate}"
|
|
break;
|
|
fi
|
|
done
|
|
|
|
if ! test -x "${KUMOD}" ; then
|
|
echo "Couldn't find kumod"
|
|
exit 1
|
|
fi
|
|
|
|
script=$(mktemp)
|
|
trap "rm -f -- '$script'" EXIT
|
|
cat >${script} <<-EOT
|
|
local kumo = require 'kumo'
|
|
package.path = 'assets/?.lua;' .. package.path
|
|
|
|
kumo.configure_accounting_db_path(os.tmpname())
|
|
|
|
local function test_module(name)
|
|
local mod = require(name)
|
|
mod:test()
|
|
end
|
|
|
|
test_module 'policy-extras.typing'
|
|
test_module 'policy-extras.queue'
|
|
test_module 'policy-extras.listener_domains'
|
|
|
|
os.exit(0)
|
|
EOT
|
|
|
|
${KUMOD} --policy $script
|
|
|