Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: gentoo-dev@l.g.o
Cc: devmanual@g.o
Subject: [gentoo-dev] [PATCH] Add section about defining "Test Dependencies"
Date: Fri, 24 Aug 2018 18:24:18
Message-Id: 20180824182406.17134-1-floppym@gentoo.org
1 ---
2 general-concepts/dependencies/text.xml | 38 ++++++++++++++++++++++++++
3 1 file changed, 38 insertions(+)
4
5 diff --git a/general-concepts/dependencies/text.xml b/general-concepts/dependencies/text.xml
6 index 2f10380..64be9dc 100644
7 --- a/general-concepts/dependencies/text.xml
8 +++ b/general-concepts/dependencies/text.xml
9 @@ -578,6 +578,44 @@ valid.
10 </body>
11 </section>
12
13 +<section>
14 +<title>Test Dependencies</title>
15 +<body>
16 +
17 +<p>
18 +Packages often have optional dependencies that are needed only when running
19 +tests. These should be specified in DEPEND behind a USE flag. Often, the
20 +'test' USE flag is used for this purpose.
21 +</p>
22 +
23 +<p>
24 +Since testing will likely fail when test dependencies are not installed, the
25 +test phase should be disabled in this case. This may be accomplished via USE
26 +conditionals in the RESTRICT variable.
27 +</p>
28 +
29 +<p>
30 +If other optional features must be enabled/disabled when testing, REQUIRED_USE
31 +may be set to express this.
32 +</p>
33 +
34 +<codesample lang="ebuild">
35 +# Define some USE flags
36 +IUSE="debug test"
37 +
38 +# Disable test phase when test USE flag is disabled
39 +RESTRICT="!test? ( test )"
40 +
41 +# Running tests requires 'foo' to be installed
42 +DEPEND="test? ( dev-util/foo )"
43 +
44 +# Require debug support when tests are enabled
45 +REQUIRED_USE="test? ( debug )"
46 +</codesample>
47 +
48 +</body>
49 +</section>
50 +
51 </body>
52 </chapter>
53 </guide>
54 --
55 2.18.0

Replies

Subject Author
Re: [gentoo-dev] [PATCH] Add section about defining "Test Dependencies" Andrew Savchenko <bircoph@g.o>