tools: Start running pep8 against python tests

.travis.xml and containers/unit-tests/Dockerfile were adjusted to
install python3-pep8 package.

Closes #10657
This commit is contained in:
Katerina Koukiou 2018-11-23 19:11:07 +01:00 committed by Martin Pitt
parent 24ec0a4a3c
commit de918cc808
3 changed files with 24 additions and 2 deletions

View File

@ -58,6 +58,7 @@ addons:
- pcp
- pkg-config
- pyflakes
- python3-pep8
- ssh
- valgrind
- xmlto

View File

@ -18,7 +18,7 @@ RUN dpkg --add-architecture ${arch} && echo ${arch} > /arch && apt-get update &&
apt-get install -y --allow-downgrades libssh-dev:${arch}=0.6.3-4.3 libssh-4:${arch}=0.6.3-4.3 && \
echo 'deb http://archive.ubuntu.com/ubuntu bionic universe' > /etc/apt/sources.list.d/stable.list && \
apt-get update && \
apt-get install -y pyflakes pyflakes3 && \
apt-get install -y pyflakes pyflakes3 python3-pep8 && \
apt-get clean
# use latest npm/node

View File

@ -2,7 +2,7 @@
# run static code checks like pyflakes and pep8
set -eu
echo "1..6"
echo "1..7"
builddir=$(pwd)
cd "${srcdir:-.}"
@ -108,4 +108,25 @@ else
echo "ok 6 json-verify # SKIP not a git tree"
fi
# pycodestyle/pep8 python syntax check
if python3 -m pycodestyle /dev/null >/dev/null 2>&1; then
PYTHON_STYLE_CHECKER="pycodestyle"
elif python3 -m pep8 /dev/null >/dev/null 2>&1; then
PYTHON_STYLE_CHECKER="pep8"
fi
if [ -z "${PYTHON_STYLE_CHECKER-}" ]; then
echo "ok 7 pycodestyle test # SKIP pycodestyle not installed"
else
# FIXME: Fix code for the warnings and re-enable them
out=$(python3 -m "$PYTHON_STYLE_CHECKER" --ignore E501,E265,E261,W504,W605 test/verify/* --exclude=test/verify/nested-kvm) || true
if [ -n "$out" ]; then
echo "$out" >&2
echo "not ok 7 $PYTHON_STYLE_CHECKER test"
fail=1
else
echo "ok 7 $PYTHON_STYLE_CHECKER test"
fi
fi
exit $fail