commit: d909a4e5c4828969e1af52d6199d1539f238a04a
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 15 14:58:22 2025 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 25 04:35:37 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d909a4e5
python-utils-r1.eclass: epytest, create junit xml
Request pytest to output junit format xml files that could be used
for further machine processing of test results. Use xunit1 format
since it includes filenames that are useful for decoding the `classname`
attribute. The potential use cases include automatically generating
`EPYTEST_DESELECT` from test failures and verifying the existing lists
for stale values.
We use `mktemp` to create unique filenames, to account for `epytest`
being called multiple times in a single test phase.
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
eclass/python-utils-r1.eclass | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index c535a79cb48e..6c887626cbd1 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1324,6 +1324,9 @@ epytest() {
local color=yes
[[ ${NO_COLOR} ]] && color=no
+ mkdir -p "${T}/pytest-xml" || die
+ local junit_xml=$(mktemp "${T}/pytest-xml/${EPYTHON}-XXX.xml" || die)
+
local args=(
# verbose progress reporting and tracebacks
-vv
@@ -1345,6 +1348,10 @@ epytest() {
# we don't need to preserve them
-o tmp_path_retention_count=0
-o tmp_path_retention_policy=failed
+ # write a junit .xml file to aid machine processing of results
+ --junit-xml="${junit_xml}"
+ # use xunit1 format as that includes an explicit path
+ -o junit_family=xunit1
)
if has_version ">=dev-python/pytest-8.4.0"; then