Files
kumomta/assets/run-lua-test
T
Wez Furlong 7e6ca34e2d new: kumo.fs lua module
The read_dir and glob functions have been logically moved into that new
namespace, leaving deprecated versions of them in the `kumo` module.

A new `kumo.fs.open` function that works similarly to `io.open` is
provided.  This function cooperates with the kumo async io scheduler
and won't block it if the filesystem is under pressure.

It returns file handles that are simlar to the builtin lua file handle
objects, but do not support formatting or parsing of writes or reads
respectively: the calling code is responsible for that.  The rationale
for this difference is that is that lua's semantics for those functions
are frankly a bit weird and are hard to replicate precisely.
2025-07-23 16:51:06 +01:00

48 lines
1.2 KiB
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 "${CARGO_TARGET_DIR}/debug/kumod" "${CARGO_TARGET_DIR}/release/kumod" /opt/kumomta/sbin/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.on('main', function()
local function test_module(name)
local mod = require(name)
mod:test()
end
test_module 'policy-extras.listener_domains'
test_module 'policy-extras.queue'
test_module 'policy-extras.sources'
test_module 'policy-extras.typing'
dofile "crates/mod-memoize/test.lua"
dofile "crates/mod-dns-resolver/test-dns-ptr.lua"
dofile "crates/mod-mpsc/test.lua"
dofile "crates/mod-filesystem/test.lua"
end)
EOT
${KUMOD} --user `id -un` --policy $script --script