aboutsummaryrefslogtreecommitdiff
blob: c0316bfb3f844aa84967bd11471653793729617c (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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# Copyright 2013-2015 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 OrChoicesTestCase(TestCase):

	def testOrChoices(self):
		ebuilds = {
			"dev-lang/vala-0.20.0" : {
				"EAPI": "5",
				"SLOT": "0.20"
			},
			"dev-lang/vala-0.18.0" : {
				"EAPI": "5",
				"SLOT": "0.18"
			},
			#"dev-libs/gobject-introspection-1.36.0" : {
			#	"EAPI": "5",
			#	"RDEPEND" : "!<dev-lang/vala-0.20.0",
			#},
			"dev-libs/gobject-introspection-1.34.0" : {
				"EAPI": "5"
			},
			"sys-apps/systemd-ui-2" : {
				"EAPI": "5",
				"RDEPEND" : "|| ( dev-lang/vala:0.20 dev-lang/vala:0.18 )"
			},
		}

		installed = {
			"dev-lang/vala-0.18.0" : {
				"EAPI": "5",
				"SLOT": "0.18"
			},
			"dev-libs/gobject-introspection-1.34.0" : {
				"EAPI": "5"
			},
			"sys-apps/systemd-ui-2" : {
				"EAPI": "5",
				"RDEPEND" : "|| ( dev-lang/vala:0.20 dev-lang/vala:0.18 )"
			},
		}

		world = ["dev-libs/gobject-introspection", "sys-apps/systemd-ui"]

		test_cases = (
			# Demonstrate that vala:0.20 update is pulled in, for bug #478188
			ResolverPlaygroundTestCase(
				["@world"],
				options = {"--update": True, "--deep": True},
				success=True,
				all_permutations = True,
				mergelist = ['dev-lang/vala-0.20.0']),
			# Verify that vala:0.20 is not pulled in without --deep
			ResolverPlaygroundTestCase(
				["@world"],
				options = {"--update": True},
				success=True,
				all_permutations = True,
				mergelist = []),
			# Verify that vala:0.20 is not pulled in without --update
			ResolverPlaygroundTestCase(
				["@world"],
				options = {"--selective": True, "--deep": True},
				success=True,
				all_permutations = True,
				mergelist = []),
		)

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

	def testInitiallyUnsatisfied(self):

		ebuilds = {

			"app-misc/A-1" : {
				"EAPI": "5",
				"SLOT": "0/1"
			},

			"app-misc/A-2" : {
				"EAPI": "5",
				"SLOT": "0/2"
			},

			"app-misc/B-0" : {
				"EAPI": "5",
				"RDEPEND": "app-misc/A:="
			},

			"app-misc/C-0" : {
				"EAPI": "5",
				"RDEPEND": "|| ( app-misc/X <app-misc/A-2 )"
			},

		}

		installed = {

			"app-misc/A-1" : {
				"EAPI": "5",
				"SLOT": "0/1"
			},

			"app-misc/B-0" : {
				"EAPI": "5",
				"RDEPEND": "app-misc/A:0/1="
			},

			"app-misc/C-0" : {
				"EAPI": "5",
				"RDEPEND": "|| ( app-misc/X <app-misc/A-2 )"
			},

		}

		world = ["app-misc/B", "app-misc/C"]

		test_cases = (

			# Test bug #522652, where the unsatisfiable app-misc/X
			# atom is selected, and the dependency is placed into
			# _initially_unsatisfied_deps where it is ignored, causing
			# upgrade to app-misc/A-2 (breaking a dependency of
			# app-misc/C-0).
			ResolverPlaygroundTestCase(
				["app-misc/A"],
				options = {},
				success = True,
				mergelist = ['app-misc/A-1']
			),

		)

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


	def testUseMask(self):

		profile = {
			"use.mask":
			(
				"abi_ppc_32",
			),
		}

		ebuilds = {

			"sys-libs/A-1" : {
				"EAPI": "5",
				"RDEPEND": "|| ( sys-libs/zlib[abi_ppc_32(-)] " + \
					"sys-libs/zlib[abi_x86_32(-)] )"
			},

			"sys-libs/zlib-1.2.8-r1" : {
				"EAPI": "5",
				"IUSE": "abi_ppc_32 abi_x86_32"
			},

			"sys-libs/zlib-1.2.8" : {
				"EAPI": "5",
				"IUSE": ""
			},
		}

		test_cases = (

			# bug #515584: We want to prefer choices that do
			# not require changes to use.mask or use.force.
			# In this case, abi_ppc_32 is use.masked in the
			# profile, so we want to avoid that choice.
			ResolverPlaygroundTestCase(
				["sys-libs/A"],
				options = {},
				success = False,
				use_changes = {
					'sys-libs/zlib-1.2.8-r1': {'abi_x86_32': True}
				},
				mergelist = ["sys-libs/zlib-1.2.8-r1", "sys-libs/A-1"]
			),

		)

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

	def testConflictMissedUpdate(self):

		ebuilds = {
			"dev-lang/ocaml-4.02.1" : {
				"EAPI": "5",
				"SLOT": "0/4.02.1",
			},

			"dev-lang/ocaml-4.01.0" : {
				"EAPI": "5",
				"SLOT": "0/4.01.0",
			},

			"dev-ml/lablgl-1.05" : {
				"EAPI": "5",
				"DEPEND": (">=dev-lang/ocaml-3.10.2:= "
					"|| ( dev-ml/labltk:= <dev-lang/ocaml-4.02 )"),
				"RDEPEND": (">=dev-lang/ocaml-3.10.2:= "
					"|| ( dev-ml/labltk:= <dev-lang/ocaml-4.02 )"),
			},

			"dev-ml/labltk-8.06.0" : {
				"EAPI": "5",
				"SLOT": "0/8.06.0",
				"DEPEND": ">=dev-lang/ocaml-4.02:=",
				"RDEPEND": ">=dev-lang/ocaml-4.02:=",
			},
		}

		installed = {
			"dev-lang/ocaml-4.01.0" : {
				"EAPI": "5",
				"SLOT": "0/4.01.0",
			},

			"dev-ml/lablgl-1.05" : {
				"EAPI": "5",
				"DEPEND": (">=dev-lang/ocaml-3.10.2:0/4.01.0= "
					"|| ( dev-ml/labltk:= <dev-lang/ocaml-4.02 )"),
				"RDEPEND": (">=dev-lang/ocaml-3.10.2:0/4.01.0= "
					"|| ( dev-ml/labltk:= <dev-lang/ocaml-4.02 )"),
			},
		}

		world = (
			"dev-lang/ocaml",
			"dev-ml/lablgl",
		)

		test_cases = (

			# bug #531656: If an ocaml update is desirable,
			# then we need to pull in dev-ml/labltk.
			ResolverPlaygroundTestCase(
				["@world"],
				options = {"--update": True, "--deep": True},
				success = True,
				mergelist = [
					"dev-lang/ocaml-4.02.1",
					"dev-ml/labltk-8.06.0",
					"dev-ml/lablgl-1.05",
				]
			),

		)

		playground = ResolverPlayground(debug=False,
			ebuilds=ebuilds, installed=installed, world=world)
		try:
			for test_case in test_cases:
				playground.run_TestCase(test_case)
				self.assertEqual(test_case.test_success, True,
					test_case.fail_msg)
		finally:
			# Disable debug so that cleanup works.
			playground.debug = False
			playground.cleanup()

class OrChoicesLibpostprocTestCase(TestCase):

	def testOrChoicesLibpostproc(self):

		ebuilds = {
			"media-video/ffmpeg-0.10" : {
				"EAPI": "5",
				"SLOT": "0.10"
			},
			"media-video/ffmpeg-1.2.2" : {
				"EAPI": "5",
				"SLOT": "0"
			},
			"media-libs/libpostproc-0.8.0.20121125" : {
				"EAPI": "5"
			},
			"media-plugins/gst-plugins-ffmpeg-0.10.13_p201211-r1" : {
				"EAPI": "5",
				"RDEPEND" : "|| ( media-video/ffmpeg:0 media-libs/libpostproc )"
			},
		}

		installed = {
			"media-video/ffmpeg-0.10" : {
				"EAPI": "5",
				"SLOT": "0.10"
			},
			"media-libs/libpostproc-0.8.0.20121125" : {
				"EAPI": "5"
			},
			"media-plugins/gst-plugins-ffmpeg-0.10.13_p201211-r1" : {
				"EAPI": "5",
				"RDEPEND" : "|| ( media-video/ffmpeg:0 media-libs/libpostproc )"
			},
		}

		world = ["media-plugins/gst-plugins-ffmpeg"]

		test_cases = (
			# Demonstrate that libpostproc is preferred
			# over ffmpeg:0 for bug #480736.
			ResolverPlaygroundTestCase(
				["@world"],
				options = {"--update": True, "--deep": True},
				success=True,
				all_permutations = True,
				mergelist = []),
		)

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