python: add a pycodestyle test

Look for pycodestyle, and use it to check all the Python sources (tests
and auxiliary scripts included) of the Python bindings.
This commit is contained in:
Pino Toscano
2020-01-10 15:02:01 +01:00
parent da4c7f9112
commit cad3ea9e74
4 changed files with 37 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ EXTRA_DIST = \
setup.py.in \
run-bindtests \
run-python-tests \
test-pycodestyle.sh \
t/__init__.py \
t/README \
t/test[0-9]*.py
@@ -121,6 +122,10 @@ if ENABLE_APPLIANCE
TESTS += run-python-tests
endif ENABLE_APPLIANCE
if HAVE_PYCODESTYLE
TESTS += test-pycodestyle.sh
endif
endif HAVE_PYTHON
# Extra clean.

28
python/test-pycodestyle.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2020 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
set -e
$TEST_FUNCTIONS
skip_if_skipped
# Gather the list of Python sources.
# (-u is passed to to sort to avoid duplicates in case builddir==srcdir)
files="$(find "$srcdir" . -name '*.py' | sort -u)"
$PYCODESTYLE $files