Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions recipes-devtools/python/files/python_dependency_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env python3
"""Reusable Python dependency compatibility testing library"""

import pkg_resources
import sys
import os

def test_package_requirements(package_name):
"""Test that a package's requirements are satisfied"""
try:
# Import the package
__import__(package_name.replace('-', '_'))
print(f"PASS: {package_name} import successful")

# Get package distribution and requirements
dist = pkg_resources.get_distribution(package_name)
requirements = dist.requires()

print(f"{package_name} version: {dist.version}")

if not requirements:
print(f"PASS: {package_name} has no dependencies to check")
return True

# Check each requirement
for req in requirements:
try:
pkg_resources.require(str(req))
print(f"PASS: {req} satisfied")
except pkg_resources.DistributionNotFound:
print(f"FAIL: {req} not found")
return False
except pkg_resources.VersionConflict as e:
print(f"FAIL: {req} version conflict: {e}")
return False

return True
except Exception as e:
print(f"FAIL: {package_name} test failed: {e}")
return False

def get_python_rdepends_from_env():
"""Extract Python dependencies from RDEPENDS environment variable"""
rdepends = os.environ.get('RDEPENDS', '')
python_deps = []

for dep in rdepends.split():
if dep.startswith('python3-') and not dep.endswith('-native'):
pkg_name = dep.replace('python3-', '')
python_deps.append(pkg_name)

return python_deps

def test_integration_with(package_name, integration_packages):
"""Test integration with other packages"""
success = True

for integration_pkg in integration_packages:
try:
__import__(package_name.replace('-', '_'))
__import__(integration_pkg.replace('-', '_'))
print(f"PASS: {package_name} integrates with {integration_pkg}")
except ImportError:
print(f"SKIP: {integration_pkg} not available")
except Exception as e:
print(f"FAIL: {package_name}-{integration_pkg} integration failed: {e}")
success = False

return success

def main():
"""Main test function"""
if len(sys.argv) < 2:
print("FAIL: Package name required as argument")
return 1

package_name = sys.argv[1]
print(f"=== Testing {package_name} dependency compatibility ===")

success = True
success &= test_package_requirements(package_name)

# Get integration packages from RDEPENDS
integration_packages = get_python_rdepends_from_env()
if integration_packages:
print(f"Found Python dependencies from RDEPENDS: {integration_packages}")
success &= test_integration_with(package_name, integration_packages)

# Always output final result
if success:
print(f"PASS: {package_name} dependency test completed successfully")
else:
print(f"FAIL: {package_name} dependency test failed")

return 0 if success else 1

if __name__ == "__main__":
sys.exit(main())
5 changes: 5 additions & 0 deletions recipes-devtools/python/python3-boto3/run-ptest
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
#!/bin/sh

# Test dependency conflicts using shared library
python3 python_dependency_test.py boto3

# Run original smoke tests
pytest tests/functional/test_smoke.py -o log_cli=true -o log_cli_level=INFO | sed -e 's/\[...%\]//g'| sed -e 's/PASSED/PASS/g'| sed -e 's/FAILED/FAIL/g'| sed -e 's/SKIPPED/SKIP/g'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS"){printf "%s: %s\n", $NF, $0}else{print}}'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS") {$NF="";print $0}else{print}}'
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ HOMEPAGE = "https://github.com/boto/boto3"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=2ee41112a44fe7014dce33e26468ba93"

FILESEXTRAPATHS:prepend := "${THISDIR}/../files:"

SRC_URI = "\
git://github.com/boto/boto3.git;protocol=https;branch=master \
file://run-ptest"
file://run-ptest \
file://python_dependency_test.py \
"

SRCREV = "3f98cd0ed5dc41957e2303a3473b1249b8f4a7c4"
SRCREV = "660a1ec6b8b97d109a8ab37ca5a79925844388f0"
S = "${UNPACKDIR}/git"

inherit setuptools3 ptest
Expand All @@ -29,4 +33,5 @@ RDEPENDS:${PN}-ptest += "\
do_install_ptest() {
install -d ${D}${PTEST_PATH}/tests
cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
install -m 0755 ${UNPACKDIR}/python_dependency_test.py ${D}${PTEST_PATH}/
}
9 changes: 8 additions & 1 deletion recipes-devtools/python/python3-botocore/run-ptest
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
#!/bin/sh
pytest tests/integration/test_loaders.py -o log_cli=true -o log_cli_level=INFO | sed -e 's/\[...%\]//g'| sed -e 's/PASSED/PASS/g'| sed -e 's/FAILED/FAIL/g'| sed -e 's/SKIPPED/SKIP/g'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS"){printf "%s: %s\n", $NF, $0}else{print}}'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS") {$NF="";print $0}else{print}}'

# Test dependency conflicts using shared library
python3 python_dependency_test.py botocore

# Run basic botocore tests (if any exist)
if [ -d tests/unit ]; then
pytest tests/unit/test_client.py -v 2>/dev/null || echo "SKIP: unit tests not available"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ HOMEPAGE = "https://github.com/boto/botocore"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=2ee41112a44fe7014dce33e26468ba93"

FILESEXTRAPATHS:prepend := "${THISDIR}/../files:"

SRC_URI = "\
git://github.com/boto/botocore.git;protocol=https;branch=master \
file://run-ptest \
file://python_dependency_test.py \
"

SRCREV = "2a882881e2f02f8959df7b551978005854f8f5dd"
SRCREV = "dc8eb09cd30fb3fe1259c98a2a2f7955dc700227"
S = "${UNPACKDIR}/git"

inherit setuptools3 ptest
Expand All @@ -28,4 +31,5 @@ RDEPENDS:${PN}-ptest += "\
do_install_ptest() {
install -d ${D}${PTEST_PATH}/tests
cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
install -m 0755 ${UNPACKDIR}/python_dependency_test.py ${D}${PTEST_PATH}/
}
17 changes: 4 additions & 13 deletions recipes-devtools/python/python3-s3transfer/run-ptest
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

# known good tests
# Test dependency conflicts using shared library
python3 python_dependency_test.py s3transfer botocore multiprocessing urllib3 boto3

# Run original unit tests
TESTS="\
unit/test_bandwidth.py \
unit/test_compat.py \
Expand All @@ -11,15 +14,3 @@ for TEST in $TESTS
do
pytest tests/$TEST -o log_cli=true -o log_cli_level=INFO | sed -e 's/\[...%\]//g'| sed -e 's/PASSED/PASS/g'| sed -e 's/FAILED/FAIL/g'| sed -e 's/SKIPPED/SKIP/g'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS"){printf "%s: %s\n", $NF, $0}else{print}}'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS") {$NF="";print $0}else{print}}'
done

#disabled tests
# unit/test_delete.py
# unit/test_download.py
# unit/test_futures.py
# unit/test_manager.py
# unit/test_processpool.py
# unit/test_s3transfer.py
# unit/test_subscribers.py
# unit/test_tasks.py
# unit/test_upload.py
# unit/test_utils.py
6 changes: 5 additions & 1 deletion recipes-devtools/python/python3-s3transfer_0.14.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ HOMEPAGE = "https://github.com/boto/s3transfer"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=3b83ef96387f14655fc854ddc3c6bd57"

FILESEXTRAPATHS:prepend := "${THISDIR}/../files:"

SRC_URI = "\
git://github.com/boto/s3transfer.git;protocol=https;branch=master \
file://run-ptest \
file://python_dependency_test.py \
"
SRCREV = "b4ee0a2cc675088f8419e4996a9c560e510afd37"

Expand All @@ -24,10 +27,11 @@ RDEPENDS:${PN} += "\
RDEPENDS:${PN}-ptest += "\
python3 \
python3-pytest \
python3-urllib3 \
python3-boto3 \
"

do_install_ptest() {
install -d ${D}${PTEST_PATH}/tests
cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
install -m 0755 ${UNPACKDIR}/python_dependency_test.py ${D}${PTEST_PATH}/
}