tests: replace pycodestyle with black
[vpp.git] / test / Makefile
index 82cef83..b416bc3 100644 (file)
@@ -73,10 +73,10 @@ V=0
 endif
 
 PYTHON_VERSION=$(shell $(PYTHON_INTERP) -c 'import sys; print(sys.version_info.major)')
-PIP_VERSION=22.0.3
+PIP_VERSION=22.0.4
 # Keep in sync with requirements.txt
-PIP_TOOLS_VERSION=6.5.0
-PIP_SETUPTOOLS_VERSION=60.7.1
+PIP_TOOLS_VERSION=6.6.0
+PIP_SETUPTOOLS_VERSION=62.1.0
 PYTHON_DEPENDS=requirements-$(PYTHON_VERSION).txt
 SCAPY_SOURCE=$(shell find $(VENV_PATH)/lib/python* -name site-packages)
 BUILD_COV_DIR=$(TEST_BR)/coverage
@@ -344,37 +344,35 @@ wipe-papi:
 wipe-all: wipe wipe-papi wipe-cov
        @rm -rf $(TEST_BR)
 
-.PHONY: checkstyle-diff
-checkstyle-diff: $(PIP_INSTALL_DONE)
-       @bash -c "source $(VENV_PATH)/bin/activate &&\
-                 python3 -m pip install pycodestyle"
-       @bash -c "source $(VENV_PATH)/bin/activate &&\
-               cd $(WS_ROOT) && git diff --name-only --no-color --relative HEAD~1 ':!*.patch' | grep '.py$$' | xargs -I XXX \
-               pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 -v XXX ||\
-               (echo \"*********************************************************************\" &&\
-                echo \"* Test framework PEP8 compliance check FAILED (checked changed files)\" &&\
-                echo \"*********************************************************************\" &&\
-                false)"
-       @echo "*********************************************************************"
-       @echo "* Test framework PEP8 compliance check passed (checked changed files)"
-       @echo "*********************************************************************"
-
 .PHONY: start-gdb
 start-gdb: sanity
        @bash -c "source $(VENV_PATH)/bin/activate && python3 -c 'from debug import start_vpp_in_gdb; start_vpp_in_gdb()' $(RUN_TESTS_ARGS)"
 
-.PHONY: checkstyle
-checkstyle: $(PIP_INSTALL_DONE)
+.PHONY: checkstyle-python-all
+checkstyle-python-all: $(PIP_INSTALL_DONE)
        @bash -c "source $(VENV_PATH)/bin/activate &&\
-                 python3 -m pip install pycodestyle"
+               black -t py39 --diff $(WS_ROOT) ||\
+               (echo \"*************************************************************************\" &&\
+               echo \"* Test framework PEP8 compliance check FAILED (maybe: make fixstyle-python)\" &&\
+               echo \"*************************************************************************\" &&\
+               false)"
+       @echo "*******************************************************************"
+       @echo "* Test framework PEP8 compliance check passed"
+       @echo "*******************************************************************"
+
+.PHONY: checkstyle
+checkstyle: checkstyle-python-all
+
+.PHONY: fixstyle-python-all
+fixstyle-python-all: $(PIP_INSTALL_DONE)
        @bash -c "source $(VENV_PATH)/bin/activate &&\
-               pycodestyle --show-source --ignore=W504,E126,E241,E226,E305,E704,E741,E722 -v *.py ||\
-               (echo \"*******************************************************************\" &&\
-                echo \"* Test framework PEP8 compliance check FAILED (checked all files)\" &&\
-                echo \"*******************************************************************\" &&\
-                false)"
+               black -t py39 $(WS_ROOT) ||\
+               (echo \"*************************************************************************\" &&\
+               echo \"* Test framework PEP8 compliance check FAILED (maybe: make fixstyle-python)\" &&\
+               echo \"*************************************************************************\" &&\
+               false)"
        @echo "*******************************************************************"
-       @echo "* Test framework PEP8 compliance check passed (checked all files)"
+       @echo "* Test framework PEP8 compliance check passed"
        @echo "*******************************************************************"
 
 .PHONY: help
@@ -397,7 +395,6 @@ help:
        @echo " test-wipe-all          - wipe (temporary) files generated by unit tests, and coverage"
        @echo " test-shell             - enter shell with test environment"
        @echo " test-shell-debug       - enter shell with test environment (debug build)"
-       @echo " test-checkstyle        - check PEP8 compliance for test framework"
        @echo " test-refresh-deps      - refresh the Python dependencies for the tests"
        @echo ""
        @echo "Arguments controlling test runs:"
@@ -456,8 +453,3 @@ help:
        @echo ""
        @echo " test-cov               - generate code coverage report for test framework"
        @echo " test-wipe-cov          - wipe code coverage report for test framework"
-       @echo ""
-       @echo "Verifying code-style:"
-       @echo ""
-       @echo " test-checkstyle        - check PEP8 compliance"
-       @echo ""