aboutsummaryrefslogtreecommitdiff
blob: b566cb5921444c4e22217a3e696baf9ee82d7ec8 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# Copyright 2017-2018 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 VirtualMinimizeChildrenTestCase(TestCase):

	def testVirtualMinimizeChildren(self):
		ebuilds = {
			'app-misc/bar-1': {
				'EAPI': '6',
				'RDEPEND': 'virtual/foo'
			},
			'virtual/foo-1': {
				'EAPI': '6',
				'RDEPEND': '|| ( app-misc/A app-misc/B ) || ( app-misc/B app-misc/C )'
			},
			'app-misc/A-1': {
				'EAPI': '6',
			},
			'app-misc/B-1': {
				'EAPI': '6',
			},
			'app-misc/C-1': {
				'EAPI': '6',
			},
		}

		test_cases = (
			# Test bug 632026, where we want to minimize the number of
			# packages chosen to satisfy overlapping || deps like
			# "|| ( foo bar ) || ( bar baz )".
			ResolverPlaygroundTestCase(
				['app-misc/bar'],
				success=True,
				mergelist=[
					'app-misc/B-1',
					'virtual/foo-1',
					'app-misc/bar-1',
				],
			),
		)

		playground = ResolverPlayground(debug=False,
			ebuilds=ebuilds)

		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.debug = False
			playground.cleanup()

		# If app-misc/A and app-misc/C are installed then
		# that choice should be preferred over app-misc/B.
		installed = {
			'app-misc/A-1': {
				'EAPI': '6',
			},
			'app-misc/C-1': {
				'EAPI': '6',
			},
		}

		test_cases = (
			ResolverPlaygroundTestCase(
				['app-misc/bar'],
				success=True,
				mergelist=[
					'virtual/foo-1',
					'app-misc/bar-1',
				],
			),
		)

		playground = ResolverPlayground(debug=False,
			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.debug = False
			playground.cleanup()

	def testOverlapSlotConflict(self):
		ebuilds = {
			'app-misc/bar-1': {
				'EAPI': '6',
				'RDEPEND': 'virtual/foo'
			},
			'virtual/foo-1': {
				'EAPI': '6',
				'RDEPEND': '|| ( app-misc/A >=app-misc/B-2 ) || ( <app-misc/B-2 app-misc/C )'
			},
			'app-misc/A-1': {
				'EAPI': '6',
			},
			'app-misc/B-2': {
				'EAPI': '6',
			},
			'app-misc/B-1': {
				'EAPI': '6',
			},
			'app-misc/C-1': {
				'EAPI': '6',
			},
		}

		test_cases = (
			# Here the ( >=app-misc/B-2 <app-misc/B-2 ) choice is not satisfiable.
			ResolverPlaygroundTestCase(
				['app-misc/bar'],
				success=True,
				ambiguous_merge_order=True,
				mergelist=[
					(
						'app-misc/C-1',
						'app-misc/A-1',
					),
					'virtual/foo-1',
					'app-misc/bar-1',
				]
			),
		)

		playground = ResolverPlayground(debug=False,
			ebuilds=ebuilds)

		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.debug = False
			playground.cleanup()

	def testVirtualPackageManager(self):
		ebuilds = {
			'app-admin/perl-cleaner-2.25': {
				'RDEPEND': '''
					|| (
						( sys-apps/portage app-portage/portage-utils )
						sys-apps/pkgcore
						sys-apps/paludis
					)'''
			},
			'app-portage/portage-utils-0.64': {},
			'sys-apps/paludis-2.6.0': {},
			'sys-apps/portage-2.3.19-r1': {},
			'virtual/package-manager-0': {
				'RDEPEND': '''
					|| (
						sys-apps/portage
						sys-apps/paludis
						sys-apps/pkgcore
					)'''
			},
		}

		test_cases = (
			# Test bug 645002, where paludis was selected to satisfy a
			# perl-cleaner dependency because that choice contained fewer
			# packages than the ( portage portage-utils ) choice which
			# should have been preferred according to the order of
			# choices specified in the ebuild.
			ResolverPlaygroundTestCase(
				[
					'app-admin/perl-cleaner',
					'virtual/package-manager',
				],
				all_permutations=True,
				success=True,
				ambiguous_merge_order=True,
				mergelist=(
					(
						'sys-apps/portage-2.3.19-r1',
						'app-portage/portage-utils-0.64',
						'app-admin/perl-cleaner-2.25',
						'virtual/package-manager-0',
					),
				)
			),
			# Test paludis preference. In this case, if paludis is not
			# included in the argument atoms then the result varies
			# depending on whether the app-admin/perl-cleaner or
			# virtual/package-manager dependencies are evaluated first!
			# Therefore, include paludis in the argument atoms.
			ResolverPlaygroundTestCase(
				[
					'app-admin/perl-cleaner',
					'virtual/package-manager',
					'sys-apps/paludis',
				],
				all_permutations=True,
				success=True,
				ambiguous_merge_order=True,
				mergelist=(
					'sys-apps/paludis-2.6.0',
					(
						'app-admin/perl-cleaner-2.25',
						'virtual/package-manager-0',
					),
				)
			),
		)

		playground = ResolverPlayground(debug=False, ebuilds=ebuilds)

		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.debug = False
			playground.cleanup()

	def testVirtualDevManager(self):
		ebuilds = {
			'sys-fs/eudev-3.1.5': {},
			'sys-fs/static-dev-0.1': {},
			'sys-fs/udev-233': {},
			'virtual/dev-manager-0': {
				'RDEPEND': '''
					|| (
						virtual/udev
						sys-fs/static-dev
					)'''
			},
			'virtual/udev-0': {
				'RDEPEND': '''
					|| (
						>=sys-fs/eudev-2.1.1
						>=sys-fs/udev-217
					)'''
			},
		}

		test_cases = (
			# Test bug 645190, where static-dev was pulled in instead
			# of eudev.
			ResolverPlaygroundTestCase(
				[
					'virtual/dev-manager',
				],
				success=True,
				mergelist=(
					'sys-fs/eudev-3.1.5',
					'virtual/udev-0',
					'virtual/dev-manager-0',
				),
			),
			# Test static-dev preference.
			ResolverPlaygroundTestCase(
				[
					'sys-fs/static-dev',
					'virtual/dev-manager',
				],
				all_permutations=True,
				success=True,
				mergelist=(
					'sys-fs/static-dev-0.1',
					'virtual/dev-manager-0',
				),
			),
		)

		playground = ResolverPlayground(debug=False, ebuilds=ebuilds)

		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.debug = False
			playground.cleanup()