|
Packit |
6bd9ab |
#!/bin/sh
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# test_pylint.sh - run pylint on the source to find errors
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# Copyright (C) 2013 Arthur de Jong
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# This library is free software; you can redistribute it and/or
|
|
Packit |
6bd9ab |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6bd9ab |
# License as published by the Free Software Foundation; either
|
|
Packit |
6bd9ab |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# This library is distributed in the hope that it will be useful,
|
|
Packit |
6bd9ab |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6bd9ab |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6bd9ab |
# Lesser General Public License for more details.
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6bd9ab |
# License along with this library; if not, write to the Free Software
|
|
Packit |
6bd9ab |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit |
6bd9ab |
# 02110-1301 USA
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
set -e
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# find source directory
|
|
Packit |
6bd9ab |
srcdir="${srcdir-`dirname "$0"`}"
|
|
Packit |
6bd9ab |
top_srcdir="${top_srcdir-${srcdir}/..}"
|
|
Packit |
6bd9ab |
builddir="${builddir-`dirname "$0"`}"
|
|
Packit |
6bd9ab |
top_builddir="${top_builddir-${builddir}/..}"
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# if Pylint is missing, ignore
|
|
Packit |
6bd9ab |
if ! pylint --version > /dev/null 2> /dev/null
|
|
Packit |
6bd9ab |
then
|
|
Packit |
6bd9ab |
echo "Pylint not found"
|
|
Packit |
6bd9ab |
exit 77
|
|
Packit |
6bd9ab |
fi
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# get rcfile absolute path
|
|
Packit |
6bd9ab |
absdir="$( (cd "$srcdir"; pwd) )"
|
|
Packit |
6bd9ab |
rcfile="$absdir/pylint.rc"
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# get the disable option from the configuration file
|
|
Packit |
6bd9ab |
# (this somehow doesn't work in pylint)
|
|
Packit |
6bd9ab |
disable=$(sed -n 's/^disable=\(.*\)$/\1/p' "$rcfile")
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# run Pylint in both pynslcd and utils directories
|
|
Packit |
6bd9ab |
for dir in pynslcd utils
|
|
Packit |
6bd9ab |
do
|
|
Packit |
6bd9ab |
echo "Running pylint in $dir..."
|
|
Packit |
6bd9ab |
dir_builddir="$(cd "${top_builddir}/${dir}" && pwd)"
|
|
Packit |
6bd9ab |
( cd "${top_srcdir}/${dir}" ;
|
|
Packit |
6bd9ab |
PYTHONPATH="${dir_builddir}" pylint --errors-only --rcfile "$rcfile" --disable "$disable" *.py)
|
|
Packit |
6bd9ab |
done
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# Pylint has the following exit codes:
|
|
Packit |
6bd9ab |
# 0 if everything went fine
|
|
Packit |
6bd9ab |
# 1 if a fatal message was issued
|
|
Packit |
6bd9ab |
# 2 if an error message was issued
|
|
Packit |
6bd9ab |
# 4 if a warning message was issued
|
|
Packit |
6bd9ab |
# 8 if a refactor message was issued
|
|
Packit |
6bd9ab |
# 16 if a convention message was issued
|
|
Packit |
6bd9ab |
# 32 on usage error
|
|
Packit |
6bd9ab |
# (exit codes are ORed)
|