Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] python3-pygobject: add ptest support
@ 2026-11-14 19:03 Babanpreet Singh
  0 siblings, 0 replies; only message in thread
From: Babanpreet Singh @ 2026-11-14 19:03 UTC (permalink / raw)
  To: openembedded-core; +Cc: Trevor Gamblin, Ross Burton, Babanpreet Singh

Run the upstream pytest suite under ptest. The test libraries and
typelibs come from the gobject-introspection-tests subproject that
pygobject bundles, built through the 'tests' PACKAGECONFIG when ptest
is enabled.

Tested on qemux86-64 with ptest-runner: 1442 pass, 184 skip, 7 xfail,
0 fail. Most skips are Gtk, Gdk and Pango tests; those are not in the
image.

[YOCTO #15565]

AI-Generated: Uses Claude (claude-fable-5-2)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../python/python3-pygobject/run-ptest        |  8 ++++++
 .../python/python3-pygobject_3.58.1.bb        | 27 ++++++++++++++++---
 3 files changed, 33 insertions(+), 3 deletions(-)
 create mode 100755 meta/recipes-devtools/python/python3-pygobject/run-ptest

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index bef45bb4d5..77e03b33b1 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -93,6 +93,7 @@ PTESTS_FAST = "\
     python3-pluggy \
     python3-pefile \
     python3-pyasn1 \
+    python3-pygobject \
     python3-pyopenssl \
     python3-pyyaml \
     python3-rpds-py \
diff --git a/meta/recipes-devtools/python/python3-pygobject/run-ptest b/meta/recipes-devtools/python/python3-pygobject/run-ptest
new file mode 100755
index 0000000000..47fab21c9c
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-pygobject/run-ptest
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+export LD_LIBRARY_PATH=$PWD/../gi-tests
+export GI_TYPELIB_PATH=$PWD/../gi-tests
+export GSETTINGS_SCHEMA_DIR=$PWD/tests
+export GSETTINGS_BACKEND=memory
+
+pytest --automake
diff --git a/meta/recipes-devtools/python/python3-pygobject_3.58.1.bb b/meta/recipes-devtools/python/python3-pygobject_3.58.1.bb
index 82089c2ad7..069a313735 100644
--- a/meta/recipes-devtools/python/python3-pygobject_3.58.1.bb
+++ b/meta/recipes-devtools/python/python3-pygobject_3.58.1.bb
@@ -7,7 +7,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=91db794c3adc9d824d4eddabb341e816"
 
 GIR_MESON_OPTION = ""
 
-inherit gnomebase setuptools3-base gobject-introspection upstream-version-is-even
+inherit gnomebase setuptools3-base gobject-introspection upstream-version-is-even ptest-python-pytest
 
 python() {
     if d.getVar('CLASSOVERRIDE') == "class-target" and not bb.utils.to_boolean(d.getVar("GI_DATA_ENABLED")):
@@ -19,11 +19,13 @@ DEPENDS += "python3 glib-2.0"
 GNOME_COMPRESS_TYPE = "gz"
 GNOMEBN = "pygobject"
 
+SRC_URI += "file://run-ptest"
 SRC_URI[archive.sha256sum] = "4c80598ade17fbaa7798e01a25d0bf29ce109740786026a074c5c62bb3e79d23"
 
 S = "${UNPACKDIR}/${GNOMEBN}-${PV}"
 
-PACKAGECONFIG ??= "${@bb.utils.contains_any('DISTRO_FEATURES', [ 'directfb', 'wayland', 'x11' ], 'cairo', '', d)}"
+PACKAGECONFIG ??= "${@bb.utils.contains_any('DISTRO_FEATURES', [ 'directfb', 'wayland', 'x11' ], 'cairo', '', d)} \
+                   ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"
 
 RDEPENDS:${PN} += " \
     python3-asyncio \
@@ -35,7 +37,26 @@ RDEPENDS:${PN} += " \
 # python3-pycairo is checked on configuration -> DEPENDS
 # we don't link against python3-pycairo -> RDEPENDS
 PACKAGECONFIG[cairo] = "-Dpycairo=enabled,-Dpycairo=disabled, cairo python3-pycairo, python3-pycairo"
-PACKAGECONFIG[tests] = "-Dtests=true,-Dtests=false,"
+# do_install_ptest_base cleans PTEST_PATH, so the test libraries go next to it
+PACKAGECONFIG[tests] = "-Dtests=true -Dgobject-introspection-tests:install_dir=${libdir}/${BPN}/gi-tests,-Dtests=false,"
+
+do_install_ptest:append() {
+    rm -f ${D}${PTEST_PATH}/tests/*.c ${D}${PTEST_PATH}/tests/*.h ${D}${PTEST_PATH}/tests/meson.build
+    install -m 0644 ${S}/pyproject.toml ${D}${PTEST_PATH}/
+    install -m 0644 ${B}/tests/gschemas.compiled ${D}${PTEST_PATH}/tests/
+    install -m 0755 ${B}/tests/testhelper*.so ${D}${PTEST_PATH}/tests/
+}
+
+FILES:${PN}-ptest += "${libdir}/${BPN}/gi-tests"
+
+RDEPENDS:${PN}-ptest += " \
+    bash \
+    python3-ctypes \
+    python3-misc \
+    python3-pickle \
+    python3-unittest \
+"
+RDEPENDS:${PN}-ptest:append:libc-glibc = " glibc-gconv-iso8859-1"
 
 BBCLASSEXTEND = "native"
 PACKAGECONFIG:class-native = ""
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-14 19:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-14 19:03 [PATCH] python3-pygobject: add ptest support Babanpreet Singh

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