journal/runTests.sh
2024-11-10 13:00:43 +00:00

28 lines
661 B
Bash
Executable file

#!/usr/bin/env bash
SCRIPT_DIR="$(cd -- "$(dirname -- "$0")" && pwd)"
cd "${SCRIPT_DIR}/tool" || return
JQ=${JQ:-jq}
export JQ_FLAVOUR=${JQ_FLAVOUR:-"$(basename "${JQ}")"}
export JQ_TYPECHECKING=1
if [ ! -d "./lib/stubs/${JQ_FLAVOUR}" ]; then
STUBS_DIR="./lib/stubs/${JQ_FLAVOUR}"
else
STUBS_DIR="./lib/stubs/jq"
fi
runTests() {
echo "Running Tests with JQ=${JQ}"
export JQ_FLAVOUR=${JQ_FLAVOUR:-"$(basename "${JQ}")"}
${JQ} -nr \
-L "$(realpath .)" -L "$(realpath ./lib)" -L "$(realpath "${STUBS_DIR}")" \
"include \"tests\"; testsMain"
}
runTests
if command -v gojq 2>/dev/null >/dev/null; then
JQ=gojq JQ_FLAVOUR=gojq runTests
fi