Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 860072 - ruby-ng.eclass should not force adding 'test' to IUSE when adding an RDEPEND
Summary: ruby-ng.eclass should not force adding 'test' to IUSE when adding an RDEPEND
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-22 11:45 UTC by konsolebox
Modified: 2022-07-28 11:34 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description konsolebox 2022-07-22 11:45:44 UTC
In https://github.com/gentoo/gentoo/blob/3a7d6bc69a8f49ac4e2c9b3953b1d867e4ef8c37/eclass/ruby-ng.eclass#L242, instead of adding 'test' to IUSE when it's not assigned, it's probably better to only add the test? dependencies when 'test' has been assigned in IUSE instead.

This will not force 'test' to always exist in gems that rely on ruby-fakegem.eclas because of 'ruby_add_rdepend virtual/rubygems' unlike how it is right now.

I checked ruby-fakegem.eclass and it only calls ruby_add_*depend after test has been conditionally assigned to IUSE.  A sensible ebuild that doesn't rely on ruby-fakegem.eclass will also only call the function after declaring the value of IUSE.

diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
index 70cb5be74b87..3126ba09be6c 100644
--- a/eclass/ruby-ng.eclass
+++ b/eclass/ruby-ng.eclass
@@ -233,16 +233,16 @@ ruby_add_rdepend() {
 
	RDEPEND="${RDEPEND} $dependency"
 
-	# Add the dependency as a test-dependency since we're going to
-	# execute the code during test phase.
-	case ${EAPI} in
-		5|6) DEPEND="${DEPEND} test? ( ${dependency} )" ;;
-		*) BDEPEND="${BDEPEND} test? ( ${dependency} )" ;;
-	esac
-	if ! has test "$IUSE"; then
-		IUSE+=" test"
-		RESTRICT+=" !test? ( test )"
+	if has test "$IUSE"; then
+		# Add the dependency as a test-dependency since we're going to
+		# execute the code during test phase.
+		case ${EAPI} in
+			5|6) DEPEND="${DEPEND} test? ( ${dependency} )" ;;
+			*) BDEPEND="${BDEPEND} test? ( ${dependency} )" ;;
+		esac
	fi
+
+	[[ " ${RESTRICT} " != *" !test? ( test ) "* ]] && RESTRICT+=" !test? ( test )"
 }
 
 # @FUNCTION: ruby_add_bdepend
Comment 1 konsolebox 2022-07-22 12:18:13 UTC
Last line should probably be placed inside the `if has test ...` block as well.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-26 03:17:02 UTC
The idea is that you always need runtime dependencies at test time so it's doing DEPEND="test? ( ${RDEPEND} )".

Python packages do the same if using d_e_t.
Comment 3 Hans de Graaff gentoo-dev Security 2022-07-28 10:53:54 UTC
What problem are you trying to fix here? I'm not sure what problem the existing situation would cause or what approaches this would be blocking.
Comment 4 konsolebox 2022-07-28 11:28:29 UTC
(In reply to Sam James from comment #2)
> The idea is that you always need runtime dependencies at test time so it's
> doing DEPEND="test? ( ${RDEPEND} )".
> 
> Python packages do the same if using d_e_t.

That's ok but the problem is about test being forced as an IUSE even in packages that don't want or can't have it; not the dependencies being forced to 'test'.
Comment 5 konsolebox 2022-07-28 11:34:53 UTC
(In reply to Hans de Graaff from comment #3)
> What problem are you trying to fix here? I'm not sure what problem the
> existing situation would cause or what approaches this would be blocking.

No situation.  Just troublesome inconsistency that made me check the eclasses plenty of times already.  If the ebuild doesn't provide a test, 'test' shouldn't be forced in it and appear in `emerge -v`.