123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- tap_count_=0
- tap_pass_count_=0
- tap_skip_count_=0
- tap_fail_count_=0
- tap_xfail_count_=0
- tap_xpass_count_=0
- not () { ! "$@"; }
- plan_ ()
- {
- if test $# -eq 0; then
- bailout_ "plan_: missing argument"
- elif test $# -ge 2; then
- bailout_ "plan_: too many arguments"
- elif test x"$planned_" != x"none" && test x"$planned_" != x"later"; then
- bailout_ "plan_: called to many times"
- elif test x"$1" = x"unknown" || test x"$1" = x"later"; then
-
- planned_=later
- return 0
- elif test x"$1" = x"lazy" || test x"$1" = x"now"; then
- planned_=$tap_count_
- elif test $1 -ge 0; then
- planned_=$1
- else
- bailout_ "plan_: invalid argument '$1'"
- fi
- echo "1..$planned_"
- }
- planned_=none
- diag_ ()
- {
- test $# -eq 0 || echo "$diag_string_ $*"
- }
- diag_string_="#"
- warn_ ()
- {
- case $# in
- 0) diag_ "WARNING: (unknown warning)";;
- *) diag_ "WARNING: $*";;
- esac
- }
- result_ ()
- {
- set +x
- test $# -gt 0 || bailout_ "result_: missing argument"
- tap_result_=$1; shift
- case $tap_result_ in
- "ok"|"not ok") ;;
- *) bailout_ "result_: invalid result '$tap_result'" ;;
- esac
- tap_directive_= tap_reason_=
- while test $# -gt 0; do
- case $1 in
- -D|--directive) tap_directive_=$2; shift;;
- -r|--reason) tap_reason_=$2; shift;;
- --) shift; break;;
- -*) bailout_ "result_: invalid option '$1'";;
- *) break;;
- esac
- shift
- done
- case $tap_directive_ in
- ""|TODO|SKIP) ;;
- *) bailout_ "result_: invalid directive '$directive_'" ;;
- esac
- tap_count_=$(($tap_count_ + 1))
- case $tap_result_,$tap_directive_ in
- ok,)
- tap_pass_count_=$(($tap_pass_count_ + 1)) ;;
- not\ ok,TODO)
- tap_xfail_count_=$(($tap_xfail_count_ + 1)) ;;
- not\ ok,*)
- tap_fail_count_=$(($tap_fail_count_ + 1)) ;;
- ok,TODO)
- tap_xpass_count_=$(($tap_xpass_count_ + 1)) ;;
- ok,SKIP)
- tap_skip_count_=$(($tap_skip_count_ + 1)) ;;
- *)
- bailout_ "internal error in 'result_'" ;;
- esac
- tap_text_="$tap_result_ $tap_count_"
- if test x"$*" != x; then
- tap_text_="$tap_text_ - $*"
- fi
- if test x"$tap_directive_" != x; then
- tap_text_="$tap_text_ # $tap_directive_"${tap_reason_:+" $tap_reason_"}
- fi
- printf '%s\n' "$tap_text_"
- set -x
- }
- ok_ () { result_ 'ok' ${1+"$@"}; }
- not_ok_ () { result_ 'not ok' ${1+"$@"}; }
- skip_ () { result_ 'ok' -D SKIP ${1+"$@"}; }
- skip_row_ ()
- {
- skip_count_=$1; shift
- for i_ in $(seq_ $skip_count_); do skip_ ${1+"$@"}; done
- }
- skip_all_ ()
- {
- echo "1..0 # SKIP" ${1+"$@"}
- planned_=0
- exit 0
- }
- bailout_ ()
- {
- echo 'Bail out!' ${1+"$@"}
- exit 99
- }
- fatal_ ()
- {
- bailout_ ${1+"$@"}
- }
- framework_failure_ ()
- {
- bailout_ "set-up failure"${1+": $*"}
- }
- command_ok_ ()
- {
- tap_directive_= tap_reason_=
- test $# -gt 0 || bailout_ "command_ok_: missing argument"
- tap_description_=$1; shift
- while test $# -gt 0; do
- case $1 in
- -D|--directive) tap_directive_=$2; shift;;
- -r|--reason) tap_reason_=$2; shift;;
- --) shift; break;;
- -*) bailout_ "command_ok_: invalid option '$1'";;
- *) break;;
- esac
- shift
- done
- tap_result_="ok"; "$@" || tap_result_="not ok"
- result_ "$tap_result_" -D "$tap_directive_" -r "$tap_reason_" \
- -- "$tap_description_"
- }
- :
|