From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A5009158089 for ; Sat, 4 Nov 2023 06:10:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 042862BC04A; Sat, 4 Nov 2023 06:09:17 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B6F722BC047 for ; Sat, 4 Nov 2023 06:09:16 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 3/6] python-utils-r1.eclass: Add EPYTEST_XDIST for epytest Date: Sat, 4 Nov 2023 07:05:12 +0100 Message-ID: <20231104060904.26947-4-mgorny@gentoo.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231104060904.26947-1-mgorny@gentoo.org> References: <20231104060904.26947-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: c6075eef-13f9-48ab-8f32-cfd8d4f69072 X-Archives-Hash: 268196c723d532ed99f6640481069fe8 Add an `EPYTEST_XDIST` variable that can be used to enable running the test suite in parallel via the dev-python/pytest-xdist plugin. This also includes user-facing `EPYTEST_JOBS` to control the job count independently of `MAKEOPTS`. Signed-off-by: Michał Górny --- eclass/python-utils-r1.eclass | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 4a538f9942f6..f2a8d4d0f65e 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1307,6 +1307,19 @@ _python_check_occluded_packages() { # parameter, when calling epytest. The listed files will be entirely # skipped from test collection. +# @VARIABLE: EPYTEST_XDIST +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set to a non-empty value, enables running tests in parallel +# via pytest-xdist plugin. + +# @VARIABLE: EPYTEST_JOBS +# @USER_VARIABLE +# @DEFAULT_UNSET +# @DESCRIPTION: +# Specifies the number of jobs for parallel (pytest-xdist) test runs. +# When unset, defaults to -j from MAKEOPTS, or the current nproc. + # @FUNCTION: epytest # @USAGE: [...] # @DESCRIPTION: @@ -1371,6 +1384,22 @@ epytest() { -p no:plus -p no:tavern ) + + if [[ ${EPYTEST_XDIST} ]]; then + local jobs=${EPYTEST_JOBS:-$(makeopts_jobs)} + if [[ ${jobs} -gt 1 ]]; then + args+=( + # explicitly enable the plugin, in case the ebuild was using + # PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 + -p xdist + -n "${jobs}" + # worksteal ensures that workers don't end up idle when heavy + # jobs are unevenly distributed + --dist=worksteal + ) + fi + fi + local x for x in "${EPYTEST_DESELECT[@]}"; do args+=( --deselect "${x}" ) -- 2.42.0