We use both cppcheck and clang-tidy to lint our C code. Now that we're
introducing Python code in the tests, use static checkers flake8 and pylint
for it too. Run them from our testsuite.
Signed-off-by: David Gibson
---
test/Makefile | 16 ++++++++++++++++
test/avocado/static_checkers/flake8.sh | 3 +++
test/avocado/static_checkers/pylint.sh | 3 +++
3 files changed, 22 insertions(+)
create mode 100755 test/avocado/static_checkers/flake8.sh
create mode 100755 test/avocado/static_checkers/pylint.sh
diff --git a/test/Makefile b/test/Makefile
index 9b3af410..00b84856 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -209,6 +209,7 @@ jammy-server-cloudimg-s390x.img:
PYTHON = python3
VENV = venv
PLUGIN = avocado_classless
+PYPKGS = $(PLUGIN)/$(PLUGIN) $(wildcard $(PLUGIN)/*.py)
# Put this back if/when the plugin becomes available in upstream/system avocado
#AVOCADO := $(shell which avocado)
@@ -219,6 +220,8 @@ endif
$(VENV):
$(PYTHON) -m venv $(VENV)
$(VENV)/bin/pip install avocado-framework
+ $(VENV)/bin/pip install flake8
+ $(VENV)/bin/pip install pylint
$(VENV)/bin/pip install -e ./$(PLUGIN)
.PHONY: avocado-assets
@@ -228,6 +231,19 @@ avocado-assets:
avocado: avocado-assets $(VENV)
$(AVOCADO) run avocado
+flake8: $(VENV)
+ $(VENV)/bin/flake8 $(PYPKGS)
+
+# pylint suppressions:
+#
+# C0116 missing-function-docstring
+# We have a bunch of trivial functions for which docstrings would be overkill
+#
+pylint: $(VENV)
+ $(VENV)/bin/pylint \
+ --disable=C0116 \
+ $(PYPKGS)
+
.PHONY: check
check: avocado check-legacy
diff --git a/test/avocado/static_checkers/flake8.sh b/test/avocado/static_checkers/flake8.sh
new file mode 100755
index 00000000..66f59fb0
--- /dev/null
+++ b/test/avocado/static_checkers/flake8.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+make flake8
diff --git a/test/avocado/static_checkers/pylint.sh b/test/avocado/static_checkers/pylint.sh
new file mode 100755
index 00000000..a52f19f8
--- /dev/null
+++ b/test/avocado/static_checkers/pylint.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+make pylint
--
2.41.0