tests: final printf conversion

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-01-02 17:21:28 +01:00
parent f7b5c19cab
commit e8aa80c15a
3 changed files with 65 additions and 32 deletions

View File

@ -1,58 +1,79 @@
#!/usr/bin/env bash
#===============================================================================
#
# ADD a new test skeleton to test dir, but does not activate test
# FILE: ADD-test-new.sh
#
# USAGE: ADD-test-new.sh
#
#### $$VERSION$$ v1.20-0-g2ab00a2
# DESCRIPTION: creates interactive a new test skeleton, but does not activate test
#
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
#
#### $$VERSION$$ v1.21-pre-38-gf7b5c19
#===============================================================================
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
GIT_DIR=$(git rev-parse --git-dir)
cd "${GIT_DIR}/.." || exit 1
echo -ne "\\nDo your really want to create an new test for bashbot test suite? (y/N) N\\b"
printf "\nDo your really want to create an new test for bashbot test suite? (y/N) N\b"
read -r REALLY
[ "${REALLY}" != "y" ] && echo "Aborting ..." && exit 1
[ "${REALLY}" != "y" ] && printf "Stop ...\n\n" && exit 1
# enter name
echo -ne "\\nEnter Name for the the new test, 6+ chars, no :space: (empty to abort) abort\\b\\b\\b\\b\\b"
printf "\nEnter Name for the the new test, 6+ chars, no :space: (empty to stop) stop\b\b\b\b"
read -r NAME
if [ "${NAME}" = "" ] || [ "${NAME}" = "" ]; then echo "Aborting ..."; exit 1; fi
if [ "${NAME}" = "" ] || [ "${NAME}" = "" ]; then printf "Stop ...\n\n"; exit 1; fi
# enter pass a-z
echo -ne "\\nEnter PASS \"a\" to \"z\" to execute the new test, d\\b"
printf "\nEnter PASS \"a\" to \"z\" to execute the new test, d\b"
read -r PASS
# pass to lower, default pass d
PASS="${PASS,,}"
[ "${PASS}" = "" ] && PASS="d"
[ "${#PASS}" != '1' ] && echo "Sorry, PASS must exactly one character from a to z, aborting ..." && exit 1
[ "${#PASS}" != '1' ] && printf "SORRY: PASS must exactly one character from a to z! Stop ...\n\n" && exit 1
TEST="${PASS}-${NAME}-test"
echo -e " OK! You entered name \"${NAME}\" and pass \"${PASS}\".\\n"
printf "%s\n\n" " OK! Let's create test name \"${NAME}\" for pass \"${PASS}\"."
# check if already exist
if [ -f "test/${TEST}.sh" ] || [ -d "test/${TEST}" ]; then
echo "TEST EXIST ALREADY! Aborting ..."
printf "%s\n\n" "SORRY: Test test/${TEST}.sh already exists! Stop ..."
exit 1
fi
echo "The following files will be created for test \"${TEST}.sh\":"
echo -e " test/${TEST}.sh\\n test/${TEST}/${TEST}.input\\n test/${TEST}/${TEST}.result"
printf "The following files will be created:\n"
printf "%s\n%s\n%s\n" " test/${TEST}.sh" " test/${TEST}/${TEST}.input" " test/${TEST}/${TEST}.result"
echo -ne "\\nCreate the new test for bashbot test suite? (y/N) N\\b"
printf "\nCreate the new test for bashbot test suite? (y/N) N\b"
read -r REALLY
[ "${REALLY}" != "y" ] && echo "Aborting ..." && exit 1
[ "${REALLY}" != "y" ] && printf "Stop ...\n\n" && exit 1
echo -e " OK!\\n"
printf " OK!\n\n"
# create files
cat >"test/${TEST}.sh" <<EOF
#!/usr/bin/env bash
#===============================================================================
#
# FILE: test/${TEST}.sh
#
# USAGE: must run only from dev/all-tests.sh
#
# DESCRIPTION: test ,,,
#
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
# AUTHOR: yourname, your@e-mail.com
#
#### \$\$VERSION\$\$
#===============================================================================
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -64,8 +85,8 @@ cd "\${TESTDIR}" || exit 1
# source bashbot.sh function, uncomment if you want to test functions
# shellcheck source=./bashbot.sh
# source "\\${TESTDIR}/bashbot.sh" source
# source "\\${TESTDIR}/commands.sh" source
# source "\${TESTDIR}/bashbot.sh" source
# source "\${TESTDIR}/commands.sh" source
# start writing your tests here ...
@ -77,4 +98,4 @@ touch "test/${TEST}/${TEST}.input" "test/${TEST}/${TEST}.result"
set +f
ls -l test/"${PASS}"-"${NAME}"-*
echo "Done."
printf "\nDone.\n"

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
#===============================================================================
#
# FILE: d-user:is-test.sh
# FILE: d-user_is-test.sh
#
# USAGE: must run only from dev/all-tests.sh
#
@ -10,7 +10,7 @@
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
#
#### $$VERSION$$ v1.21-pre-37-g7e1c1b5
#### $$VERSION$$ v1.21-pre-38-gf7b5c19
#===============================================================================
# include common functions and definitions

View File

@ -1,5 +1,17 @@
#!/usr/bin/env bash
#### $$VERSION$$ v1.21-pre-7-g74dfdd7
#===============================================================================
#
# FILE: e-env-test.sh
#
# USAGE: must run only from dev/all-tests.sh
#
# DESCRIPTION: test BASHBOT_xxx variables working as expected
#
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
#
#### $$VERSION$$ v1.21-pre-38-gf7b5c19
#===============================================================================
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh
@ -36,7 +48,7 @@ cp -r "${TESTDIR}/bashbot.sh" "${TESTDIR}/modules" "${TESTDIR}/JSON.sh/JSON.sh"
TESTFILES="${TOKENFILE} ${ACLFILE}"
echo "Check first run in ENVIRONMENT ..."
printf "Check first run in ENVIRONMENT ...\n"
mkdir "${BASHBOT_VAR}/${DATADIR}"
# run bashbot first time with init
@ -45,24 +57,24 @@ $TESTTOKEN
nobody
botadmin
EOF
echo "${SUCCESS}"
printf "%s\n" "${SUCCESS}"
echo "Check if files are placed in ENVIRONMENT ..."
printf "Check if files are placed in ENVIRONMENT ...\n"
if [ ! -f "${BASHBOT_JSONSH}" ]; then
echo "${NOSUCCESS} ${BASHBOT_JSONSH} missing!"
printf "%s\n" "${NOSUCCESS} ${BASHBOT_JSONSH} missing!"
exit 1
fi
if [ ! -d "${BASHBOT_VAR}/${DATADIR}" ]; then
echo "${NOSUCCESS} ${DATADIR} missing!"
printf "%s\n" "${NOSUCCESS} ${DATADIR} missing!"
exit 1
fi
if [ ! -f "${BASHBOT_VAR}/${COUNTFILE}" ]; then
echo "${NOSUCCESS} ${BASHBOT_VAR}/${COUNTFILE} missing!"
printf "%s\n" "${NOSUCCESS} ${BASHBOT_VAR}/${COUNTFILE} missing!"
exit 1
fi
echo " ... BASHBOT_VAR seems to work!"
echo "${SUCCESS}"
printf " ... BASHBOT_VAR seems to work!\n"
printf "%s\n" "${SUCCESS}"
# compare files with reference files
@ -70,9 +82,9 @@ export FAIL="0"
for file in ${TESTFILES}
do
ls -d "${BASHBOT_ETC}/${file}" >>"${LOGFILE}"
if ! diff -q "${BASHBOT_ETC}/${file}" "${REFDIR}/${file}" >>"${LOGFILE}"; then echo "${NOSUCCESS} Fail diff ${file}!"; FAIL="1"; fi
if ! diff -q "${BASHBOT_ETC}/${file}" "${REFDIR}/${file}" >>"${LOGFILE}"; then printf "%s\n" "${NOSUCCESS} Fail diff ${file}!"; FAIL="1"; fi
done
echo " ... BASHBOT_ETC seems to work!"
echo "${SUCCESS}"
printf " ... BASHBOT_ETC seems to work!\n"
printf "%s\n" "${SUCCESS}"