8
# Test counts. Neither skips or errors are necessarily fatal.
33
function start-test() {
34
if [ -z "$JITSU_LOGDIR" ] ; then
35
readonly DATADIR=$(mktemp -d --tmpdir "${TEST_NAME}.XXXXXXX")
37
readonly DATADIR=$JITSU_LOGDIR
39
info "Executing ${TEST_NAME} with results in $DATADIR: $1"
41
trap trapped-teardown EXIT TERM INT
45
# Empty, override in actual test as needed
51
info "Completed test $TEST_NAME"
58
# Empty, override in actual test as needed
63
function test-teardown() {
66
if [[ "$ERRORS" -gt 0 ]] ; then
68
elif [[ "$SKIPS" -gt 0 ]] ; then
76
if [ -n "$DATADIR" ] ; then
77
if [ -f $DATADIR/passed ]; then
78
info "Passed test results for ${TEST_NAME} in ${DATADIR}, skips=${SKIPS}"
81
info "Failed test results for ${TEST_NAME} in ${DATADIR}, errors=${ERRORS}, skips=${SKIPS}"
82
if [ -f $DATADIR/wget.log ] ; then
94
# Unpack the caller info to get some useful diagnostics for
95
# tracing any assertion issues
96
local data=( $(caller 1) )
97
local lineno=${data[0]}
98
local function_name=${data[1]}
99
local script_name=${data[2]}
100
echo "function $function_name at line $lineno ($script_name)"
103
function trapped-teardown() {
105
error "Untrapped error in $(diagnose)"
110
# The assert function takes two args, such as:
111
# assert "what we are asserting" "non empty result passes"
112
# If the second arg is empty or undefined, the assertion fails
113
if [[ "$#" -lt 2 || -z "$2" ]] ; then
114
error "$1, assertion failed in $(diagnose)"