Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: python@g.o
Subject: Re: [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: distutils_enable_tests, handle no deps better
Date: Sat, 16 Nov 2019 11:03:13
Message-Id: 200161490246735c90fd8cf8eada4210447d881d.camel@gentoo.org
In Reply to: [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: distutils_enable_tests, handle no deps better by "Michał Górny"
1 On Fri, 2019-11-15 at 17:35 +0100, Michał Górny wrote:
2 > Do not set IUSE or other variables if the test runner does not have
3 > any deps, and RDEPEND is empty.
4 >
5 > Signed-off-by: Michał Górny <mgorny@g.o>
6 > ---
7 > eclass/distutils-r1.eclass | 23 ++++++++++++-----------
8 > 1 file changed, 12 insertions(+), 11 deletions(-)
9 >
10 > diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
11 > index 99da6f5111cd..f316f85c3fc8 100644
12 > --- a/eclass/distutils-r1.eclass
13 > +++ b/eclass/distutils-r1.eclass
14 > @@ -255,21 +255,16 @@ distutils_enable_tests() {
15 > debug-print-function ${FUNCNAME} "${@}"
16 > [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner"
17 >
18 > - [[ ${EAPI} == [56] ]] && local BDEPEND
19 > -
20 > - IUSE+=" test"
21 > - RESTRICT+=" !test? ( test )"
22 > - BDEPEND+=" test? ("
23 > -
24 > + local test_deps
25 > case ${1} in
26 > nose)
27 > - BDEPEND+=" dev-python/nose[${PYTHON_USEDEP}]"
28 > + test_deps="dev-python/nose[${PYTHON_USEDEP}]"
29 > python_test() {
30 > nosetests -v || die "Tests fail with ${EPYTHON}"
31 > }
32 > ;;
33 > pytest)
34 > - BDEPEND+=" dev-python/pytest[${PYTHON_USEDEP}]"
35 > + test_deps="dev-python/pytest[${PYTHON_USEDEP}]"
36 > python_test() {
37 > pytest -vv || die "Tests fail with ${EPYTHON}"
38 > }
39 > @@ -289,9 +284,15 @@ distutils_enable_tests() {
40 > die "${FUNCNAME}: unsupported argument: ${1}"
41 > esac
42 >
43 > - BDEPEND+=" ${RDEPEND} )"
44 > -
45 > - [[ ${EAPI} == [56] ]] && DEPEND+=" ${BDEPEND}"
46 > + if [[ -n ${test_deps} || -n ${RDEPEND} ]]; then
47 > + IUSE+=" test"
48 > + RESTRICT+=" !test? ( test )"
49 > + if [[ ${EAPI} == [56] ]]; then
50 > + DEPEND+=" test? ( ${test_deps} ${RDEPEND} )"
51 > + else
52 > + BDEPEND+=" test? ( ${test_deps} ${RDEPEND} )"
53 > + fi
54 > + fi
55 >
56 > # we need to ensure successful return in case we're called last,
57 > # otherwise Portage may wrongly assume sourcing failed
58
59 I've pushed this one already since it fixes invalid dependency syntax.
60 I'll resend the other two with a small change.
61
62 --
63 Best regards,
64 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature