Gentoo Archives: gentoo-dev

From: Andrew Savchenko <bircoph@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] Add section about defining "Test Dependencies"
Date: Sat, 25 Aug 2018 05:42:30
Message-Id: 20180825084157.5488c8fd6f803834a9134814@gentoo.org
In Reply to: [gentoo-dev] [PATCH] Add section about defining "Test Dependencies" by Mike Gilbert
1 On Fri, 24 Aug 2018 14:24:06 -0400 Mike Gilbert wrote:
2 > ---
3 > general-concepts/dependencies/text.xml | 38 ++++++++++++++++++++++++++
4 > 1 file changed, 38 insertions(+)
5 >
6 > diff --git a/general-concepts/dependencies/text.xml b/general-concepts/dependencies/text.xml
7 > index 2f10380..64be9dc 100644
8 > --- a/general-concepts/dependencies/text.xml
9 > +++ b/general-concepts/dependencies/text.xml
10 > @@ -578,6 +578,44 @@ valid.
11 > </body>
12 > </section>
13 >
14 > +<section>
15 > +<title>Test Dependencies</title>
16 > +<body>
17 > +
18 > +<p>
19 > +Packages often have optional dependencies that are needed only when running
20 > +tests. These should be specified in DEPEND behind a USE flag. Often, the
21 > +'test' USE flag is used for this purpose.
22 > +</p>
23 > +
24 > +<p>
25 > +Since testing will likely fail when test dependencies are not installed, the
26 > +test phase should be disabled in this case. This may be accomplished via USE
27 > +conditionals in the RESTRICT variable.
28 > +</p>
29 > +
30 > +<p>
31 > +If other optional features must be enabled/disabled when testing, REQUIRED_USE
32 > +may be set to express this.
33 > +</p>
34 > +
35 > +<codesample lang="ebuild">
36 > +# Define some USE flags
37 > +IUSE="debug test"
38 > +
39 > +# Disable test phase when test USE flag is disabled
40 > +RESTRICT="!test? ( test )"
41
42 I do not understand why we need this useless code. If test USE flag
43 is disabled, tests must be disabled as well. It is PM's job and
44 there is no need to put this obvious stuff into each ebuild with
45 tests and extra deps. I see no reason to support running src_test()
46 with USE="-test".
47
48 > +# Running tests requires 'foo' to be installed
49 > +DEPEND="test? ( dev-util/foo )"
50 > +
51 > +# Require debug support when tests are enabled
52 > +REQUIRED_USE="test? ( debug )"
53 > +</codesample>
54 > +
55 > +</body>
56 > +</section>
57 > +
58 > </body>
59 > </chapter>
60 > </guide>
61
62
63 Best regards,
64 Andrew Savchenko

Replies