On Fri, 2019-11-15 at 17:35 +0100, Michał Górny wrote:
> Do not set IUSE or other variables if the test runner does not have
> any deps, and RDEPEND is empty.
> 
> Signed-off-by: Michał Górny <mgo...@gentoo.org>
> ---
>  eclass/distutils-r1.eclass | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
> index 99da6f5111cd..f316f85c3fc8 100644
> --- a/eclass/distutils-r1.eclass
> +++ b/eclass/distutils-r1.eclass
> @@ -255,21 +255,16 @@ distutils_enable_tests() {
>       debug-print-function ${FUNCNAME} "${@}"
>       [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: 
> test-runner"
>  
> -     [[ ${EAPI} == [56] ]] && local BDEPEND
> -
> -     IUSE+=" test"
> -     RESTRICT+=" !test? ( test )"
> -     BDEPEND+=" test? ("
> -
> +     local test_deps
>       case ${1} in
>               nose)
> -                     BDEPEND+=" dev-python/nose[${PYTHON_USEDEP}]"
> +                     test_deps="dev-python/nose[${PYTHON_USEDEP}]"
>                       python_test() {
>                               nosetests -v || die "Tests fail with ${EPYTHON}"
>                       }
>                       ;;
>               pytest)
> -                     BDEPEND+=" dev-python/pytest[${PYTHON_USEDEP}]"
> +                     test_deps="dev-python/pytest[${PYTHON_USEDEP}]"
>                       python_test() {
>                               pytest -vv || die "Tests fail with ${EPYTHON}"
>                       }
> @@ -289,9 +284,15 @@ distutils_enable_tests() {
>                       die "${FUNCNAME}: unsupported argument: ${1}"
>       esac
>  
> -     BDEPEND+=" ${RDEPEND} )"
> -
> -     [[ ${EAPI} == [56] ]] && DEPEND+=" ${BDEPEND}"
> +     if [[ -n ${test_deps} || -n ${RDEPEND} ]]; then
> +             IUSE+=" test"
> +             RESTRICT+=" !test? ( test )"
> +             if [[ ${EAPI} == [56] ]]; then
> +                     DEPEND+=" test? ( ${test_deps} ${RDEPEND} )"
> +             else
> +                     BDEPEND+=" test? ( ${test_deps} ${RDEPEND} )"
> +             fi
> +     fi
>  
>       # we need to ensure successful return in case we're called last,
>       # otherwise Portage may wrongly assume sourcing failed

I've pushed this one already since it fixes invalid dependency syntax. 
I'll resend the other two with a small change.

-- 
Best regards,
Michał Górny

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to