Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 664104 - FEATURES=test from package.env is ignored when RESTRICT="!test? ( test )" is set
Summary: FEATURES=test from package.env is ignored when RESTRICT="!test? ( test )" is set
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS, REGRESSION
Depends on:
Blocks: 912975 659322
  Show dependency tree
 
Reported: 2018-08-20 13:38 UTC by Michał Górny
Modified: 2023-08-24 20:27 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 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-08-20 13:38:28 UTC
if has test ${FEATURES} && \
    use server && ! has userpriv ${FEATURES} ; then
      eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
      die "FEATURES=test with FEATURES=-userpriv is not supported"
  fi

  if has test ${FEATURES} && ! use test ; then
    eerror "FEATURES=test requires USE=test."
    die "FEATURES=test set but not USE=test"
  fi

FEATURES=test is entirely Portage-specific and testing for it is just plain wrong.  The whole purpose of USE=test is to provide quasi-PM-agnostic way of controlling test support.

What you should do instead is:

1. RESTRICT="!test? ( test )"

2. Check for 'use test' in the first conditional, and remove the second die.
Comment 1 Thomas Deutschmann (RETIRED) gentoo-dev 2018-08-20 14:02:55 UTC
This was added on purpose. I changed the ebuild like you have requested:

> diff --git a/dev-db/percona-server/percona-server-5.6.41.84.1.ebuild b/dev-db/percona-server/percona-server-5.6.41.84.1.ebuild
> index a46ac7790a75..0f90f84fff87 100644
> --- a/dev-db/percona-server/percona-server-5.6.41.84.1.ebuild
> +++ b/dev-db/percona-server/percona-server-5.6.41.84.1.ebuild
> @@ -35,7 +35,8 @@ IUSE="-client-libs cracklib debug jemalloc latin1 libressl numa pam +perl profil
>         +server static static-libs systemtap tcmalloc test test-suite tokudb tokudb-backup-plugin yassl"
> 
>  # Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
> -RESTRICT="libressl? ( test )"
> +RESTRICT="libressl? ( test )
> +       !test? ( test )"
> 
>  REQUIRED_USE="tokudb-backup-plugin? ( tokudb ) tokudb? ( jemalloc !tcmalloc ) ?? ( tcmalloc jemalloc ) static? ( yassl )"
> 
> @@ -210,17 +211,6 @@ pkg_setup() {
>                         die "Unsupported GCC version"
>                 fi
> 
> -               if has test ${FEATURES} && \
> -                       use server && ! has userpriv ${FEATURES} ; then
> -                               eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
> -                               die "FEATURES=test with FEATURES=-userpriv is not supported"
> -               fi
> -
> -               if has test ${FEATURES} && ! use test ; then
> -                       eerror "FEATURES=test requires USE=test."
> -                       die "FEATURES=test set but not USE=test"
> -               fi
> -
>                 use test && python-any-r1_pkg_setup
>         fi
> 


Pre requirement: dev-python/mysql-python is not installed

When I now call

`FEATURES="test" USE="-test" ebuild percona-server-5.6.41.84.1.ebuild clean install`

code like

> use test && python-any-r1_pkg_setup

or

>         if use test || use test-suite ; then
>                 mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
>         else

won't run with the result that a missing Python dep isn't detected (i.e. I would expect an error like "No supported Python implementation installed") and test suite isn't available in src_test phase.

Same when running through `emerge` instead of `ebuild` with just FEATURES=test set but *no* USE=test.

That's why I added a check that checks if USE=test is set when FEATURES=test is used.

I am testing with current portage git master (5a1528ee9b1246836c7cd066cc4506820a9a5a23).
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-08-20 14:28:26 UTC
This is intentional.  You can use USE=test to pull all the dependencies and do all the extra test preparation stuff, e.g. to check if tests compile without actually spending time to running them.
Comment 3 Larry the Git Cow gentoo-dev 2018-08-20 19:45:16 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f53741fd866b410509e007d666cd1b7e39ea4871

commit f53741fd866b410509e007d666cd1b7e39ea4871
Author:     Thomas Deutschmann <whissi@gentoo.org>
AuthorDate: 2018-08-20 19:44:30 +0000
Commit:     Thomas Deutschmann <whissi@gentoo.org>
CommitDate: 2018-08-20 19:44:30 +0000

    dev-db/percona-server: remove FEATURES check
    
    Bug: https://bugs.gentoo.org/664104
    Package-Manager: Portage-2.3.47, Repoman-2.3.10

 dev-db/percona-server/percona-server-5.6.41.84.1.ebuild | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2018-08-20 20:47:58 UTC
Assigning to portage for further investigation.

> # grep -Fr percona /etc/portage/
> /etc/portage/package.use:dev-db/percona-server -pam ssl -extraengine jemalloc
> /etc/portage/package.env:dev-db/percona-server run-tests.conf

> # cat /etc/portage/env/run-tests.conf
> FEATURES="${FEATURES} test"

> # equery uses percona-server
> [...]
> + - jemalloc
> + - perl
> + - server
> - - test
> [...]

> # emerge -p percona-server
> 
> These are the packages that would be merged, in order:
> 
> Calculating dependencies... done!
> [ebuild  N     ] dev-db/mysql-init-scripts-2.2-r3::gentoo  0 KiB
> [ebuild  N     ] dev-db/percona-server-5.6.41.84.1:0/18::gentoo  USE="jemalloc perl server (-client-libs) -cracklib -debug -latin1 -libressl -numa -pam -profiling -rocksdb (-selinux) -static -static-libs -systemtap -tcmalloc -test -test-suite -tokudb -tokudb-backup-plugin -yassl" ABI_X86="(64) -32 (-x32)" 0 KiB

So USE=test isn't set which is unexpected because FEATURES=test is set via package.env which should also enable USE=test.
Maybe package.env isn't used somehow?

> # FEATURES=test emerge -p percona-server
> 
> These are the packages that would be merged, in order:
> 
> Calculating dependencies... done!
> 
> 
> [nomerge       ] dev-db/percona-server-5.6.41.84.1:0/18::gentoo  USE="jemalloc perl server test (-client-libs) -cracklib -debug -latin1 -libressl -numa -pam -profiling -rocksdb (-selinux) -static -static-libs -systemtap -tcmalloc -test-suite -tokudb -tokudb-backup-plugin -yassl" ABI_X86="(64) -32 (-x32)"
> [ebuild  N     ]  dev-python/mysql-python-1.2.5-r1::gentoo  USE="-doc" PYTHON_TARGETS="python2_7 -pypy" 0 KiB
> [ebuild  N     ]   virtual/mysql-5.6-r12:0/18::gentoo  USE="server (-embedded) -static" 0 KiB
> [ebuild  N     ]    dev-db/percona-server-5.6.41.84.1:0/18::gentoo  USE="jemalloc perl server test (-client-libs) -cracklib -debug -latin1 -libressl -numa -pam -profiling -rocksdb (-selinux) -static -static-libs -systemtap -tcmalloc -test-suite -tokudb -tokudb-backup-plugin -yassl" ABI_X86="(64) -32 (-x32)" 0 KiB

Bingo! Looks like package.env is getting ignored.

But when I now remove 'RESTRICT="!test? ( test )"', i.e.

> --- a/dev-db/percona-server/percona-server-5.6.41.84.1.ebuild
> +++ b/dev-db/percona-server/percona-server-5.6.41.84.1.ebuild
> @@ -35,8 +35,7 @@ IUSE="-client-libs cracklib debug jemalloc latin1 libressl numa pam +perl profil
>         +server static static-libs systemtap tcmalloc test test-suite tokudb tokudb-backup-plugin yassl"
> 
>  # Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
> -RESTRICT="libressl? ( test )
> -       !test? ( test )"
> +RESTRICT="libressl? ( test )"
> 
>  REQUIRED_USE="tokudb-backup-plugin? ( tokudb ) tokudb? ( jemalloc !tcmalloc ) ?? ( tcmalloc jemalloc ) static? ( yassl )"

then package.env is respected:

> # emerge -p percona-server
> 
> These are the packages that would be merged, in order:
> 
> Calculating dependencies... done!
> 
> 
> [nomerge       ] dev-db/percona-server-5.6.41.84.1:0/18::gentoo  USE="jemalloc perl server test (-client-libs) -cracklib -debug -latin1 -libressl -numa -pam -profiling -rocksdb (-selinux) -static -static-libs -systemtap -tcmalloc -test-suite -tokudb -tokudb-backup-plugin -yassl" ABI_X86="(64) -32 (-x32)"
> [ebuild  N     ]  dev-python/mysql-python-1.2.5-r1::gentoo  USE="-doc" PYTHON_TARGETS="python2_7 -pypy" 0 KiB
> [ebuild  N     ]   virtual/mysql-5.6-r12:0/18::gentoo  USE="server (-embedded) -static" 0 KiB
> [ebuild  N     ]    dev-db/percona-server-5.6.41.84.1:0/18::gentoo  USE="jemalloc perl server test (-client-libs) -cracklib -debug -latin1 -libressl -numa -pam -profiling -rocksdb (-selinux) -static -static-libs -systemtap -tcmalloc -test-suite -tokudb -tokudb-backup-plugin -yassl" ABI_X86="(64) -32 (-x32)" 0 KiB

And when I now remove "dev-db/percona-server run-tests.conf" line from package.env file, the output is expected:

> # emerge -p percona-server
> 
> These are the packages that would be merged, in order:
> 
> Calculating dependencies... done!
> [ebuild  N     ] dev-db/mysql-init-scripts-2.2-r3::gentoo  0 KiB
> [ebuild  N     ] dev-db/percona-server-5.6.41.84.1:0/18::gentoo  USE="jemalloc perl server (-client-libs) -cracklib -debug -latin1 -libressl -numa -pam -profiling -rocksdb (-selinux) -static -static-libs -systemtap -tcmalloc -test -test-suite -tokudb -tokudb-backup-plugin -yassl" ABI_X86="(64) -32 (-x32)" 0 KiB

=> So it seems like 'RESTRICT="!test? ( test )"' causes portage to ignore package.env.


As said, I am testing with current portage git master (5a1528ee9b1246836c7cd066cc4506820a9a5a23).
Comment 5 Zac Medico gentoo-dev 2018-08-20 21:47:48 UTC
The USE flags need to be re-calculated one more time before evaluation of conditional RESTRICT.
Comment 6 Larry the Git Cow gentoo-dev 2018-08-20 23:11:17 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=cbe6f8cac95f5db7b35018a01c56dc3d9c76bb21

commit cbe6f8cac95f5db7b35018a01c56dc3d9c76bb21
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2018-08-20 21:54:14 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2018-08-20 22:13:59 +0000

    config: regenerate USE for conditional RESTRICT (bug 664104)
    
    When the features USE state changes due to package.env settings,
    regenerate USE for correct evaluation of conditional RESTRICT.
    
    Fixes: 45986341a80c ("Support !test? conditionals in RESTRICT (bug 663278)")
    Bug: https://bugs.gentoo.org/664104

 lib/portage/package/ebuild/config.py | 39 ++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 19 deletions(-)
Comment 7 Thomas Deutschmann (RETIRED) gentoo-dev 2018-08-20 23:37:50 UTC
Fix confirmed, thank you.