From d6ccb6ab62f2f8726859d4d567e79af34435042f Mon Sep 17 00:00:00 2001 From: Marcel Telka <marcel@telka.sk> Date: Mon, 08 Apr 2024 18:47:42 +0200 Subject: [PATCH] setup.py.mk: sort test results with pytest-randomly only --- make-rules/setup.py.mk | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/make-rules/setup.py.mk b/make-rules/setup.py.mk index 028e955..f8914a0 100644 --- a/make-rules/setup.py.mk +++ b/make-rules/setup.py.mk @@ -465,12 +465,11 @@ $(eval $(call disable-pytest-plugin,socket,pytest-socket)) $(eval $(call disable-pytest-plugin,subprocess,pytest-subprocess)) $(eval $(call disable-pytest-plugin,subtests,pytest-subtests)) -$(eval $(call disable-pytest-plugin,tempdir,pytest-tempdir)) # adds line to test report header +$(eval $(call disable-pytest-plugin,system-statistics,pytest-system-statistics)) $(eval $(call disable-pytest-plugin,time_machine,time-machine)) $(eval $(call disable-pytest-plugin,timeout,pytest-timeout)) $(eval $(call disable-pytest-plugin,travis-fold,pytest-travis-fold)) $(eval $(call disable-pytest-plugin,typeguard,typeguard)) -$(eval $(call disable-pytest-plugin,unittest_mock,backports-unittest-mock)) $(eval $(call disable-pytest-plugin,xdist,pytest-xdist)) $(eval $(call disable-pytest-plugin,xdist.looponfail,pytest-xdist)) $(eval $(call disable-pytest-plugin,xprocess,pytest-xprocess)) # adds a reminder line to test output @@ -494,17 +493,9 @@ # unconditionally. COMPONENT_TEST_TRANSFORMS += \ "-e 's/^\(platform sunos5 -- Python \)$(shell echo $(PYTHON_VERSION) | $(GSED) -e 's/\./\\./g')\.[0-9]\{1,\}.*\( -- .*\)/\1\$$(PYTHON_VERSION).X\2/'" -COMPONENT_TEST_TRANSFORMS += "-e '/^Using --randomly-seed=[0-9]\{1,\}$$/d'" # this is random COMPONENT_TEST_TRANSFORMS += "-e '/^plugins: /d'" # order of listed plugins could vary COMPONENT_TEST_TRANSFORMS += "-e '/^-\{1,\} coverage: /,/^$$/d'" # remove coverage report -# sort list of pytest unit tests and drop percentage -COMPONENT_TEST_TRANSFORMS += \ - "| ( \ - $(GSED) -u -e '/^=\{1,\} test session starts /q' ; \ - $(GSED) -u -e '/^$$/q' ; \ - $(GSED) -u -e 's/ *\[...%\]$$//' -e '/^$$/Q' | $(SORT) | $(NAWK) '{print}END{if(NR>0)printf(\"\\\\n\")}' ; \ - $(CAT) \ - ) | $(COMPONENT_TEST_TRANSFORMER)" +COMPONENT_TEST_TRANSFORMS += "-e 's/ \{1,\}\[...%\]\$$//'" # drop percentage COMPONENT_TEST_TRANSFORMS += \ "-e 's/^=\{1,\} \(.*\) in [0-9]\{1,\}\.[0-9]\{1,\}s \(([^)]*) \)\?=\{1,\}$$/======== \1 ========/'" # remove timing # Remove slowest durations report for projects that run pytest with --durations option @@ -518,6 +509,18 @@ $(GSED) -e '/^-\{1,\} benchmark/,/^=/{/^=/!d}' \ ) | $(COMPONENT_TEST_TRANSFORMER) -e ''") +# Normalize test results produced by pytest-randomly +USE_PYTEST_RANDOMLY = $(filter library/python/pytest-randomly-$(subst .,,$(PYTHON_VERSION)), $(REQUIRED_PACKAGES) $(TEST_REQUIRED_PACKAGES)) +PYTEST_SORT_TESTS = $(USE_PYTEST_RANDOMLY) +COMPONENT_TEST_TRANSFORMS += $(if $(strip $(USE_PYTEST_RANDOMLY)),"-e '/^Using --randomly-seed=[0-9]\{1$(comma)\}\$$/d'") +COMPONENT_TEST_TRANSFORMS += \ + $(if $(strip $(PYTEST_SORT_TESTS)),"| ( \ + $(GSED) -u -e '/^=\{1$(comma)\} test session starts /q' ; \ + $(GSED) -u -e '/^\$$/q' ; \ + $(GSED) -u -e '/^\$$/Q' | $(SORT) | $(GSED) -e '\$$a\'\$$'\\\n\\\n' ; \ + $(CAT) \ + ) | $(COMPONENT_TEST_TRANSFORMER) -e ''") + # Normalize test results produced by pytest-xdist COMPONENT_TEST_TRANSFORMS += \ $(if $(filter library/python/pytest-xdist-$(subst .,,$(PYTHON_VERSION)), $(REQUIRED_PACKAGES) $(TEST_REQUIRED_PACKAGES)),"| ( \ -- Gitblit v1.9.3