commit:     792934438a7142acbf946db90f3c044a17e4619a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat May 24 05:36:49 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat May 24 06:11:02 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=79293443

dev-python/uv-build: Add a self-test

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/uv-build/uv-build-0.7.8.ebuild | 55 ++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/dev-python/uv-build/uv-build-0.7.8.ebuild 
b/dev-python/uv-build/uv-build-0.7.8.ebuild
index 770145636992..1ba62137357d 100644
--- a/dev-python/uv-build/uv-build-0.7.8.ebuild
+++ b/dev-python/uv-build/uv-build-0.7.8.ebuild
@@ -20,10 +20,18 @@ HOMEPAGE="
 LICENSE="|| ( Apache-2.0 MIT )"
 SLOT="0"
 KEYWORDS="~amd64"
+IUSE="test"
+RESTRICT="!test? ( test )"
 
 RDEPEND="
        >=dev-python/uv-${PV}
 "
+BDEPEND="
+       test? (
+               app-arch/unzip
+               dev-python/build[${PYTHON_USEDEP}]
+       )
+"
 
 src_prepare() {
        distutils-r1_src_prepare
@@ -36,7 +44,7 @@ src_prepare() {
        sed -i -e '/\[build-system\]/,$d' pyproject.toml || die
        cat >> pyproject.toml <<-EOF || die
                [build-system]
-               requires = []
+               requires = ["uv_build<9999"]
                build-backend = "uv_build"
                backend-path = ["src"]
        EOF
@@ -44,3 +52,48 @@ src_prepare() {
        # rename to make uv-build find it
        mv python src || die
 }
+
+python_test() {
+       "${EPYTHON}" -m build -n || die "Self-build failed with ${EPYTHON}"
+
+       local zip_result=$(
+               unzip -t "dist/uv_build-${PV}-py3-none-any.whl" || die
+       )
+       local zip_expected="\
+Archive:  dist/uv_build-${PV}-py3-none-any.whl
+    testing: uv_build/                OK
+    testing: uv_build/__init__.py     OK
+    testing: uv_build/__main__.py     OK
+    testing: uv_build/py.typed        OK
+    testing: uv_build-0.7.8.dist-info/   OK
+    testing: uv_build-0.7.8.dist-info/WHEEL   OK
+    testing: uv_build-0.7.8.dist-info/METADATA   OK
+    testing: uv_build-0.7.8.dist-info/RECORD   OK
+No errors detected in compressed data of dist/uv_build-${PV}-py3-none-any.whl.\
+"
+       if [[ ${zip_result} != ${zip_expected} ]]; then
+               eerror ".zip result:\n${zip_result}"
+               eerror ".zip expected:\n${zip_expected}"
+               die ".whl result mismatch"
+       fi
+
+       local tar_result=$(
+               tar -tf "dist/uv_build-${PV}.tar.gz" || die
+       )
+       local tar_expected="\
+uv_build-0.7.8/PKG-INFO
+uv_build-0.7.8/
+uv_build-0.7.8/README.md
+uv_build-0.7.8/pyproject.toml
+uv_build-0.7.8/src
+uv_build-0.7.8/src/uv_build
+uv_build-0.7.8/src/uv_build/__init__.py
+uv_build-0.7.8/src/uv_build/__main__.py
+uv_build-0.7.8/src/uv_build/py.typed\
+"
+       if [[ ${tar_result} != ${tar_expected} ]]; then
+               eerror ".tar.gz result:\n${tar_result}"
+               eerror ".tar.gz expected:\n${tar_expected}"
+               die ".tar.gz result mismatch"
+       fi
+}

Reply via email to