]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Added a script that performes checks of pychecker.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Jan 2009 23:33:27 +0000 (00:33 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Jan 2009 23:33:27 +0000 (00:33 +0100)
src/pomona/Makefile
src/pomona/pychecker-false-positives [new file with mode: 0644]
src/pomona/runpychecker.sh [new file with mode: 0755]

index ea2159f833f006916193b0c056a8e931bb94e93a..408c58207c56e405b5dcf04ebd7dc1ee4b8a956a 100644 (file)
@@ -47,6 +47,9 @@ install: all
        -mkdir -p $(DESTDIR)/sbin
        install -m 755 $(PSNAME) $(DESTDIR)/sbin/$(PSNAME)
 
+test:
+       ./runpychecker.sh
+
 clean:
        rm -vf *.o *.so *.pyc *.pyo lang-names{,.tmp}
        for d in $(SUBDIRS); do make -C $$d clean; done
diff --git a/src/pomona/pychecker-false-positives b/src/pomona/pychecker-false-positives
new file mode 100644 (file)
index 0000000..0d06375
--- /dev/null
@@ -0,0 +1,13 @@
+deleted
+filter
+setattr
+^$
+^Warnings...$
+^installer\.py:[0-9]*: No global .* found$
+^fsset\.py:[0-9]*: Object \(bestprep\) has no attribute \(format\)$
+^partitions.py:[0-9]*: Object \(bestprep\) has no attribute \(getPreExisting\)$
+^partitions.py:[0-9]*: Object \(bestreq\) has no attribute \(format\)$
+^.*isys/isys.py:[0-9]*: Object \(.*_iface\) has no attribute \(Get.*\)$
+^partedUtils.py:[0-9]*: No module attribute \(__dict__\) found$
+^partedUtils.py:[0-9]*: No module attribute \(DEVICE_SX8\) found$
+Note this last line must never end with a newline
\ No newline at end of file
diff --git a/src/pomona/runpychecker.sh b/src/pomona/runpychecker.sh
new file mode 100755 (executable)
index 0000000..b9ad592
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+# This script will check pomona for any pychecker warning using a set of
+# options minimizing false positives, in combination with filtering of any
+# warning regularexpressions listed in pychecker-false-positives.
+# 
+# If any warnings our found they will be stored in pychecker-log and printed
+# to stdout and this script will exit with a status of 1, if no (non filtered)
+# warnings are found it exits with a status of 0
+
+FALSE_POSITIVES=pychecker-false-positives
+NON_STRICT_OPTIONS="--no-deprecated --no-returnvalues --no-abstract"
+
+usage () {
+  echo "usage: `basename $0` [--strict] [--help]"
+  exit $1
+}
+
+while [ $# -gt 0 ]; do
+  case $1 in
+    --strict)
+      NON_STRICT_OPTIONS=""
+      ;;
+    --help)
+      usage 0
+      ;;
+    *)
+      echo "Error unknown option: $1"
+      usage 1
+  esac
+  shift
+done
+
+if [ "`tail -c 1 pychecker-false-positives`" == "`echo`" ]; then
+  echo "Error $FALSE_POSITIVES ends with an enter."
+  echo "Error the last line of $FALSE_POSITIVES should never have an enter!"
+  exit 1
+fi
+
+export PYTHONPATH="isys"
+
+FILES=installer.py
+for file in *.py isys/*.py; do FILES="${FILES} ${file}"; done
+
+pychecker --only --limit 1000 \
+  --maxlines 500 --maxargs 20 --maxbranches 80 --maxlocals 60 --maxreturns 20 \
+  --no-callinit --no-local --no-shadow --no-shadowbuiltin \
+  --no-import --no-miximport --no-pkgimport --no-reimport \
+  --no-argsused --no-varargsused --no-override \
+  $NON_STRICT_OPTIONS $FILES | \
+  egrep -v "`cat $FALSE_POSITIVES | tr '\n' '|'`" > pychecker-log
+
+if [ -s pychecker-log ]; then
+  echo "Pychecker reports the following issues:"
+  cat pychecker-log
+  exit 1
+fi
+
+rm pychecker-log
+
+exit 0