From dd46cb7b055ee4b5e8666ae3a1098d03b5010019 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 13 Dec 2016 16:39:03 -0800 Subject: [PATCH] Add a code-smell test for iterkeys (#18589) * Add a code-smell test for iterkeys * Add a message on how to port iterkeys problems and make the grep more robust --- test/sanity/code-smell/no-iterkeys.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 test/sanity/code-smell/no-iterkeys.sh diff --git a/test/sanity/code-smell/no-iterkeys.sh b/test/sanity/code-smell/no-iterkeys.sh new file mode 100755 index 0000000000..bc21b966b0 --- /dev/null +++ b/test/sanity/code-smell/no-iterkeys.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +ITERKEYS_USERS=$(grep -r -I iterkeys . \ + --exclude-dir .git \ + --exclude-dir .tox \ + --exclude-dir docsite \ + | grep -v \ + -e lib/ansible/compat/six/_six.py \ + -e lib/ansible/module_utils/six.py \ + -e test/sanity/code-smell/no-iterkeys.sh \ + -e '^[^:]*:#' + ) + +if [ "${ITERKEYS_USERS}" ]; then + echo 'iterkeys has been removed in python3. Use "for KEY in DICT:" instead' + echo "${ITERKEYS_USERS}" + exit 1 +fi