Skip to contentSkip to conversation

python3-jsbeautifier: Enable tests

PATCH New Leon Anavi 1 participant 5 messages Jul 9

lore
Share & tools
lore

Leon Anavi

author
#0 lore raw

PATCH 1/5 python3-jsbeautifier: Enable tests

Inherit ptest and include tests for jsbeautifier.

This work was sponsored by GOVCERT.LU.

---
 .../python/python3-jsbeautifier/run-ptest     |  3 +++
 .../python/python3-jsbeautifier_2.0.3.bb      | 23 ++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-jsbeautifier/run-ptest
meta-python/recipes-devtools/python/python3-jsbeautifier/run-ptest new file +3 -0
new file mode 100644
index 0000000000..8d2017d39c
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+pytest --automake
meta-python/recipes-devtools/python/python3-jsbeautifier_2.0.3.bb +20 -3
index 635dc69a13..05de25c3fc 100644
@@ -4,11 +4,11 @@ LICENSE = "MIT"
 SECTION = "devel/python"
 LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=8227180126797a0148f94f483f3e1489"
 
-inherit pypi setuptools3
+inherit pypi setuptools3 ptest
 
-SRC_URI[sha256sum] = "9579d4e9dbaa00383f3efdff4c98c8140bb85ba319398e8b97cdaba27abd6ba3"
+SRC_URI += "file://run-ptest"
 
-PYPI_PACKAGE = "jsbeautifier"
+SRC_URI[sha256sum] = "9579d4e9dbaa00383f3efdff4c98c8140bb85ba319398e8b97cdaba27abd6ba3"
 
 RDEPENDS:${PN} += "\
     python3-core \
@@ -16,4 +16,21 @@ RDEPENDS:${PN} += "\
     python3-shell \
 "
 
+RDEPENDS:${PN}-ptest += " \
+    python3-pytest \
+    python3-core \
+    python3-unittest \
+    python3-unittest-automake-output \
+"
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+    cp -rf ${S}/${PYPI_PACKAGE}/tests/* ${D}${PTEST_PATH}/tests/
+
+    cat > ${D}${PTEST_PATH}/pytest.ini <<EOF
+[pytest]
+python_files = test*.py
+EOF
+}
+
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.47.3
author
#1 lore raw

PATCH 2/5 python3-olefile: Enable tests

Inherit ptest and include tests for olefile.

This work was sponsored by GOVCERT.LU.

---
 .../python/python3-olefile/run-ptest            |  3 +++
 .../python/python3-olefile_0.47.bb              | 17 +++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-olefile/run-ptest
meta-python/recipes-devtools/python/python3-olefile/run-ptest new file +3 -0
new file mode 100644
index 0000000000..8d2017d39c
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+pytest --automake
meta-python/recipes-devtools/python/python3-olefile_0.47.bb +15 -2
index bb6fa7a8cc..c5f72d12eb 100644
@@ -3,11 +3,12 @@ HOMEPAGE = "https://github.com/decalage2/olefile"
 LICENSE = "BSD-2-Clause"
 LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=f18814bd70fd28e11a4545145dcb3822"
 
+SRC_URI += "file://run-ptest"
+
 SRC_URI[sha256sum] = "599383381a0bf3dfbd932ca0ca6515acd174ed48870cbf7fee123d698c192c1c"
 
-inherit pypi setuptools3
+inherit pypi setuptools3 ptest
 
-PYPI_PACKAGE = "olefile"
 PYPI_PACKAGE_EXT = "zip"
 
 RDEPENDS:${PN} += "\
@@ -15,3 +16,15 @@ RDEPENDS:${PN} += "\
     python3-datetime \
     python3-logging \
 "
+
+RDEPENDS:${PN}-ptest += " \
+    python3-pytest \
+    python3-core \
+    python3-unittest \
+    python3-unittest-automake-output \
+"
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+    cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
+}
Signature · 1 line
2.47.3
author
#2 lore raw

PATCH 3/5 python3-screeninfo: Enable tests

In reply to Leon Anavi

Inherit ptest and include tests for screeninfo.

This work was sponsored by GOVCERT.LU.

---
 .../python/python3-screeninfo/run-ptest       |  3 +++
 .../python/python3-screeninfo_0.8.1.bb        | 23 +++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-screeninfo/run-ptest
meta-python/recipes-devtools/python/python3-screeninfo/run-ptest new file +3 -0
new file mode 100644
index 0000000000..8d2017d39c
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+pytest --automake
meta-python/recipes-devtools/python/python3-screeninfo_0.8.1.bb +21 -2
index a7a20707ef..4e1da84c66 100644
@@ -4,11 +4,30 @@ SECTION = "devel/python"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSE.md;md5=a23813181e06852d377bc25ae5563a97"
 
-SRC_URI[sha256sum] = "9983076bcc7e34402a1a9e4d7dabf3729411fd2abb3f3b4be7eba73519cd2ed1"
+# The PyPI package omits files for testing
+# so use the GitHub source instead.
+SRCREV = "0cf3055ccaf583a00a7a3a049f85a7c58dfd8884"
+SRC_URI = " \
+    git://github.com/rr-/screeninfo;branch=master;protocol=https \
+    file://run-ptest \
+"
 
-inherit pypi python_poetry_core
+inherit python_poetry_core ptest
 
 RDEPENDS:${PN} += "\
     python3-core \
     python3-profile \
 "
+
+RDEPENDS:${PN}-ptest += " \
+    python3-pytest \
+    python3-core \
+    python3-unittest \
+    python3-unittest-automake-output \
+"
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+    cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
+    cp -f ${S}/README.md ${D}${PTEST_PATH}/
+}
Signature · 1 line
2.47.3
author
#3 lore raw

PATCH 4/5 python3-pybcj: Enable tests

In reply to Leon Anavi

Inherit ptest and include tests for pybcj.

This work was sponsored by GOVCERT.LU.

---
 .../python/python3-pybcj/run-ptest            |  3 ++
 .../python/python3-pybcj_1.0.7.bb             | 28 ++++++++++++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-pybcj/run-ptest
meta-python/recipes-devtools/python/python3-pybcj/run-ptest new file +3 -0
new file mode 100644
index 0000000000..8d2017d39c
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+pytest --automake
meta-python/recipes-devtools/python/python3-pybcj_1.0.7.bb +24 -4
index 299677b072..e291375456 100644
@@ -4,11 +4,15 @@ LICENSE = "LGPL-2.1-or-later"
 SECTION = "devel/python"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=4fbd65380cdd255951079008b364516c"
 
-SRC_URI[sha256sum] = "72d64574069ffb0a800020668376b7ebd7adea159adbf4d35f8effc62f0daa67"
-
-inherit pypi python_setuptools_build_meta pypi
+# The PyPI package omits files for testing
+# so use the GitHub source instead.
+SRCREV = "0735ad15fa001748dc3a13f36be2fe7a4971cf79"
+SRC_URI = " \
+    git://github.com/miurahr/pybcj;branch=main;protocol=https \
+    file://run-ptest \
+"
 
-#PROVIDES = "python3-pybcj"
+inherit python_setuptools_build_meta ptest
 
 DEPENDS += " \
     python3-setuptools-scm-native \
@@ -22,3 +26,19 @@ RDEPENDS:${PN} += "\
     python3-core \
     python3-compression \
 "
+
+RDEPENDS:${PN}-ptest += " \
+    python3-pytest \
+    python3-core \
+    python3-datetime \
+    python3-crypt \
+    python3-compression \
+    python3-hypothesis \
+    python3-unittest \
+    python3-unittest-automake-output \
+"
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+    cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
+}
Signature · 1 line
2.47.3
author
#4 lore raw

PATCH 5/5 python3-pyppmd: Enable tests

In reply to Leon Anavi

Inherit ptest and include tests for pyppmd.

Add a patch to fix SIGABRT OutputBuffer_Grow() from src/ext/_ppmdmodule.c which was detected with the tests.

This work was sponsored by GOVCERT.LU.

---
 ...md8-Fix-SIGABRT-in-OutputBuffer_Grow.patch | 70 +++++++++++++++++++
 .../python/python3-pyppmd/run-ptest           |  3 +
 .../python/python3-pyppmd_1.3.1.bb            | 23 +++++-
 3 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-pyppmd/0001-Ppmd7-Ppmd8-Fix-SIGABRT-in-OutputBuffer_Grow.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pyppmd/run-ptest
meta-python/recipes-devtools/python/python3-pyppmd/0001-Ppmd7-Ppmd8-Fix-SIGABRT-in-OutputBuffer_Grow.patch new file +70 -0
new file mode 100644
index 0000000000..a31ac621d6
@@ -0,0 +1,70 @@
+From f9c6a0549503f00a1ab0ad58a98a30ee99b96770 Mon Sep 17 00:00:00 2001
+From: Leon Anavi <[email protected]>
+Date: Thu, 9 Jul 2026 11:37:04 +0000
+Subject: [PATCH] Ppmd7/Ppmd8: Fix SIGABRT in OutputBuffer_Grow
+
+The decode loop could abort in OutputBuffer_Grow() when a resumed
+decode thread wrote past the current call's max_length. Stop early
+once that limit is reached instead of trying to grow the buffer
+further.
+
+Also fix Ppmd8Decoder_decode because it never updated needs_input
+when input was fully consumed, unlike Ppmd7.
+
+Fixes test_ppmd7_decode_chunks and the equivalent Ppmd8 case,
+which previously aborted deterministically partway through decoding
+testdata2.ppmd in small chunks.
+
+This work was sponsored by GOVCERT.LU.
+
+Upstream-Status: Pending [https://github.com/miurahr/pyppmd/pull/131/]
+
+Signed-off-by: Leon Anavi <[email protected]>
+---
+ src/ext/_ppmdmodule.c | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/src/ext/_ppmdmodule.c b/src/ext/_ppmdmodule.c
+index dafa1c5..94f7f18 100644
+--- a/src/ext/_ppmdmodule.c
++++ b/src/ext/_ppmdmodule.c
+@@ -531,6 +531,12 @@ Ppmd7Decoder_decode(Ppmd7Decoder *self,  PyObject *args, PyObject *kwargs) {
+             break;
+         }
+         if (out->pos == out->size) {
++            /* Already reached max_length for this call; stop instead of
++               growing (avoids rest<=0 assert in OutputBuffer_Grow) */
++            if (self->blocksOutputBuffer->max_length >= 0 &&
++                self->blocksOutputBuffer->allocated >= self->blocksOutputBuffer->max_length) {
++                break;
++            }
+             if (OutputBuffer_Grow(self->blocksOutputBuffer, out) < 0) {
+                 PyErr_SetString(PyExc_ValueError, "No Memory.");
+                 goto error;
+@@ -1276,6 +1282,11 @@ Ppmd8Decoder_decode(Ppmd8Decoder *self,  PyObject *args, PyObject *kwargs) {
+              break;  // filled expected
+         }
+         if (out->pos == out->size) {
++            /* Same guard as for Ppmd7Decoder_decode() above */
++            if (self->blocksOutputBuffer->max_length >= 0 &&
++                self->blocksOutputBuffer->allocated >= self->blocksOutputBuffer->max_length) {
++                break;
++            }
+             if (OutputBuffer_Grow(self->blocksOutputBuffer, out) < 0) {
+                 PyErr_SetString(PyExc_ValueError, "L1586: Unknown status");
+                 goto error;
+@@ -1303,6 +1314,11 @@ Ppmd8Decoder_decode(Ppmd8Decoder *self,  PyObject *args, PyObject *kwargs) {
+             self->in_begin = 0;
+             self->in_end = 0;
+         }
++        if (self->eof) {
++            self->needs_input = False;
++        } else {
++            self->needs_input = True;
++        }
+     } else {
+         const size_t data_size = in->size - in->pos;
+         self->needs_input = False;
+-- 
+2.47.3
+
meta-python/recipes-devtools/python/python3-pyppmd/run-ptest new file +3 -0
new file mode 100644
index 0000000000..8d2017d39c
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+pytest --automake
meta-python/recipes-devtools/python/python3-pyppmd_1.3.1.bb +22 -1
index 4a06c9f01b..5af79d0453 100644
@@ -4,10 +4,15 @@ LICENSE = "LGPL-2.1-or-later"
 SECTION = "devel/python"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=4fbd65380cdd255951079008b364516c"
 
-inherit pypi python_setuptools_build_meta
+inherit pypi python_setuptools_build_meta ptest
 
 SRC_URI[sha256sum] = "ced527f08ade4408c1bfc5264e9f97ffac8d221c9d13eca4f35ec1ec0c7b6b2e"
 
+SRC_URI += " \
+    file://0001-Ppmd7-Ppmd8-Fix-SIGABRT-in-OutputBuffer_Grow.patch \
+    file://run-ptest \
+"
+
 DEPENDS += " \
     python3-setuptools-scm-native \
     python3-toml-native \
@@ -18,3 +23,19 @@ RDEPENDS:${PN} += "\
     python3-email \
     python3-importlib-metadata \
 "
+
+RDEPENDS:${PN}-ptest += " \
+    python3-pytest \
+    python3-pytest-benchmark \
+    python3-core \
+    python3-crypt \
+    python3-datetime \
+    python3-hypothesis \
+    python3-unittest \
+    python3-unittest-automake-output \
+"
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+    cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
+}
Signature · 1 line
2.47.3