From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 44B1B5A026F for ; Tue, 27 Jun 2023 04:54:44 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Qqq7J6Mwpz4wqc; Tue, 27 Jun 2023 12:54:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1687834476; bh=0PCHvpmdTSYhZ9/xlPv82h8rxfx3jG/vRK6JrdkJTXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cg8NQTaKZVz6I1Vlb/38iUyUgUx6MScIPB2OUAHAVmpFr0IuPOrGbyi/R2W2HlZJU 4h7nQ85guzJXcCd4y5UvdkcIv2GEXVBtpCASLKNxiFlrhO4mQ0tXSRVatcVfJkenyF izwN6hhkkN/UCKpQS34LS86g2SoqW2cMpIw3k6fo= From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 05/27] avocado, test: Add static checkers for Python code Date: Tue, 27 Jun 2023 12:54:06 +1000 Message-ID: <20230627025429.2209702-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230627025429.2209702-1-david@gibson.dropbear.id.au> References: <20230627025429.2209702-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: UQA454AMWBA2S4PTBP32OYRNFYG7S22E X-Message-ID-Hash: UQA454AMWBA2S4PTBP32OYRNFYG7S22E X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: crosa@redhat.com, jarichte@redhat.com, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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