Files
ale/test/script/run-lua-tests
w0rp bd591d47f2 Add basic Lua ALE functions and test coverage
Ensure that basic ALE functions `ale.var`, `ale.escape`, and `ale.env`
are available in Lua. Cover all Lua code so far with busted tests,
fixing bugs where ALE variables can be set with Boolean values instead
of numbers. Document all functionality so far.
2025-03-27 12:40:11 +00:00

58 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
set -u
docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin/test/lua "$DOCKER_RUN_IMAGE")
quiet=0
while [ $# -ne 0 ]; do
case $1 in
-q)
quiet=1
shift
;;
--)
shift
break
;;
-?*)
echo "Invalid argument: $1" 1>&2
exit 1
;;
*)
break
;;
esac
done
function filter-busted-output() {
local hit_failure_line=0
while read -r; do
if ((quiet)); then
# If we're using the quiet flag, the filter out lines until we hit
# the first line with "Failure" and then print the rest.
if ((hit_failure_line)); then
echo "$REPLY"
elif [[ "$REPLY" = *'Failure'* ]]; then
hit_failure_line=1
echo "$REPLY"
fi
else
echo "$REPLY"
fi
done
}
exit_code=0
set -o pipefail
"$DOCKER" run -a stdout "${docker_flags[@]}" /usr/bin/busted-5.1 \
-m '../../lua/?.lua;../../lua/?/init.lua' . \
--output utfTerminal | filter-busted-output || exit_code=$?
set +o pipefail
exit "$exit_code"