aboutsummaryrefslogtreecommitdiff
blob: 34efe9c562b2bb8d29e4542ff99677147464a4f6 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright 2010 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 MergelistOutputTestCase(TestCase):

	def testMergelistOutput(self):
		"""
		This test doesn't check if the output is correct, but makes sure
		that we don't backtrace somewhere in the output code.
		"""
		ebuilds = {
			"dev-libs/A-1": { "DEPEND": "dev-libs/B dev-libs/C", "IUSE": "+foo", "EAPI": 1 },
			"dev-libs/B-1": { "DEPEND": "dev-libs/D", "IUSE": "foo +bar", "EAPI": 1 },
			"dev-libs/C-1": { "DEPEND": "dev-libs/E", "IUSE": "foo bar" },
			"dev-libs/D-1": { "IUSE": "" },
			"dev-libs/E-1": {},

			#reinstall for flags
			"dev-libs/Z-1": { "IUSE": "+foo", "EAPI": 1 },
			"dev-libs/Y-1": { "IUSE": "foo", "EAPI": 1 },
			"dev-libs/X-1": {},
			"dev-libs/W-1": { "IUSE": "+foo", "EAPI": 1 },
			}

		installed = {
			"dev-libs/Z-1": { "USE": "", "IUSE": "foo" },
			"dev-libs/Y-1": { "USE": "foo", "IUSE": "+foo", "EAPI": 1 },
			"dev-libs/X-1": { "USE": "foo", "IUSE": "+foo", "EAPI": 1 },
			"dev-libs/W-1": { },
		}

		option_cobos = (
			(),
			("verbose",),
			("tree",),
			("tree", "unordered-display",),
			("verbose",),
			("verbose", "tree",),
			("verbose", "tree", "unordered-display",),
		)

		test_cases = []
		for options in option_cobos:
			testcase_opts = {}
			for opt in options:
				testcase_opts["--" + opt] = True

			test_cases.append(ResolverPlaygroundTestCase(
				["dev-libs/A"],
				options = testcase_opts,
				success = True,
				ignore_mergelist_order=True,
				mergelist = ["dev-libs/D-1", "dev-libs/E-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"]))

			test_cases.append(ResolverPlaygroundTestCase(
				["dev-libs/Z"],
				options = testcase_opts,
				success = True,
				mergelist = ["dev-libs/Z-1"]))

			test_cases.append(ResolverPlaygroundTestCase(
				["dev-libs/Y"],
				options = testcase_opts,
				success = True,
				mergelist = ["dev-libs/Y-1"]))

			test_cases.append(ResolverPlaygroundTestCase(
				["dev-libs/X"],
				options = testcase_opts,
				success = True,
				mergelist = ["dev-libs/X-1"]))

			test_cases.append(ResolverPlaygroundTestCase(
				["dev-libs/W"],
				options = testcase_opts,
				success = True,
				mergelist = ["dev-libs/W-1"]))

		playground = ResolverPlayground(ebuilds=ebuilds, installed=installed)
		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()