From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1624922-garchives=archives.gentoo.org@lists.gentoo.org>
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 9AC481581E7
	for <garchives@archives.gentoo.org>; Thu, 25 Apr 2024 20:43:49 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id D9ED8E29AA;
	Thu, 25 Apr 2024 20:43:48 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(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 BF6D1E29AA
	for <gentoo-commits@lists.gentoo.org>; Thu, 25 Apr 2024 20:43:48 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(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 smtp.gentoo.org (Postfix) with ESMTPS id 0A3A5343117
	for <gentoo-commits@lists.gentoo.org>; Thu, 25 Apr 2024 20:43:48 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 970A21625
	for <gentoo-commits@lists.gentoo.org>; Thu, 25 Apr 2024 20:43:46 +0000 (UTC)
From: "Andreas Sturmlechner" <asturm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Andreas Sturmlechner" <asturm@gentoo.org>
Message-ID: <1714077757.70a0b3a104fbce20ee72549dbc3f96115dce5c46.asturm@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
X-VCS-Repository: repo/gentoo
X-VCS-Files: eclass/ecm.eclass
X-VCS-Directories: eclass/
X-VCS-Committer: asturm
X-VCS-Committer-Name: Andreas Sturmlechner
X-VCS-Revision: 70a0b3a104fbce20ee72549dbc3f96115dce5c46
X-VCS-Branch: master
Date: Thu, 25 Apr 2024 20:43:46 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 0db77767-94d4-4963-a18f-22e3c6fa4760
X-Archives-Hash: 2503321959bdf15688e9e229e0e5ff41

commit:     70a0b3a104fbce20ee72549dbc3f96115dce5c46
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  4 14:17:19 2024 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 20:42:37 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=70a0b3a1

ecm.eclass: Restrict ECM_TEST="optional" and punting dep to _KFSLOT=5

In dev-qt/qtbase:6, Qt6Test is always provided so it makes no sense to
go through the trouble of ripping out the build dependency.

We should still aim to avoid needless building of tests if not requested,
either by detecting unconditional use of ecm_add_test or expose existing
force* logic to ebuild developers to catch those as errors.

Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 eclass/ecm.eclass | 50 +++++++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/eclass/ecm.eclass b/eclass/ecm.eclass
index d83320e991ed..6d64815984cc 100644
--- a/eclass/ecm.eclass
+++ b/eclass/ecm.eclass
@@ -125,20 +125,21 @@ fi
 # @ECLASS_VARIABLE: ECM_TEST
 # @DEFAULT_UNSET
 # @DESCRIPTION:
-# Will accept "true", "false", "optional", "forceoptional",
-# "forceoptional-recursive".
+# Will accept "true", "false", "forceoptional", and "forceoptional-recursive".
+# For KF5-based ebuilds, additionally accepts "optional".
 # Default value is "false", except for CATEGORY=kde-frameworks where it is
 # set to "true". If set to "false", do nothing.
-# For any other value, add "test" to IUSE (and for KF5 DEPEND on
-# dev-qt/qttest:5). If set to "optional", build with
-# -DCMAKE_DISABLE_FIND_PACKAGE_Qt${_KFSLOT}Test=ON when USE=!test. If set
-# to "forceoptional", punt Qt${_KFSLOT}Test dependency and ignore "autotests",
-# "test", "tests" subdirs from top-level CMakeLists.txt when USE=!test.
-# If set to "forceoptional-recursive", punt Qt${_KFSLOT}Test dependencies and
-# make autotest(s), unittest(s) and test(s) subdirs from *any* CMakeLists.txt
-# in ${S} and below conditional on BUILD_TESTING when USE=!test. This is always
-# meant as a short-term fix and creates ${T}/${P}-tests-optional.patch to
-# refine and submit upstream.
+# For any other value, add "test" to IUSE. If set to "forceoptional", ignore
+# "autotests", "test", "tests" subdirs from top-level CMakeLists.txt when
+# USE=!test. If set to "forceoptional-recursive", make autotest(s), unittest(s)
+# and test(s) subdirs from *any* CMakeLists.txt in ${S} and below conditional
+# on BUILD_TESTING when USE=!test. This is always meant as a short-term fix and
+# creates ${T}/${P}-tests-optional.patch to refine and submit upstream.
+# For KF5-based ebuilds:
+# Additionally DEPEND on dev-qt/qttest:5 if USE=test, but punt Qt5Test
+# dependency if set to "forceoptional*" with USE=!test.
+# If set to "optional", build with -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON
+# when USE=!test.
 if [[ ${CATEGORY} = kde-frameworks ]]; then
 	: "${ECM_TEST:=true}"
 fi
@@ -258,13 +259,13 @@ case ${ECM_QTHELP} in
 esac
 
 case ${ECM_TEST} in
-	true|optional|forceoptional|forceoptional-recursive)
-		IUSE+=" test"
-		if [[ ${_KFSLOT} == 5 ]]; then
-			DEPEND+=" test? ( dev-qt/qttest:${_KFSLOT} )"
+	optional)
+		if [[ ${_KFSLOT} != 5 ]]; then
+			eerror "Banned value for \${ECM_TEST}"
+			die "Value ${ECM_TEST} is only supported in KF5"
 		fi
-		RESTRICT+=" !test? ( test )"
 		;;
+	true|forceoptional|forceoptional-recursive) ;;
 	false) ;;
 	*)
 		eerror "Unknown value for \${ECM_TEST}"
@@ -277,10 +278,17 @@ BDEPEND+="
 	>=kde-frameworks/extra-cmake-modules-${KFMIN}:*
 "
 RDEPEND+=" >=kde-frameworks/kf-env-4"
+if [[ ${ECM_TEST} != false ]]; then
+	IUSE+=" test"
+	RESTRICT+=" !test? ( test )"
+fi
 if [[ ${_KFSLOT} == 6 ]]; then
 	COMMONDEPEND+=" dev-qt/qtbase:${_KFSLOT}"
 else
 	COMMONDEPEND+=" dev-qt/qtcore:${_KFSLOT}"
+	if [[ ${ECM_TEST} != false ]]; then
+		DEPEND+=" test? ( dev-qt/qttest:5 )"
+	fi
 fi
 
 DEPEND+=" ${COMMONDEPEND}"
@@ -498,11 +506,11 @@ ecm_src_prepare() {
 	# only build unit tests when required
 	if ! { in_iuse test && use test; } ; then
 		if [[ ${ECM_TEST} = forceoptional ]] ; then
-			ecm_punt_qt_module Test
+			[[ ${_KFSLOT} = 5 ]] && ecm_punt_qt_module Test
 			# if forceoptional, also cover non-kde categories
 			cmake_comment_add_subdirectory autotests test tests
 		elif [[ ${ECM_TEST} = forceoptional-recursive ]] ; then
-			ecm_punt_qt_module Test
+			[[ ${_KFSLOT} = 5 ]] && ecm_punt_qt_module Test
 			local f pf="${T}/${P}"-tests-optional.patch
 			touch ${pf} || die "Failed to touch patch file"
 			for f in $(find . -type f -name "CMakeLists.txt" -exec \
@@ -552,8 +560,8 @@ ecm_src_configure() {
 	if in_iuse test && ! use test ; then
 		cmakeargs+=( -DBUILD_TESTING=OFF )
 
-		if [[ ${ECM_TEST} = optional ]] ; then
-			cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_Qt${_KFSLOT}Test=ON )
+		if [[ ${_KFSLOT} = 5 && ${ECM_TEST} = optional ]] ; then
+			cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON )
 		fi
 	fi