8
# Test counts. Neither skips or errors are necessarily fatal.
33
function start-test() {
34
readonly DATADIR=$(mktemp -d --tmpdir "${TEST_NAME}.XXXXXXX")
35
info "Executing ${TEST_NAME} with results in $DATADIR: $1"
37
trap trapped-teardown EXIT TERM INT
41
# Empty, override in actual test as needed
47
info "Completed test $TEST_NAME"
54
# Empty, override in actual test as needed
59
function test-teardown() {
62
if [[ "$ERRORS" -gt 0 ]] ; then
64
elif [[ "$SKIPS" -gt 0 ]] ; then
72
if [ -n "$DATADIR" ] ; then
73
if [ -f $DATADIR/passed ]; then
74
info "Passed test results for ${TEST_NAME} in ${DATADIR}, skips=${SKIPS}"
77
info "Failed test results for ${TEST_NAME} in ${DATADIR}, errors=${ERRORS}, skips=${SKIPS}"
78
if [ -f $DATADIR/wget.log ] ; then
90
# Unpack the caller info to get some useful diagnostics for
91
# tracing any assertion issues
92
local data=( $(caller 1) )
93
local lineno=${data[0]}
94
local function_name=${data[1]}
95
local script_name=${data[2]}
96
echo "function $function_name at line $lineno ($script_name)"
99
function trapped-teardown() {
101
error "Untrapped error in $(diagnose)"
106
# The assert function takes two args, such as:
107
# assert "what we are asserting" "non empty result passes"
108
# If the second arg is empty or undefined, the assertion fails
109
if [[ "$#" -lt 2 || -z "$2" ]] ; then
110
error "$1, assertion failed in $(diagnose)"