aboutsummaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/resolver/test_unpack_dependencies.py
blob: cfceff4b16aa520475ad8a9a4b7939fade5ccaa7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright 2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

from portage.tests import TestCase
from portage.tests.resolver.ResolverPlayground import ResolverPlayground, ResolverPlaygroundTestCase

class UnpackDependenciesTestCase(TestCase):
	def testUnpackDependencies(self):
		distfiles = {
			"A-1.tar.gz": b"binary\0content",
			"B-1.TAR.XZ": b"binary\0content",
			"B-docs-1.tar.bz2": b"binary\0content",
			"C-1.TAR.XZ": b"binary\0content",
			"C-docs-1.tar.bz2": b"binary\0content",
		}

		ebuilds = {
			"dev-libs/A-1": {"SRC_URI": "A-1.tar.gz", "EAPI": "5-progress"},
			"dev-libs/B-1": {"IUSE": "doc", "SRC_URI": "B-1.TAR.XZ doc? ( B-docs-1.tar.bz2 )", "EAPI": "5-progress"},
			"dev-libs/C-1": {"IUSE": "doc", "SRC_URI": "C-1.TAR.XZ doc? ( C-docs-1.tar.bz2 )", "EAPI": "5-progress"},
			"app-arch/bzip2-1": {},
			"app-arch/gzip-1": {},
			"app-arch/tar-1": {},
			"app-arch/xz-utils-1": {},
		}

		repo_configs = {
			"test_repo": {
				"unpack_dependencies/5-progress": (
					"tar.bz2 app-arch/tar app-arch/bzip2",
					"tar.gz app-arch/tar app-arch/gzip",
					"tar.xz app-arch/tar app-arch/xz-utils",
				),
			},
		}

		test_cases = (
			ResolverPlaygroundTestCase(
				["dev-libs/A"],
				success = True,
				ignore_mergelist_order = True,
				mergelist = ["app-arch/tar-1", "app-arch/gzip-1", "dev-libs/A-1"]),
			ResolverPlaygroundTestCase(
				["dev-libs/B"],
				success = True,
				ignore_mergelist_order = True,
				mergelist = ["app-arch/tar-1", "app-arch/xz-utils-1", "dev-libs/B-1"]),
			ResolverPlaygroundTestCase(
				["dev-libs/C"],
				success = True,
				ignore_mergelist_order = True,
				mergelist = ["app-arch/tar-1", "app-arch/xz-utils-1", "app-arch/bzip2-1", "dev-libs/C-1"]),
		)

		user_config = {
			"package.use": ("dev-libs/C doc",)
		}

		playground = ResolverPlayground(distfiles=distfiles, ebuilds=ebuilds, repo_configs=repo_configs, user_config=user_config)
		try:
			for test_case in test_cases:
				playground.run_TestCase(test_case)
				self.assertEqual(test_case.test_success, True, test_case.fail_msg)
		finally:
			playground.cleanup()