format-code.sh: Add pycodestyle (pep8) check
Check pycodestyle (former pep8) and exit if there are any
errors.
Also move the checking of the formatting files to the
format-code.sh file.
Change-Id: Idca20d145e36a471634666aa39c968d3542886d8
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
old mode 100644
new mode 100755
index b7db2da..0cd6a71
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -13,6 +13,17 @@
cd ${DIR}
echo "Formatting code under $DIR/"
-find . -regextype sed -regex ".*\.[hc]\(pp\)\?" -not -name "*mako*" -print0 | xargs -0 "clang-format-5.0" -i
-git --no-pager diff --exit-code
+if [ -f "setup.cfg" ]; then
+ pycodestyle --show-source .
+ rc=$?
+ if [ ${rc} -ne 0 ]; then
+ exit ${rc}
+ fi
+fi
+
+if [ -f ".clang-format" ]; then
+ find . -regextype sed -regex ".*\.[hc]\(pp\)\?" -not -name "*mako*" -print0 |\
+ xargs -0 "clang-format-5.0" -i
+ git --no-pager diff --exit-code
+fi
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index f526c9a..5739d55 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -394,10 +394,10 @@
else:
printline = lambda *l: None
- # First validate code formattting if repo has clang file
+ # First validate code formattting if repo has style formatting files.
+ # The format-code.sh checks for these files.
CODE_SCAN_DIR = WORKSPACE + "/" + UNIT_TEST_PKG
- if os.path.exists(CODE_SCAN_DIR + "/.clang-format"):
- check_call_cmd(WORKSPACE, "./format-code.sh", CODE_SCAN_DIR)
+ check_call_cmd(WORKSPACE, "./format-code.sh", CODE_SCAN_DIR)
prev_umask = os.umask(000)
# Determine dependencies and add them