public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Introduce epytest helper
@ 2021-03-06 11:01 Michał Górny
  2021-03-06 11:01 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: Use epytest Michał Górny
  2021-03-06 11:01 ` [gentoo-dev] [PATCH 3/3] python-utils-r1.eclass: Always force test summary in epytest Michał Górny
  0 siblings, 2 replies; 3+ messages in thread
From: Michał Górny @ 2021-03-06 11:01 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Introduce an epytest helper to call pytest with the standard set
of options, and the standard error message.  While
distutils_enable_tests made running pytest a lot easier, there are still
many cases when python_test() needs to be redefined in order to pass
additional options or perform additional actions.  Having the extra
helper will reduce code duplication and make it easier to change
the standard options.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/python-utils-r1.eclass | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index dcc441b82098..1b2e2ccde8e5 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1278,6 +1278,29 @@ build_sphinx() {
 	HTML_DOCS+=( "${dir}/_build/html/." )
 }
 
+# @FUNCTION: epytest
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Run pytest, passing the standard set of pytest options, followed
+# by user-specified options.
+#
+# This command dies on failure and respects nonfatal in EAPIs supporting
+# nonfatal die.
+epytest() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ -n ${EPYTHON} ]] || die "EPYTHON unset, invalid call context"
+
+	local die_args=()
+	[[ ${EAPI} != [45] ]] && die_args+=( -n )
+
+	set -- "${EPYTHON}" -m pytest -vv "${@}"
+
+	echo "${@}" >&2
+	"${@}" || die "${die_args[@]}" "pytest failed with ${EPYTHON}"
+	return ${?}
+}
+
 # -- python.eclass functions --
 
 _python_check_dead_variables() {
-- 
2.30.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: Use epytest
  2021-03-06 11:01 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Introduce epytest helper Michał Górny
@ 2021-03-06 11:01 ` Michał Górny
  2021-03-06 11:01 ` [gentoo-dev] [PATCH 3/3] python-utils-r1.eclass: Always force test summary in epytest Michał Górny
  1 sibling, 0 replies; 3+ messages in thread
From: Michał Górny @ 2021-03-06 11:01 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index ca2ed98c8e8c..f5b151d4b8e2 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -435,11 +435,11 @@ distutils_enable_tests() {
 			if [[ ${do_install} ]]; then
 				python_test() {
 					distutils_install_for_testing --via-root
-					pytest -vv || die "Tests fail with ${EPYTHON}"
+					epytest
 				}
 			else
 				python_test() {
-					pytest -vv || die "Tests fail with ${EPYTHON}"
+					epytest
 				}
 			fi
 			;;
-- 
2.30.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-dev] [PATCH 3/3] python-utils-r1.eclass: Always force test summary in epytest
  2021-03-06 11:01 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Introduce epytest helper Michał Górny
  2021-03-06 11:01 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: Use epytest Michał Górny
@ 2021-03-06 11:01 ` Michał Górny
  1 sibling, 0 replies; 3+ messages in thread
From: Michał Górny @ 2021-03-06 11:01 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Explicitly request pytest to display the summary of all test results
except for passing tests.  This overrides the upstream defaults to
improve the quality of build logs.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/python-utils-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 1b2e2ccde8e5..52d064e4af80 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1294,7 +1294,7 @@ epytest() {
 	local die_args=()
 	[[ ${EAPI} != [45] ]] && die_args+=( -n )
 
-	set -- "${EPYTHON}" -m pytest -vv "${@}"
+	set -- "${EPYTHON}" -m pytest -vv -ra "${@}"
 
 	echo "${@}" >&2
 	"${@}" || die "${die_args[@]}" "pytest failed with ${EPYTHON}"
-- 
2.30.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-06 11:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-06 11:01 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Introduce epytest helper Michał Górny
2021-03-06 11:01 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: Use epytest Michał Górny
2021-03-06 11:01 ` [gentoo-dev] [PATCH 3/3] python-utils-r1.eclass: Always force test summary in epytest Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox