[PATCH 5/5] Changes to allow pylint checks to be run on a distribution of the source.
mulhern
amulhern at redhat.com
Wed Mar 19 20:08:36 UTC 2014
That is, we allow for the fact that sometime the top source directory
may not actually be a git working directory.
Changes taken from anaconda commit 67dd55b7d532dadd5ac05cb89e63435b9d76be39.
Signed-off-by: mulhern <amulhern at redhat.com>
---
tests/lib/testlib.sh | 37 +++++++++++++++++++++++++++++++++++++
tests/pylint/runpylint.sh | 17 +++++++----------
2 files changed, 44 insertions(+), 10 deletions(-)
create mode 100644 tests/lib/testlib.sh
diff --git a/tests/lib/testlib.sh b/tests/lib/testlib.sh
new file mode 100644
index 0000000..896d884
--- /dev/null
+++ b/tests/lib/testlib.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Shell functions for use by anaconda tests
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: David Shea <dshea at redhat.com>
+
+# Print a list of files to test on stdout
+# Takes filter arguments identical to the find utility, for example
+# findtestfiles -name '*.py'. Note that pruning directories will not
+# work since find is passed a list of filenames as the path arguments.
+findtestfiles()
+{
+ # If the test is being run from a git work tree, use a list of all files
+ # known to git
+ if [ -d "${top_srcdir}/.git" ]; then
+ findpath=$(git ls-files -c "${top_srcdir}")
+ # Otherwise list everything under $top_srcdir
+ else
+ findpath="${top_srcdir} -type f"
+ fi
+
+ find $findpath "$@"
+}
diff --git a/tests/pylint/runpylint.sh b/tests/pylint/runpylint.sh
index 5d452b8..e0ec7de 100755
--- a/tests/pylint/runpylint.sh
+++ b/tests/pylint/runpylint.sh
@@ -27,6 +27,8 @@ if [ -z "$top_srcdir" ]; then
. ${top_srcdir}/tests/testenv.sh
fi
+. ${top_srcdir}/tests/lib/testlib.sh
+
srcdir="${top_srcdir}/tests/pylint"
builddir="${top_builddir}/tests/pylint"
@@ -89,16 +91,11 @@ fi
# run pylint one file / module at a time, otherwise it sometimes gets
# confused
if [ -z "$FILES" ]; then
- # Find any file in the git working tree that either ends in .py
- # or contains #!/usr/bin/python in the first line.
- # Scan everything except old_tests
- for testfile in $(git ls-files -c "${top_srcdir}" | egrep -v '(^|/)old_tests/') ; do
- if [ -f "${testfile}" ] && \
- ( [ "${testfile%.py}" != "${testfile}" ] || \
- head -1 "${testfile}" | grep -q '^#!/usr/bin/python' ) ; then
- FILES="$FILES $testfile"
- fi
- done
+ # Test any file that either ends in .py or contains #!/usr/bin/python in
+ # the first line. Scan everything except old_tests
+ FILES=$(findtestfiles \( -name '*.py' -o \
+ -exec /bin/sh -c "head -1 {} | grep -q '#!/usr/bin/python'" \; \) -print | \
+ egrep -v '(|/)old_tests/')
fi
num_cpus=$(getconf _NPROCESSORS_ONLN)
--
1.8.3.1
More information about the anaconda-patches
mailing list