From 16e207783382ce04cb6253915941afa4ec68e34a Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sat, 2 Jan 2021 13:45:09 +0100 Subject: [PATCH] tests: start echo printf conversion --- test/ALL-tests.inc.sh | 69 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/test/ALL-tests.inc.sh b/test/ALL-tests.inc.sh index fb7e88b..d0f0fbc 100644 --- a/test/ALL-tests.inc.sh +++ b/test/ALL-tests.inc.sh @@ -1,5 +1,66 @@ #!/usr/bin/env bash -#### $$VERSION$$ v1.21-dev-45-gddb2785 +#=============================================================================== +# +# FILE: ALL-tests.inc.sh +# +# USAGE: source ALL-tests.inc.sh +# +# DESCRIPTION: must be included from all tests, +# setup bashbot test environment and common test functions +# +# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/ +# AUTHOR: KayM (gnadelwartz), kay@rrr.de +# +#### $$VERSION$$ v1.21-pre-32-gd70a461 +#=============================================================================== + +############ +# set where your bashbot lives +export BASHBOT_HOME BASHBOT_ETC BASHBOT_VAR FILE_REGEX + +# default: one dir up +BASHBOT_HOME="$(cd "${BASH_SOURCE[0]%/*}" >/dev/null 2>&1 && pwd)/../" +[ "${BASHBOT_HOME}" = "/../" ] && BASHBOT_HOME="../" + +# set you own BASHBOT_HOME if different, e.g. +# BASHBOT_HOME="/usr/local/telegram-bot-bash" +BASHBOT_VAR="${BASHBOT_HOME}" +BASHBOT_ETC="${BASHBOT_HOME}" + +##### +# if files are not readable, eviroment is wrong or bashbot is not initialized + +# source bashbot +if [ ! -r "${BASHBOT_HOME}/bashbot.sh" ]; then + echo "Bashbot.sh not found in \"${BASHBOT_HOME}\"" + exit 4 +fi + +# check for botconfig.jssh readable +if [ ! -r "${BASHBOT_ETC}/botconfig.jssh" ]; then + echo "Bashbot config file in \"${BASHBOT_ETC}\" does not exist or is not readable." + exit 3 +fi +# check for count.jssh readable +if [ ! -r "${BASHBOT_VAR}/count.jssh" ]; then + echo "Bashbot count file in \"${BASHBOT_VAR}\" does not exist or is not readable. Did you run bashbot init?" + exit 3 +fi + +# shellcheck disable=SC1090 +source "${BASHBOT_HOME}/bashbot.sh" source "$1" + +# overwrite bot FILE regex to BASHBOT_VAR +# change this to the location you want to allow file uploads from +UPLOADDIR="${BASHBOT_VAR%/bin*}" +FILE_REGEX="${UPLOADDIR}/.*" + +# get and check ADMIN and NAME +BOT_ADMIN="$(getConfigKey "botadmin")" +BOT_NAME="$(getConfigKey "botname")" +[[ -z "${BOT_ADMIN}" || "${BOT_ADMIN}" == "?" ]] && echo -e "${ORANGE}Warning: Botadmin not set, did you forget to sent command${NC} /start" +[[ -z "${BOT_NAME}" ]] && echo -e "${ORANGE}Warning: Botname not set, did you ever run bashbot?" + # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME @@ -68,9 +129,9 @@ compare_sorted() { ###### # lets go ... -echo "Running ${TESTNAME#? } ..." -echo "............................" -[ "${TESTDIR}" = "" ] && echo "${NOSUCCESS} not called from testsuite, exit" && exit 1 +printf "Running %s ...\n" "${TESTNAME#? }" +printf "............................\n" +[ "${TESTDIR}" = "" ] && printf "%s not called from testsuite, exit" "${NOSUCCESS}" && exit 1 # reset env for test unset IFS;