diff options
author | Michał Górny <mgorny@gentoo.org> | 2021-03-14 16:16:07 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2021-03-28 12:22:34 +0200 |
commit | 87c16896ff4e4f4f60640ee60cee34a47dbdc741 (patch) | |
tree | 11de2d2773f08956d2e1a2fe80f7e2c26bf31fa8 /eclass | |
parent | dev-python/snakeoil: Remove old (diff) | |
download | gentoo-87c16896ff4e4f4f60640ee60cee34a47dbdc741.tar.gz gentoo-87c16896ff4e4f4f60640ee60cee34a47dbdc741.tar.bz2 gentoo-87c16896ff4e4f4f60640ee60cee34a47dbdc741.zip |
python-utils-r1.eclass: Add eunittest helper
Add an eunittest helper to wrap up the common 'python -m unittest
discover' calls, except that they are run via
dev-python/unittest-or-fail now. This guarantees that if no tests are
discovered the test phase fails rather than silently ignoring
the problem. This is especially helpful since it saves the developer
from having to inspect test phase logs.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/python-utils-r1.eclass | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 3036148b8383..d0bfb7819059 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1299,5 +1299,28 @@ epytest() { return ${?} } +# @FUNCTION: eunittest +# @USAGE: [<args>...] +# @DESCRIPTION: +# Run unit tests using dev-python/unittest-or-fail, passing the standard +# set of options, followed by user-specified options. +# +# This command dies on failure and respects nonfatal in EAPIs supporting +# nonfatal die. +eunittest() { + debug-print-function ${FUNCNAME} "${@}" + + [[ -n ${EPYTHON} ]] || die "EPYTHON unset, invalid call context" + + local die_args=() + [[ ${EAPI} != [45] ]] && die_args+=( -n ) + + set -- "${EPYTHON}" -m unittest_or_fail discover -v "${@}" + + echo "${@}" >&2 + "${@}" || die "${die_args[@]}" "Tests failed with ${EPYTHON}" + return ${?} +} + _PYTHON_UTILS_R1=1 fi |