journal/runTests.sh

28 lines
661 B
Bash
Raw Normal View History

2024-11-07 08:58:38 +00:00
#!/usr/bin/env bash
SCRIPT_DIR="$(cd -- "$(dirname -- "$0")" && pwd)"
2024-11-07 21:45:22 +00:00
cd "${SCRIPT_DIR}/tool" || return
2024-11-10 08:13:25 +00:00
JQ=${JQ:-jq}
2024-11-10 13:00:43 +00:00
export JQ_FLAVOUR=${JQ_FLAVOUR:-"$(basename "${JQ}")"}
2024-11-07 21:45:22 +00:00
export JQ_TYPECHECKING=1
2024-11-10 13:00:43 +00:00
if [ ! -d "./lib/stubs/${JQ_FLAVOUR}" ]; then
STUBS_DIR="./lib/stubs/${JQ_FLAVOUR}"
2024-11-10 08:13:25 +00:00
else
STUBS_DIR="./lib/stubs/jq"
fi
2024-11-07 21:45:22 +00:00
runTests() {
echo "Running Tests with JQ=${JQ}"
2024-11-10 13:00:43 +00:00
export JQ_FLAVOUR=${JQ_FLAVOUR:-"$(basename "${JQ}")"}
2024-11-09 00:57:22 +00:00
${JQ} -nr \
2024-11-10 08:13:25 +00:00
-L "$(realpath .)" -L "$(realpath ./lib)" -L "$(realpath "${STUBS_DIR}")" \
2024-11-09 00:57:22 +00:00
"include \"tests\"; testsMain"
2024-11-07 21:45:22 +00:00
}
2024-11-07 08:58:38 +00:00
2024-11-07 21:45:22 +00:00
runTests
2024-11-07 11:39:39 +00:00
2024-11-07 21:45:22 +00:00
if command -v gojq 2>/dev/null >/dev/null; then
2024-11-10 13:00:43 +00:00
JQ=gojq JQ_FLAVOUR=gojq runTests
2024-11-07 21:45:22 +00:00
fi