public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Trevor Gamblin <tgamblin@baylibre.com>
To: openembedded-core@lists.openembedded.org
Subject: [OE-core][PATCH 4/4] python3-vcs-versioning: add ptest
Date: Thu, 23 Apr 2026 13:12:46 -0400	[thread overview]
Message-ID: <20260423171246.309711-4-tgamblin@baylibre.com> (raw)
In-Reply-To: <20260423171246.309711-1-tgamblin@baylibre.com>

The tests are in the 'testing_vcs' directory, so set PTEST_PYTEST_DIR
accordingly. Add setuptools, setuptools-scm, and git to the ptest
RDEPENDS, since many of the tests make use of them. Many of the skipped
tests depend on mercurial, but that's in meta-oe and not worth moving to
oe-core just for this.

Add python3-vcs-versioning to PTESTS_FAST in ptest-packagelists.inc,
since the suite only takes a few seconds.

We also need a custom run-ptest script for two reasons:

1. There is a 'vcs_versioning.test_api' used as a plugin. This is
   mentioned in conftest.py but is intended to be picked up from
   pyproject.toml, which we don't ship with the ptest image. Instead,
   just add '-p vcs_versioning.test_api' to the pytest call.
2. The test logic tries to rewrite pytest's assertion failures, which
   doesn't work well with our automake formatting. We can work around
   this by telling pytest to output plain messages with --assert=plain.

Example test results:

|============================================================================
|Testsuite summary
|# TOTAL: 409
|# PASS: 364
|# SKIP: 44
|# XFAIL: 1
|# FAIL: 0
|# XPASS: 0
|# ERROR: 0
|DURATION: 3
|END: /usr/lib/python3-vcs-versioning/ptest
|2026-04-23T16:21
|STOP: ptest-runner
|TOTAL: 1 FAIL: 0

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../python/python3-vcs-versioning/run-ptest   |  6 ++++++
 .../python/python3-vcs-versioning_1.1.1.bb    | 19 ++++++++++++++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/python/python3-vcs-versioning/run-ptest

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index 11a894accf..d7a529678f 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -87,6 +87,7 @@ PTESTS_FAST = "\
     python3-pyyaml \
     python3-rpds-py \
     python3-trove-classifiers \
+    python3-vcs-versioning \
     python3-uritools \
     python3-wcwidth \
     python3-webcolors \
diff --git a/meta/recipes-devtools/python/python3-vcs-versioning/run-ptest b/meta/recipes-devtools/python/python3-vcs-versioning/run-ptest
new file mode 100644
index 0000000000..6550ec8273
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-vcs-versioning/run-ptest
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# we need to load the vcs_versioning.test_api plugin for some tests to work.
+# Also make sure that we don't get pretty diffs for assertion errors so that we
+# don't see terminalreporter errors (which the automake plugin un-registers).
+pytest -p vcs_versioning.test_api --assert=plain --automake
diff --git a/meta/recipes-devtools/python/python3-vcs-versioning_1.1.1.bb b/meta/recipes-devtools/python/python3-vcs-versioning_1.1.1.bb
index 788717de9e..4d2f5007b4 100644
--- a/meta/recipes-devtools/python/python3-vcs-versioning_1.1.1.bb
+++ b/meta/recipes-devtools/python/python3-vcs-versioning_1.1.1.bb
@@ -7,9 +7,14 @@ LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=c9b06ad2ebd7e2e82d34b3caf353e7d5"
 
 SRC_URI[sha256sum] = "fabd75a3cab7dd8ac02fe24a3a9ba936bf258667b5a62ed468c9a1da0f5775bc"
 
+SRC_URI += "\
+    file://run-ptest \
+"
+
 PYPI_PACKAGE = "vcs_versioning"
+PTEST_PYTEST_DIR = "testing_vcs"
 
-inherit pypi python_setuptools_build_meta
+inherit pypi python_setuptools_build_meta ptest-python-pytest
 
 DEPENDS += "\
     python3-packaging-native \
@@ -21,4 +26,16 @@ RDEPENDS:${PN} = "\
     python3-typing-extensions \
 "
 
+RDEPENDS:${PN}-ptest += "\
+    git \
+    python3-setuptools \
+    python3-setuptools-scm \
+"
+
+do_install_ptest:append() {
+    rm -rf ${D}${PTEST_PATH}/.pytest_cache
+    find ${D}${PTEST_PATH} -name __pycache__ -type d -exec rm -rf {} +
+    find ${D}${PTEST_PATH} -name '*.pyc' -delete
+}
+
 BBCLASSEXTEND = "native nativesdk"
-- 
2.53.0



      parent reply	other threads:[~2026-04-23 17:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 17:12 [OE-core][PATCH 1/4] python3-vcs-versioning: add recipe Trevor Gamblin
2026-04-23 17:12 ` [OE-core][PATCH 2/4] python3-setuptools-scm: upgrade 9.2.2 -> 10.0.5 Trevor Gamblin
2026-04-24  9:42   ` Mathieu Dubois-Briand
2026-04-23 17:12 ` [OE-core][PATCH 3/4] maintainers.inc: add self for python3-uv-build Trevor Gamblin
2026-04-23 17:12 ` Trevor Gamblin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260423171246.309711-4-tgamblin@baylibre.com \
    --to=tgamblin@baylibre.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox