pkgcore / pkgcheck

pkgcore-based QA utility for ebuild repos
https://pkgcore.github.io/pkgcheck
BSD 3-Clause "New" or "Revised" License
34 stars 29 forks source link

[New Check]: Check for `EPYTEST_XDIST` declared after `distutils_enable_tests` #634

Closed mgorny closed 5 months ago

mgorny commented 8 months ago

Is there an existing such new check request for this?

Explain

Check for EPYTEST_XDIST being declared after distutils_enable_tests pytest call. This way, we ensure that dev-python/pytest-xdist dep will be added by the call.

Examples

distutils_enable_tests pytest

EPYTEST_DESELECT=( ... )
EPYTEST_XDIST=1
distutils_enable_tests pytest

python_test() {
    local EPYTEST_XDIST=1
    epytest -o addopts=
}

Output message

EPYTEST_XDIST needs to be declared prior to calling distutils_enable_tests

Documentation

EPYTEST_XDIST variable is used both by epytest and distutils_enable_tests. It needs to be declared prior to the call to the latter function, in order to ensure that it adds the dependency on dev-python/pytest-xdist. Otherwise, xdist would be used but the dependency would be missing.

Result level

warning

thesamesam commented 5 months ago

Am I missing why this can't just be a pre inherit variable?

mgorny commented 5 months ago

Because we don't want another mess like cargo.eclass where you have to scroll a hundred lines down to the inherit line.

thesamesam commented 5 months ago

That doesn't feel like great rationale for a hand-rolled check in pkgcheck when we already have infrastructure for that?

Besides, I at least find it better to put all variables which might affect metadata before inherit (it's where I expect them).

mgorny commented 5 months ago

Actually, there are valid cases not to set it prior to the call, particularly if we're using PYTHON_TESTED.