_expected_tests=0
_executed_tests=0
_failed_tests=0
+_auto_timing="${TAP_AUTOTIME:-1}"
+_last_time=''
TODO=
-
+TIME_SCRIPT="$(realpath -e -- "$(dirname "${BASH_SOURCE[0]}")")/clock"
+print "${TIME_SCRIPT}"
usage(){
cat <<'USAGE'
OTHER:
diag MSG
+ autotime 0|1
EXAMPLE:
#!/bin/bash
_plan_set=1
_no_plan=1
+ _last_time=$("${TIME_SCRIPT}")
return 0
}
_skip_all=1
_plan_set=1
+ _last_time=$("${TIME_SCRIPT}")
_exit 0
return 0
_print_plan $tests
_expected_tests=$tests
_plan_set=1
+ _last_time=$("${TIME_SCRIPT}")
return $tests
}
fi
echo
+ _autotime
if (( result != 0 )) ; then
local file='tap-functions'
local func=
diag "$line"
done
ok ${PIPESTATUS[0]} "$command"
+ _autotime
}
for (( i=0 ; i<$n ; i++ )) ; do
_executed_tests=$(( _executed_tests + 1 ))
echo "ok $_executed_tests # skip: $reason"
+ _autotime
done
return 0
else
fi
}
+_autotime(){
+ local new_time
+ local duration
+
+ if [ "${_auto_timing}" -eq "1" ] ; then
+ new_time=$("${TIME_SCRIPT}")
+ duration=$(awk "BEGIN { printf(\"%f\n\", ($new_time - $_last_time)*1000) }")
+ echo " ---"
+ echo " duration_ms: ${duration}"
+ echo " ..."
+ fi
+ _last_time=$("${TIME_SCRIPT}")
+ return 0
+}
+
+
+autotime(){
+ local val=${1:?}
+
+ if [[ "${val}" != "0" ]] ; then
+ _auto_timing=1
+ else
+ _auto_timing=0;
+ fi
+ return 0
+}
diag(){
local msg=${1:?}