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
|
# Copyright 2011 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 MergeOrderTestCase(TestCase):
def testMergeOrder(self):
ebuilds = {
"app-misc/blocker-buildtime-a-1" : {},
"app-misc/blocker-buildtime-unbuilt-a-1" : {
"DEPEND" : "!app-misc/installed-blocker-a",
},
"app-misc/blocker-buildtime-unbuilt-hard-a-1" : {
"EAPI" : "2",
"DEPEND" : "!!app-misc/installed-blocker-a",
},
"app-misc/blocker-update-order-a-1" : {},
"app-misc/blocker-update-order-hard-a-1" : {},
"app-misc/blocker-update-order-hard-unsolvable-a-1" : {},
"app-misc/blocker-runtime-a-1" : {},
"app-misc/blocker-runtime-b-1" : {},
"app-misc/blocker-runtime-hard-a-1" : {},
"app-misc/circ-buildtime-a-0": {},
"app-misc/circ-buildtime-a-1": {
"RDEPEND": "app-misc/circ-buildtime-b",
},
"app-misc/circ-buildtime-b-1": {
"RDEPEND": "app-misc/circ-buildtime-c",
},
"app-misc/circ-buildtime-c-1": {
"DEPEND": "app-misc/circ-buildtime-a",
},
"app-misc/circ-buildtime-unsolvable-a-1": {
"RDEPEND": "app-misc/circ-buildtime-unsolvable-b",
},
"app-misc/circ-buildtime-unsolvable-b-1": {
"RDEPEND": "app-misc/circ-buildtime-unsolvable-c",
},
"app-misc/circ-buildtime-unsolvable-c-1": {
"DEPEND": "app-misc/circ-buildtime-unsolvable-a",
},
"app-misc/circ-post-runtime-a-1": {
"PDEPEND": "app-misc/circ-post-runtime-b",
},
"app-misc/circ-post-runtime-b-1": {
"RDEPEND": "app-misc/circ-post-runtime-c",
},
"app-misc/circ-post-runtime-c-1": {
"RDEPEND": "app-misc/circ-post-runtime-a",
},
"app-misc/circ-runtime-a-1": {
"RDEPEND": "app-misc/circ-runtime-b",
},
"app-misc/circ-runtime-b-1": {
"RDEPEND": "app-misc/circ-runtime-c",
},
"app-misc/circ-runtime-c-1": {
"RDEPEND": "app-misc/circ-runtime-a",
},
"app-misc/circ-satisfied-a-0": {
"RDEPEND": "app-misc/circ-satisfied-b",
},
"app-misc/circ-satisfied-a-1": {
"RDEPEND": "app-misc/circ-satisfied-b",
},
"app-misc/circ-satisfied-b-0": {
"RDEPEND": "app-misc/circ-satisfied-c",
},
"app-misc/circ-satisfied-b-1": {
"RDEPEND": "app-misc/circ-satisfied-c",
},
"app-misc/circ-satisfied-c-0": {
"DEPEND": "app-misc/circ-satisfied-a",
"RDEPEND": "app-misc/circ-satisfied-a",
},
"app-misc/circ-satisfied-c-1": {
"DEPEND": "app-misc/circ-satisfied-a",
"RDEPEND": "app-misc/circ-satisfied-a",
},
"app-misc/installed-blocker-a-1" : {
"EAPI" : "2",
"DEPEND" : "!app-misc/blocker-buildtime-a",
"RDEPEND" : "!app-misc/blocker-runtime-a !app-misc/blocker-runtime-b !!app-misc/blocker-runtime-hard-a",
},
"app-misc/installed-old-version-blocks-a-1" : {
"RDEPEND" : "!app-misc/blocker-update-order-a",
},
"app-misc/installed-old-version-blocks-a-2" : {},
"app-misc/installed-old-version-blocks-hard-a-1" : {
"EAPI" : "2",
"RDEPEND" : "!!app-misc/blocker-update-order-hard-a",
},
"app-misc/installed-old-version-blocks-hard-a-2" : {},
"app-misc/installed-old-version-blocks-hard-unsolvable-a-1" : {
"EAPI" : "2",
"RDEPEND" : "!!app-misc/blocker-update-order-hard-unsolvable-a",
},
"app-misc/installed-old-version-blocks-hard-unsolvable-a-2" : {
"DEPEND" : "app-misc/blocker-update-order-hard-unsolvable-a",
"RDEPEND" : "",
},
"app-misc/some-app-a-1": {
"RDEPEND": "app-misc/circ-runtime-a app-misc/circ-runtime-b",
},
"app-misc/some-app-b-1": {
"RDEPEND": "app-misc/circ-post-runtime-a app-misc/circ-post-runtime-b",
},
"app-misc/some-app-c-1": {
"RDEPEND": "app-misc/circ-buildtime-a app-misc/circ-buildtime-b",
},
}
installed = {
"app-misc/circ-buildtime-a-0": {},
"app-misc/circ-satisfied-a-0": {
"RDEPEND": "app-misc/circ-satisfied-b",
},
"app-misc/circ-satisfied-b-0": {
"RDEPEND": "app-misc/circ-satisfied-c",
},
"app-misc/circ-satisfied-c-0": {
"DEPEND": "app-misc/circ-satisfied-a",
"RDEPEND": "app-misc/circ-satisfied-a",
},
"app-misc/installed-blocker-a-1" : {
"EAPI" : "2",
"DEPEND" : "!app-misc/blocker-buildtime-a",
"RDEPEND" : "!app-misc/blocker-runtime-a !app-misc/blocker-runtime-b !!app-misc/blocker-runtime-hard-a",
},
"app-misc/installed-old-version-blocks-a-1" : {
"RDEPEND" : "!app-misc/blocker-update-order-a",
},
"app-misc/installed-old-version-blocks-hard-a-1" : {
"EAPI" : "2",
"RDEPEND" : "!!app-misc/blocker-update-order-hard-a",
},
"app-misc/installed-old-version-blocks-hard-unsolvable-a-1" : {
"EAPI" : "2",
"RDEPEND" : "!!app-misc/blocker-update-order-hard-unsolvable-a",
},
}
test_cases = (
ResolverPlaygroundTestCase(
["app-misc/some-app-a"],
success = True,
ambiguous_merge_order = True,
mergelist = [("app-misc/circ-runtime-a-1", "app-misc/circ-runtime-b-1", "app-misc/circ-runtime-c-1"), "app-misc/some-app-a-1"]),
ResolverPlaygroundTestCase(
["app-misc/some-app-a"],
success = True,
ambiguous_merge_order = True,
mergelist = [("app-misc/circ-runtime-c-1", "app-misc/circ-runtime-b-1", "app-misc/circ-runtime-a-1"), "app-misc/some-app-a-1"]),
# Test unsolvable circular dep that is RDEPEND in one
# direction and DEPEND in the other.
ResolverPlaygroundTestCase(
["app-misc/circ-buildtime-unsolvable-a"],
success = False,
circular_dependency_solutions = {}),
# Test optimal merge order for a circular dep that is
# RDEPEND in one direction and DEPEND in the other.
# This requires an installed instance of the DEPEND
# package in order to be solvable.
ResolverPlaygroundTestCase(
["app-misc/some-app-c", "app-misc/circ-buildtime-a"],
success = True,
ambiguous_merge_order = True,
mergelist = [("app-misc/circ-buildtime-b-1", "app-misc/circ-buildtime-c-1"), "app-misc/circ-buildtime-a-1", "app-misc/some-app-c-1"]),
# Test optimal merge order for a circular dep that is
# RDEPEND in one direction and PDEPEND in the other.
ResolverPlaygroundTestCase(
["app-misc/some-app-b"],
success = True,
ambiguous_merge_order = True,
mergelist = ["app-misc/circ-post-runtime-a-1", ("app-misc/circ-post-runtime-b-1", "app-misc/circ-post-runtime-c-1"), "app-misc/some-app-b-1"]),
# Test optimal merge order for a circular dep that is
# RDEPEND in one direction and DEPEND in the other,
# with all dependencies initially satisfied. Optimally,
# the DEPEND/buildtime dep should be updated before the
# package that depends on it, even though it's feasible
# to update it later since it is already satisfied.
ResolverPlaygroundTestCase(
["app-misc/circ-satisfied-a", "app-misc/circ-satisfied-b", "app-misc/circ-satisfied-c"],
success = True,
all_permutations = True,
ambiguous_merge_order = True,
merge_order_assertions = (("app-misc/circ-satisfied-a-1", "app-misc/circ-satisfied-c-1"),),
mergelist = [("app-misc/circ-satisfied-a-1", "app-misc/circ-satisfied-b-1", "app-misc/circ-satisfied-c-1")]),
# installed package has buildtime-only blocker
# that should be ignored
ResolverPlaygroundTestCase(
["app-misc/blocker-buildtime-a"],
success = True,
mergelist = ["app-misc/blocker-buildtime-a-1"]),
# We're installing a package that an old version of
# an installed package blocks. However, an update is
# available to the old package. The old package should
# be updated first, in order to solve the blocker without
# any need for blocking packages to temporarily overlap.
ResolverPlaygroundTestCase(
["app-misc/blocker-update-order-a", "app-misc/installed-old-version-blocks-a"],
success = True,
all_permutations = True,
mergelist = ["app-misc/installed-old-version-blocks-a-2", "app-misc/blocker-update-order-a-1"]),
# This is the same as above but with a hard blocker. The hard
# blocker is solved automatically since the update makes it
# irrelevant.
ResolverPlaygroundTestCase(
["app-misc/blocker-update-order-hard-a", "app-misc/installed-old-version-blocks-hard-a"],
success = True,
all_permutations = True,
mergelist = ["app-misc/installed-old-version-blocks-hard-a-2", "app-misc/blocker-update-order-hard-a-1"]),
# This is similar to the above case except that it's unsolvable
# due to merge order, unless bug 250286 is implemented so that
# the installed blocker will be unmerged before installation
# of the package it blocks (rather than after like a soft blocker
# would be handled). The "unmerge before" behavior requested
# in bug 250286 must be optional since essential programs or
# libraries may be temporarily unavailable during a
# non-overlapping update like this.
ResolverPlaygroundTestCase(
["app-misc/blocker-update-order-hard-unsolvable-a", "app-misc/installed-old-version-blocks-hard-unsolvable-a"],
success = False,
all_permutations = True,
ambiguous_merge_order = True,
merge_order_assertions = (('app-misc/blocker-update-order-hard-unsolvable-a-1', 'app-misc/installed-old-version-blocks-hard-unsolvable-a-2'),),
mergelist = [('app-misc/blocker-update-order-hard-unsolvable-a-1', 'app-misc/installed-old-version-blocks-hard-unsolvable-a-2', '!!app-misc/blocker-update-order-hard-unsolvable-a')]),
# The installed package has runtime blockers that
# should cause it to be uninstalled. The uninstall
# task is executed only after blocking packages have
# been merged.
# TODO: distinguish between install/uninstall tasks in mergelist
ResolverPlaygroundTestCase(
["app-misc/blocker-runtime-a", "app-misc/blocker-runtime-b"],
success = True,
all_permutations = True,
ambiguous_merge_order = True,
mergelist = [("app-misc/blocker-runtime-a-1", "app-misc/blocker-runtime-b-1"), "app-misc/installed-blocker-a-1", ("!app-misc/blocker-runtime-a", "!app-misc/blocker-runtime-b")]),
# We have a soft buildtime blocker against an installed
# package that should cause it to be uninstalled. Note that with
# soft blockers, the blocking packages are allowed to temporarily
# overlap. This allows any essential programs/libraries provided
# by both packages to be available at all times.
# TODO: distinguish between install/uninstall tasks in mergelist
ResolverPlaygroundTestCase(
["app-misc/blocker-buildtime-unbuilt-a"],
success = True,
mergelist = ["app-misc/blocker-buildtime-unbuilt-a-1", "app-misc/installed-blocker-a-1", "!app-misc/installed-blocker-a"]),
# We have a hard buildtime blocker against an installed
# package that will not resolve automatically (unless
# the option requested in bug 250286 is implemented).
ResolverPlaygroundTestCase(
["app-misc/blocker-buildtime-unbuilt-hard-a"],
success = False,
mergelist = ['app-misc/blocker-buildtime-unbuilt-hard-a-1', '!!app-misc/installed-blocker-a']),
# An installed package has a hard runtime blocker that
# will not resolve automatically (unless the option
# requested in bug 250286 is implemented).
ResolverPlaygroundTestCase(
["app-misc/blocker-runtime-hard-a"],
success = False,
mergelist = ['app-misc/blocker-runtime-hard-a-1', '!!app-misc/blocker-runtime-hard-a']),
)
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()
|