summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-10-19 18:39:15 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-10-19 18:39:15 -0700
commita22cf8ffc110401b9e3cfa8a8e6dc7c3af57ec2d (patch)
tree2e416ad2872677de6827c42c06d970ade24e1744
parentf34b55ac2bcfd71640b3db91f3c4e177f723cd03 (diff)
downloadansible-a22cf8ffc110401b9e3cfa8a8e6dc7c3af57ec2d.tar.gz
Properly add the new test and limit six test to lib
-rw-r--r--.travis.yml4
-rwxr-xr-xtest/code-smell/boilerplate.sh52
2 files changed, 54 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml
index 21d0177fb9..25ffe5ae7c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,8 +22,8 @@ install:
script:
# urllib2's defaults are not secure enough for us
- ./test/code-smell/replace-urlopen.sh .
-- ./test/code-smell/use-compat-six.sh .
-- ./test/code-smell/boilerplate.sh .
+- ./test/code-smell/use-compat-six.sh lib
+- ./test/code-smell/boilerplate.sh
- if test x"$TOXENV" != x'py24' ; then tox ; fi
- if test x"$TOXENV" = x'py24' ; then python2.4 -V && python2.4 -m compileall -fq -x 'module_utils/(a10|rax|openstack|ec2|gce).py' lib/ansible/module_utils ; fi
#- make -C docsite all
diff --git a/test/code-smell/boilerplate.sh b/test/code-smell/boilerplate.sh
new file mode 100755
index 0000000000..f31179081f
--- /dev/null
+++ b/test/code-smell/boilerplate.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+metaclass1=$(find ./bin -type f -exec grep -HL '__metaclass__ = type' \{\} \; )
+future1=$(find ./bin -type f -exec grep -HL 'from __future__ import (absolute_import, division, print_function)' \{\} \;)
+
+metaclass2=$(find ./lib/ansible -path ./lib/ansible/modules/core -prune \
+ -o -path ./lib/ansible/modules/extras -prune \
+ -o -path ./lib/ansible/module_utils -prune \
+ -o -path ./lib/ansible/compat/six/_six.py -prune \
+ -o -path ./lib/ansible/utils/module_docs_fragments -prune \
+ -o -name '*.py' -exec grep -HL '__metaclass__ = type' \{\} \;)
+
+future2=$(find ./lib/ansible -path ./lib/ansible/modules/core -prune \
+ -o -path ./lib/ansible/modules/extras -prune \
+ -o -path ./lib/ansible/module_utils -prune \
+ -o -path ./lib/ansible/compat/six/_six.py -prune \
+ -o -path ./lib/ansible/utils/module_docs_fragments -prune \
+ -o -name '*.py' -exec grep -HL 'from __future__ import (absolute_import, division, print_function)' \{\} \;)
+
+### TODO:
+### - contrib/
+### - module_utils that are py2.6+
+
+
+if test -n "$metaclass1" -o -n "$metaclass2" ; then
+printf "\n== Missing __metaclass__ = type ==\n"
+fi
+
+if test -n "$metaclass1" ; then
+ printf "$metaclass1\n"
+fi
+if test -n "$metaclass2" ; then
+ printf "$metaclass2\n"
+fi
+
+if test -n "$future1" -o -n "$future2" ; then
+ printf "\n== Missing from __future__ import (absolute_import, division, print_function) ==\n"
+fi
+
+if test -n "$future1" ; then
+ printf "$future1\n"
+fi
+if test -n "$future2" ; then
+ printf "$future2\n"
+fi
+
+if test -n "$future1$future2$metaclass1$metaclass2" ; then
+ failures=$(printf "$future1$future2$metaclass1$metaclass2"| wc -l)
+ failures=$(expr $failures + 2)
+ exit $failures
+fi
+exit 0