1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-05 07:23:48 +00:00

move test helpers

This commit is contained in:
deadc0de6
2023-01-28 16:14:19 +01:00
committed by deadc0de
parent 2f663e9dc4
commit b9015528bb
5 changed files with 6 additions and 4 deletions

29
scripts/check-doc.sh vendored Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
# author: deadc0de6 (https://github.com/deadc0de6)
# Copyright (c) 2022, deadc0de6
set -e
## test doc external links
find . -type f -iname '*.md' | while read -r line; do
./scripts/check_links.py "${line}"
done
## test the doc internal links
## https://github.com/remarkjs/remark-validate-links
## https://github.com/tcort/markdown-link-check
## npm install -g remark-cli remark-validate-links
set +e
which remark >/dev/null 2>&1
r="$?"
set -e
if [ "$r" != "0" ]; then
echo "[WARNING] install \"remark\" to test the doc"
exit 1
fi
find . -type f -iname '*.md' | while read -r line; do
remark -f -u validate-links "${line}"
done
echo "documentation OK"

119
scripts/check-syntax.sh vendored Executable file
View File

@@ -0,0 +1,119 @@
#!/bin/sh
# author: deadc0de6 (https://github.com/deadc0de6)
# Copyright (c) 2022, deadc0de6
# stop on first error
#set -ev
set -e
# ensure binaries are here
if ! which shellcheck >/dev/null 2>&1; then
echo "Install shellcheck"
exit 1
fi
echo "=> shellcheck version:"
shellcheck --version
# python tools versions
if ! which pylint >/dev/null 2>&1; then
echo "Install pylint"
exit 1
fi
echo "=> pylint version:"
pylint --version
if ! which pycodestyle >/dev/null 2>&1; then
echo "Install pycodestyle"
exit 1
fi
echo "=> pycodestyle version:"
pycodestyle --version
if ! which pyflakes >/dev/null 2>&1; then
echo "Install pyflakes"
exit 1
fi
echo "=> pyflakes version:"
pyflakes --version
# check shell scripts
# SC2002: Useless cat
# SC2126: Consider using grep -c instead of grep|wc -l
# SC2129: Consider using { cmd1; cmd2; } >> file instead of individual redirects
# SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?
echo "--------------------------------------"
echo "checking shell scripts with shellcheck"
echo "--------------------------------------"
find . -iname '*.sh' | while read -r script; do
echo "checking ${script}"
shellcheck -x \
-e SC2002 \
-e SC2126 \
-e SC2129 \
-e SC2181 \
"${script}"
done
# check other python scripts
echo "-----------------------------------------"
echo "checking other python scripts with pylint"
echo "-----------------------------------------"
find . -name "*.py" -not -path "./dotdrop/*" | while read -r script; do
echo "checking ${script}"
pylint -sn \
--disable=R0914 \
--disable=R0915 \
--disable=R0913 \
"${script}"
done
# PEP8 tests
# W503: Line break occurred before a binary operator
# W504: Line break occurred after a binary operator
echo "---------------------------------"
echo "checking dotdrop with pycodestyle"
echo "---------------------------------"
pycodestyle --ignore=W503,W504 dotdrop/
pycodestyle scripts/
# pyflakes tests
echo "------------------------------"
echo "checking dotdrop with pyflakes"
echo "------------------------------"
pyflakes dotdrop/
# pylint
echo "----------------------------"
echo "checking dotdrop with pylint"
echo "----------------------------"
# https://pylint.pycqa.org/en/latest/user_guide/checkers/features.html
# R0902: too-many-instance-attributes
# R0913: too-many-arguments
# R0903: too-few-public-methods
# R0914: too-many-locals
# R0915: too-many-statements
# R0912: too-many-branches
# R0911: too-many-return-statements
# R0904: too-many-public-methods
pylint \
--disable=R0902 \
--disable=R0913 \
--disable=R0903 \
--disable=R0914 \
--disable=R0915 \
--disable=R0912 \
--disable=R0911 \
--disable=R0904 \
dotdrop/
echo "------------------------"
echo "checking for more issues"
echo "------------------------"
set +e
exceptions="save_uservariables_name\|@@\|diff_cmd\|original,\|modified,"
# f-string errors and missing f literal
find dotdrop/ -iname '*.py' -exec grep --with-filename -n -v "f'" {} \; | grep -v "{'" | grep -v "${exceptions}" | grep "'.*}" && echo "bad string format (1)" && exit 1
find dotdrop/ -iname '*.py' -exec grep --with-filename -n -v 'f"' {} \; | grep -v "f'" | grep -v '{"' | grep -v "${exceptions}" | grep '".*}' && echo "bad string format (2)" && exit 1
set -e
echo "syntax OK"

47
scripts/check-tests-ng.sh vendored Executable file
View File

@@ -0,0 +1,47 @@
#!/bin/sh
# author: deadc0de6 (https://github.com/deadc0de6)
# Copyright (c) 2023, deadc0de6
# stop on first error
set -e
rl="readlink -f"
if ! ${rl} "${0}" >/dev/null 2>&1; then
rl="realpath"
if ! hash ${rl}; then
echo "\"${rl}\" not found!" && exit 1
fi
fi
cur=$(dirname "$(${rl} "${0}")")
tmpworkdir="/tmp/dotdrop-tests-workdir"
export DOTDROP_WORKDIR="${tmpworkdir}"
workers=${DOTDROP_WORKERS}
if [ -n "${workers}" ]; then
DOTDROP_WORKERS=${workers}
echo "ENABLE workers: ${workers}"
fi
# run bash tests
export DOTDROP_DEBUG="yes"
unset DOTDROP_FORCE_NODEBUG
workdir_tmp_exists="no"
[ -d "${HOME}/.config/dotdrop/tmp" ] && workdir_tmp_exists="yes"
if [ -z "${GITHUB_WORKFLOW}" ]; then
## local
export COVERAGE_FILE=
tests-ng/tests-launcher.py
else
## CI/CD
export COVERAGE_FILE="${cur}/.coverage"
# running multiple jobs in parallel sometimes
# messes with the results on remote servers
tests-ng/tests-launcher.py 1
fi
# clear workdir
[ "${workdir_tmp_exists}" = "no" ] && rm -rf ~/.config/dotdrop/tmp
# clear temp workdir
rm -rf "${tmpworkdir}"

36
scripts/check-unittests.sh vendored Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/sh
# author: deadc0de6 (https://github.com/deadc0de6)
# Copyright (c) 2023, deadc0de6
# stop on first error
set -e
rl="readlink -f"
if ! ${rl} "${0}" >/dev/null 2>&1; then
rl="realpath"
if ! hash ${rl}; then
echo "\"${rl}\" not found!" && exit 1
fi
fi
cur=$(dirname "$(${rl} "${0}")")
if [ -n "${DOTDROP_WORKERS}" ]; then
unset DOTDROP_WORKERS
echo "DISABLE workers"
fi
# execute tests with coverage
if [ -z "${GITHUB_WORKFLOW}" ]; then
## local
export COVERAGE_FILE=
# do not print debugs when running tests (faster)
# tests
PYTHONPATH="dotdrop" nose2 --with-coverage --coverage dotdrop --plugin=nose2.plugins.mp -N0
else
## CI/CD
export COVERAGE_FILE="${cur}/.coverage"
# tests
PYTHONPATH="dotdrop" nose2 --with-coverage --coverage dotdrop
fi
#PYTHONPATH="dotdrop" python3 -m pytest tests