From e8173281a8551e1a18ccbbadf2cb4532e27b684c Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 27 Dec 2020 14:37:07 +0100 Subject: [PATCH] adjust tests to manually download JSON.sh --- dev/all-tests.sh | 23 ++++++++++++++++++++--- dev/hooks/pre-commit.sh | 4 ++-- test/e-env-test.sh | 4 ++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/dev/all-tests.sh b/dev/all-tests.sh index fbb3f3e..c2530d3 100755 --- a/dev/all-tests.sh +++ b/dev/all-tests.sh @@ -1,7 +1,12 @@ #!/usr/bin/env bash -# this has to run once atfer git clone -# and every time we create new hooks -#### $$VERSION$$ v1.20-0-g2ab00a2 +############################################################# +# +# File: dev/all-tests.sh +# +# Description: run all tests, exit after failed test +# +#### $$VERSION$$ v1.21-dev-10-g9bfc27a +############################################################# # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script @@ -12,6 +17,7 @@ else echo "Sorry, no git repository $(pwd)" && exit 1 fi +########################## # create test environment TESTENV="/tmp/bashbot.test$$" mkdir "${TESTENV}" @@ -21,6 +27,13 @@ cd "test" || exit 1 # delete possible config rm -f "${TESTENV}/botconfig.jssh" "${TESTENV}/botacl" 2>/dev/null +# inject JSON.sh +mkdir "${TESTENV}/JSON.sh" +curl -sL "https://cdn.jsdelivr.net/gh/dominictarr/JSON.sh/JSON.sh" >"${TESTENV}/JSON.sh/JSON.sh" +chmod +x "${TESTENV}/JSON.sh/JSON.sh" + +######################## +#prepare and run tests #set -e fail=0 tests=0 @@ -45,6 +58,8 @@ do fi done +########################### +# cleanup depending on test state if [ "$fail" -eq 0 ]; then /bin/echo -n 'SUCCESS ' exitcode=0 @@ -56,6 +71,8 @@ else find "${TESTENV}/"* ! -name '[a-z]-*' -delete fi +######################### +# show test result and test logs echo -e "${passed} / ${tests}\\n" [ -d "${TESTENV}" ] && echo "Logfiles from run are in ${TESTENV}" diff --git a/dev/hooks/pre-commit.sh b/dev/hooks/pre-commit.sh index 23255fa..81d2c0d 100755 --- a/dev/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v1.20-0-g2ab00a2 +#### $$VERSION$$ v1.21-dev-10-g9bfc27a ############ # NOTE: you MUST run install-hooks.sh again when updating this file! @@ -68,7 +68,7 @@ fi if command -v codespell &>/dev/null; then echo "Running codespell" echo "............................" - codespell --skip="*.zip,*gz,*.log,*.html,*.txt,.git*,jsonDB-keyboard" -L "ba" + codespell -q 3 --skip="*.zip,*gz,*.log,*.html,*.txt,.git*,jsonDB-keyboard" -L "ba" echo "if there are (to many) typo's shown, consider running:" echo "codespell -i 3 -w --skip=\"*.log,*.html,*.txt,.git*,examples\" -L \"ba\"" else diff --git a/test/e-env-test.sh b/test/e-env-test.sh index aefadef..351645b 100755 --- a/test/e-env-test.sh +++ b/test/e-env-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v1.20-0-g2ab00a2 +#### $$VERSION$$ v1.21-dev-10-g9bfc27a # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh @@ -31,7 +31,7 @@ set +f # shellcheck disable=SC2086 cp ${TESTDIR}/*commands.sh "${BASHBOT_ETC}" || exit 1 set -f -cp -r "${TESTDIR}/bashbot.sh" "${TESTDIR}/modules" "${BASHBOT_BIN}" || exit 1 +cp -r "${TESTDIR}/bashbot.sh" "${TESTDIR}/modules" "${TESTDIR}/JSON.sh/JSON.sh" "${BASHBOT_BIN}" || exit 1 TESTFILES="${TOKENFILE} ${ACLFILE}"