mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-28 12:50:44 +00:00
tests: a- and c- printf conversion
This commit is contained in:
parent
32b99dcf2b
commit
0dfbf7bbac
@ -1,5 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v1.20-0-g2ab00a2
|
#===============================================================================
|
||||||
|
#
|
||||||
|
# FILE: b-example-test.sh
|
||||||
|
#
|
||||||
|
# USAGE: must run only from dev/all-tests.sh
|
||||||
|
#
|
||||||
|
# DESCRIPTION: run pre-commit tests first
|
||||||
|
#
|
||||||
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||||
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||||
|
#
|
||||||
|
#### $$VERSION$$ v1.21-pre-35-g32b99dc
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
../dev/hooks/pre-commit.sh
|
../dev/hooks/pre-commit.sh
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.21-pre-34-g9492f98
|
#### $$VERSION$$ v1.21-pre-35-g32b99dc
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
@ -23,7 +23,7 @@ source "./ALL-tests.inc.sh"
|
|||||||
# example: test if TESTDIR contains file bashbot.sh
|
# example: test if TESTDIR contains file bashbot.sh
|
||||||
printf "Check if bashbot.sh exists in %s ...\n" " ${TESTDIR}"
|
printf "Check if bashbot.sh exists in %s ...\n" " ${TESTDIR}"
|
||||||
if [ -f "${TESTDIR}/bashbot.sh" ]; then
|
if [ -f "${TESTDIR}/bashbot.sh" ]; then
|
||||||
printf "bashbot.sh found!\n"
|
printf " ... bashbot.sh found!\n"
|
||||||
else
|
else
|
||||||
# stop test script if test failed
|
# stop test script if test failed
|
||||||
printf "%s\n" "${NOSUCCESS} ${TESTDIR}/bashbot.sh missing!"
|
printf "%s\n" "${NOSUCCESS} ${TESTDIR}/bashbot.sh missing!"
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v1.21-pre-18-g05b81ff
|
#===============================================================================
|
||||||
|
#
|
||||||
|
# FILE: c-init-test.sh
|
||||||
|
#
|
||||||
|
# USAGE: must run only from dev/all-tests.sh
|
||||||
|
#
|
||||||
|
# DESCRIPTION: test "bashbot.sh init" and sourcing bashbot.sh
|
||||||
|
#
|
||||||
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||||
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||||
|
#
|
||||||
|
#### $$VERSION$$ v1.21-pre-35-g32b99dc
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
@ -10,38 +22,41 @@ TESTFILES="${TOKENFILE} ${ACLFILE} ${COUNTFILE} ${BLOCKEDFILE} ${ADMINFILE}"
|
|||||||
#set -e
|
#set -e
|
||||||
|
|
||||||
# run bashbot first time with init
|
# run bashbot first time with init
|
||||||
|
printf "Run bashbot init ...\n"
|
||||||
"${TESTDIR}/bashbot.sh" init >"${LOGFILE}" <<EOF
|
"${TESTDIR}/bashbot.sh" init >"${LOGFILE}" <<EOF
|
||||||
$TESTTOKEN
|
$TESTTOKEN
|
||||||
nobody
|
nobody
|
||||||
botadmin
|
botadmin
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
echo "${SUCCESS}"
|
printf "%s\n" "${SUCCESS}"
|
||||||
|
|
||||||
# compare files with reference files
|
# compare files with reference files
|
||||||
echo "Check new files after init ..."
|
printf "Check new files after init ...\n"
|
||||||
export FAIL="0"
|
export FAIL="0"
|
||||||
for file in ${TESTFILES}
|
for file in ${TESTFILES}
|
||||||
do
|
do
|
||||||
ls -d "${TESTDIR}/${file}" >>"${LOGFILE}"
|
ls -d "${TESTDIR}/${file}" >>"${LOGFILE}"
|
||||||
diff -q "${TESTDIR}/${file}" "${REFDIR}/${file}" >>"${LOGFILE}" || { echo "${NOSUCCESS} Fail diff ${file}!"; FAIL="1"; }
|
diff -q "${TESTDIR}/${file}" "${REFDIR}/${file}" >>"${LOGFILE}" || { printf "%s\n" "${NOSUCCESS} Fail diff ${file}!"; FAIL="1"; }
|
||||||
done
|
done
|
||||||
[ "${FAIL}" != "0" ] && exit "${FAIL}"
|
[ "${FAIL}" != "0" ] && exit "${FAIL}"
|
||||||
echo "${SUCCESS}"
|
printf "%s\n" "${SUCCESS}"
|
||||||
|
|
||||||
trap exit 1 EXIT
|
trap exit 1 EXIT
|
||||||
cd "${TESTDIR}" || exit
|
cd "${TESTDIR}" || exit
|
||||||
|
|
||||||
echo "Test if $JSONSHFILE exists ..."
|
printf "%s\n" "Test if ${JSONSHFILE} exists ..."
|
||||||
[ ! -x "$JSONSHFILE" ] && { echo "${NOSUCCESS} json.sh not found"; exit 1; }
|
[ ! -x "$JSONSHFILE" ] && { printf "%s\n" "${NOSUCCESS} json.sh not found"; exit 1; }
|
||||||
|
|
||||||
echo "Test Sourcing of bashbot.sh ..."
|
printf "Test Sourcing of bashbot.sh ..."
|
||||||
# shellcheck source=./bashbot.sh
|
# shellcheck source=./bashbot.sh
|
||||||
source "${TESTDIR}/bashbot.sh" source
|
source "${TESTDIR}/bashbot.sh" source
|
||||||
echo "Test Sourcing of commands.sh ..."
|
|
||||||
|
printf "Test Sourcing of commands.sh ...\n"
|
||||||
source "${TESTDIR}/commands.sh" source
|
source "${TESTDIR}/commands.sh" source
|
||||||
|
|
||||||
trap '' EXIT
|
trap '' EXIT
|
||||||
cd "${DIRME}" || exit 1
|
cd "${DIRME}" || exit 1
|
||||||
echo "${SUCCESS}"
|
|
||||||
|
printf "%s\n" "${SUCCESS}"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user