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 29E2F15803E for ; Thu, 4 Jan 2024 17:10:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7E9462BC04F; Thu, 4 Jan 2024 17:09:47 +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)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 29F882BC04C for ; Thu, 4 Jan 2024 17:09:47 +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/5] python-utils-r1.eclass, distutils-r1.eclass: Add EPYTEST_TIMEOUT Date: Thu, 4 Jan 2024 18:09:32 +0100 Message-ID: <20240104170934.106565-3-mgorny@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240104170934.106565-1-mgorny@gentoo.org> References: <20240104170934.106565-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: 800f2344-f907-41fd-b67b-02cbd9d5d486 X-Archives-Hash: 1b7d911c4b85b1eb42f0e859597d123c Signed-off-by: Michał Górny --- eclass/distutils-r1.eclass | 3 +++ eclass/python-utils-r1.eclass | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 4e77237c3009..014669c8c47c 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -618,6 +618,9 @@ distutils_enable_tests() { ;; pytest) test_pkgs='>=dev-python/pytest-7.3.1[${PYTHON_USEDEP}]' + if [[ -n ${EPYTEST_TIMEOUT} ]]; then + test_pkgs+=' dev-python/pytest-timeout[${PYTHON_USEDEP}]' + fi if [[ ${EPYTEST_XDIST} ]]; then test_pkgs+=' dev-python/pytest-xdist[${PYTHON_USEDEP}]' fi diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 27fb92a75aca..22ab778b7e11 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1296,6 +1296,16 @@ _python_check_occluded_packages() { # parameter, when calling epytest. The listed files will be entirely # skipped from test collection. +# @ECLASS_VARIABLE: EPYTEST_TIMEOUT +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set to a non-empty value, enables pytest-timeout plugin and sets +# test timeout to the specified value. This variable can be either set +# in ebuilds that are known to hang, or by user to prevent hangs +# in automated test environments. If this variable is set prior +# to calling distutils_enable_tests in distutils-r1, a test dependency +# on dev-python/pytest-timeout is added automatically. + # @ECLASS_VARIABLE: EPYTEST_XDIST # @DEFAULT_UNSET # @DESCRIPTION: @@ -1381,6 +1391,18 @@ epytest() { ) fi + if [[ -n ${EPYTEST_TIMEOUT} ]]; then + if [[ ${PYTEST_PLUGINS} != *pytest_timeout* ]]; then + args+=( + -p timeout + ) + fi + + args+=( + "--timeout=${EPYTEST_TIMEOUT}" + ) + fi + if [[ ${EPYTEST_XDIST} ]]; then local jobs=${EPYTEST_JOBS:-$(makeopts_jobs)} if [[ ${jobs} -gt 1 ]]; then -- 2.43.0