commit:     4bfa549af9709682d530782d068d72c43a709e62
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat May 29 11:45:45 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat May 29 15:15:43 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4bfa549a

install-qa-check.d: Check for missing tests in distutils-r1 ebuilds

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 metadata/install-qa-check.d/60python-tests | 32 ++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/metadata/install-qa-check.d/60python-tests 
b/metadata/install-qa-check.d/60python-tests
new file mode 100644
index 00000000000..713ed63d376
--- /dev/null
+++ b/metadata/install-qa-check.d/60python-tests
@@ -0,0 +1,32 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# QA check: ensure that tests are run if present
+# Maintainer: Python project <[email protected]>
+
+python_test_check() {
+       # only distutils-r1 is covered for the time being
+       has distutils-r1 ${INHERITED} || return
+       # skip packages that define tests
+       declare -p -f python_test &>/dev/null && return
+       # skip packages that explicitly restrict tests
+       has test ${RESTRICT} && return
+
+       # do we have any files looking like tests?
+       local any=$(find "${WORKDIR}" -name 'test_*.py' -print -quit)
+       [[ -n ${any} ]] || return
+
+       eqawarn
+       eqawarn 'QA Notice: this package seems to contain tests but they are 
not enabled.'
+       eqawarn 'Please either run tests (via distutils_enable_tests or 
declaring'
+       eqawarn 'python_test yourself), or add RESTRICT="test" along with an 
explanatory'
+       eqawarn 'comment if tests cannot be run.'
+       eqawarn
+       eqatag -v python-tests.missing
+}
+
+python_test_check
+
+: # guarantee successful exit
+
+# vim:ft=ebuild

Reply via email to