123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- #
- # Variables to hold exit status semantic
- #
- TF_ES_OK=0
- TF_ES_FAIL=1
- TF_ES_BAILOUT=2
- TF_ES_ERROR=3
- TF_ES_PANIC=4
-
- #
- # Option to turn on/off verbosity
- #
- TF_VERBOSE=${TF_VERBOSE:-true}
-
- #
- # Option to turn on/off debug mode
- #
- TF_DEBUG=${TF_DEBUG:-false}
-
- #
- # Regex to filter test names to run
- #
- TF_FILTER_TEST="${TF_FILTER_TEST:-.*}"
-
- #
- # Regex to filter subtest names to run
- #
- TF_FILTER_SUBTEST="${TF_FILTER_SUBTEST:-.*}"
-
- #
- # Enable color?
- #
- TF_COLOR=${TF_COLOR:-true}
-
- #
- # Color definition variables
- #
- TF_COLOR_BLACK="\033[0;30m"
- TF_COLOR_RED="\033[0;31m"
- TF_COLOR_GREEN="\033[0;32m"
- TF_COLOR_YELLOW="\033[0;33m"
- TF_COLOR_BLUE="\033[0;34m"
- TF_COLOR_MAGENTA="\033[0;35m"
- TF_COLOR_CYAN="\033[0;36m"
- TF_COLOR_WHITE="\033[0;37m"
- TF_COLOR_LBLACK="\033[1;30m"
- TF_COLOR_LRED="\033[1;31m"
- TF_COLOR_LGREEN="\033[1;32m"
- TF_COLOR_LYELLOW="\033[1;33m"
- TF_COLOR_LBLUE="\033[1;34m"
- TF_COLOR_LMAGENTA="\033[1;35m"
- TF_COLOR_LCYAN="\033[1;36m"
- TF_COLOR_LWHITE="\033[1;37m"
- TF_COLOR_NONE="\033[1;0m"
-
-
- tf_exit_ok() {
- #
- # Exit with OK status
- #
- exit $TF_ES_OK
- }
-
- tf_exit_fail() {
- #
- # Warn $1 and exit with status FAIL
- #
- tf_warn "$@"
- exit $TF_ES_FAIL
- }
-
- tf_exit_bailout() {
- #
- # Warn $1 and exit with status FAIL
- #
- tf_warn "$@"
- exit $TF_ES_BAILOUT
- }
-
- tf_exit_error() {
- #
- # Warn $1 and exit with status FAIL
- #
- tf_warn "$@"
- exit $TF_ES_ERROR
- }
-
- tf_exit_panic() {
- #
- # Warn $1 and exit with status FAIL
- #
- tf_warn "$@"
- exit $TF_ES_PANIC
- }
-
- tf_debug() {
- #
- # Emit debug message
- #
- $TF_DEBUG || return 0
- local msg
- for msg in "$@";
- do
- $TF_COLOR && echo -ne "$TF_COLOR_CYAN" >&2
- echo "||| $1" >&2;
- $TF_COLOR && echo -ne "$TF_COLOR_NONE" >&2
- done
- }
-
- tf_think() {
- #
- # Emit status/progress message
- #
- $TF_VERBOSE || return 0
- local msg
- for msg in "$@";
- do
- $TF_COLOR && echo -ne "$TF_COLOR_LBLACK" >&2
- echo "$pfx$1$sfx" >&2;
- $TF_COLOR && echo -ne "$TF_COLOR_NONE" >&2
- done
- }
-
- tf_warn() {
- #
- # Emit warning
- #
- local msg
- for msg in "$@";
- do
- $TF_COLOR && echo -ne "$TF_COLOR_LRED" >&2
- echo "$1" >&2;
- $TF_COLOR && echo -ne "$TF_COLOR_NONE" >&2
- done
- }
|