aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2024-02-17 16:59:22 -0800
committerBrian Dolbec <dolsen@gentoo.org>2024-02-17 18:16:28 -0800
commita1e25deeab64dcb7334381854db23a564d2d2c02 (patch)
tree63376b875f87f48e638e15e0fb2b7f31bb87d6cc
parenteclean: Handle InvalidDepstring info in _deps_equal (diff)
downloadgentoolkit-a1e25deeab64dcb7334381854db23a564d2d2c02.tar.gz
gentoolkit-a1e25deeab64dcb7334381854db23a564d2d2c02.tar.bz2
gentoolkit-a1e25deeab64dcb7334381854db23a564d2d2c02.zip
Initial tests for _deps_equal()
Signed-off-by: Brian Dolbec <dolsen@gentoo.org>
-rwxr-xr-xpym/gentoolkit/test/eclean/test_search.py157
1 files changed, 157 insertions, 0 deletions
diff --git a/pym/gentoolkit/test/eclean/test_search.py b/pym/gentoolkit/test/eclean/test_search.py
index 32d360c..0bbad46 100755
--- a/pym/gentoolkit/test/eclean/test_search.py
+++ b/pym/gentoolkit/test/eclean/test_search.py
@@ -26,8 +26,11 @@ from gentoolkit.test.eclean.distsupport import (
)
import gentoolkit.eclean.search as search
from gentoolkit.eclean.search import DistfilesSearch
+from gentoolkit.eclean.search import _deps_equal
from gentoolkit.eclean.exclude import parseExcludeFile
+from portage.dep import Atom
+
"""Tests for eclean's distfiles search functions."""
@@ -670,12 +673,166 @@ class TestRemoveProtected(unittest.TestCase):
)
+class TestDepsEqual(unittest.TestCase):
+
+ def test_deps_equal(self):
+ # def _deps_equal(deps_a, eapi_a, deps_b, eapi_b, libc_deps, uselist=None, cpv=None):
+ all_tests = [
+ # 1 equal
+ (
+ "x11-misc/xdg-user-dirs-gtk-0.11",
+ {
+ "deps_a": "dev-libs/glib:2 >=x11-libs/gtk+-3.5.1:3 >=x11-misc/xdg-user-dirs-0.14",
+ "eapi_a": "8",
+ "deps_b": "dev-libs/glib:2 >=x11-libs/gtk+-3.5.1:3 >=x11-misc/xdg-user-dirs-0.14",
+ "eapi_b": "8",
+ "libc_deps": {Atom("sys-libs/glibc:2.2")},
+ "uselist": frozenset(
+ {
+ "elibc_glibc",
+ "amd64",
+ "abi_x86_64",
+ "kernel_linux",
+ "userland_GNU",
+ }
+ ),
+ },
+ True,
+ ),
+ # 2 ebuild different gtk+ dep
+ (
+ "x11-misc/xdg-user-dirs-gtk-0.11",
+ {
+ "deps_a": "dev-libs/glib:2 >=x11-libs/gtk+-3.5.1:3 >=x11-misc/xdg-user-dirs-0.14",
+ "eapi_a": "8",
+ "deps_b": "dev-libs/glib:2 >=x11-libs/gtk+-3.5.2:3 >=x11-misc/xdg-user-dirs-0.14",
+ "eapi_b": "8",
+ "libc_deps": {Atom("sys-libs/glibc:2.2")},
+ "uselist": frozenset(
+ {
+ "elibc_glibc",
+ "amd64",
+ "abi_x86_64",
+ "kernel_linux",
+ "userland_GNU",
+ }
+ ),
+ },
+ False,
+ ),
+ # 3 different eapi, but is not currently tested
+ (
+ "x11-misc/xdg-user-dirs-gtk-0.11",
+ {
+ "deps_a": "dev-libs/glib:2 >=x11-libs/gtk+-3.5.1:3 >=x11-misc/xdg-user-dirs-0.14",
+ "eapi_a": "7",
+ "deps_b": "dev-libs/glib:2 >=x11-libs/gtk+-3.5.1:3 >=x11-misc/xdg-user-dirs-0.14",
+ "eapi_b": "8",
+ "libc_deps": {Atom("sys-libs/glibc:2.2")},
+ "uselist": frozenset(
+ {
+ "elibc_glibc",
+ "amd64",
+ "abi_x86_64",
+ "kernel_linux",
+ "userland_GNU",
+ }
+ ),
+ },
+ True,
+ ),
+ # 4 valid/False
+ (
+ "x11-misc/xdg-user-dirs-0.18",
+ {
+ "deps_a": "dev-libs/glib:2 >=x11-libs/gtk+-3.5.1:3 >=x11-misc/xdg-user-dirs-0.14",
+ "eapi_a": "8",
+ "deps_b": "gtk? ( x11-misc/xdg-user-dirs-gtk )",
+ "eapi_b": "8",
+ "libc_deps": {Atom("sys-libs/glibc:2.2")},
+ "uselist": frozenset(
+ {
+ "elibc_glibc",
+ "amd64",
+ "abi_x86_64",
+ "kernel_linux",
+ "userland_GNU",
+ }
+ ),
+ },
+ False,
+ ),
+ # 5 ebuild InvalidDependString
+ (
+ "x11-misc/xdg-user-dirs-0.18",
+ {
+ "deps_a": "dev-libs/glib:2 >=x11-libs/gtk+-3.5.1:3 >=x11-misc/xdg-user-dirs-0.14",
+ "eapi_a": "8",
+ "deps_b": "gtk? ( )",
+ "eapi_b": "8",
+ "libc_deps": {Atom("sys-libs/glibc:2.2")},
+ "uselist": frozenset(
+ {
+ "elibc_glibc",
+ "amd64",
+ "abi_x86_64",
+ "kernel_linux",
+ "userland_GNU",
+ }
+ ),
+ },
+ True,
+ ),
+ # 6 binpkg InvalidDependString
+ (
+ "x11-misc/xdg-user-dirs-0.18",
+ {
+ "deps_a": "gtk? ( )",
+ "eapi_a": "8",
+ "deps_b": "gtk? ( x11-misc/xdg-user-dirs-gtk )",
+ "eapi_b": "8",
+ "libc_deps": {Atom("sys-libs/glibc:2.2")},
+ "uselist": frozenset(
+ {
+ "elibc_glibc",
+ "amd64",
+ "abi_x86_64",
+ "kernel_linux",
+ "userland_GNU",
+ }
+ ),
+ },
+ False,
+ ),
+ ]
+ x = 1
+ for test in all_tests:
+ cpv = test[0]
+ data = test[1]
+ # print(x, cpv) # for debug testing
+ self.assertEqual(
+ _deps_equal(
+ data["deps_a"],
+ data["eapi_a"],
+ data["deps_b"],
+ data["eapi_b"],
+ data["libc_deps"],
+ data["uselist"],
+ cpv,
+ ),
+ test[2],
+ )
+ x += 1
+ # print("####################") # for debug testing
+
+
def test_main():
suite = unittest.TestLoader()
suite.loadTestsFromTestCase(TestCheckLimits)
suite.loadTestsFromTestCase(TestFetchRestricted)
suite.loadTestsFromTestCase(TestNonDestructive)
suite.loadTestsFromTestCase(TestRemoveProtected)
+ suite.loadTestsFromTestCase(TestDepsEqual)
unittest.TextTestRunner(verbosity=2).run(suite)