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/shared-macros.mk | 3 +++ make-rules/setup.py.mk | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/make-rules/setup.py.mk b/make-rules/setup.py.mk index 9bbd73d..f8914a0 100644 --- a/make-rules/setup.py.mk +++ b/make-rules/setup.py.mk @@ -493,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 @@ -517,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)),"| ( \ diff --git a/make-rules/shared-macros.mk b/make-rules/shared-macros.mk index 67bc640..b4a0b31 100644 --- a/make-rules/shared-macros.mk +++ b/make-rules/shared-macros.mk @@ -98,6 +98,9 @@ empty := space := $(empty) $(empty) +# Define $(comma) as single comma so we can use it in text transforming functions +comma = , + ROOT = / # Distribution name and version -- Gitblit v1.9.3