aboutsummaryrefslogtreecommitdiff
blob: 233a9bbf47bb6269a124aa98fd5cc74b3fd6179e (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
# Copyright 2014-2020 Gentoo Authors
# 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 SlotConflictUnsatisfiedDeepDepsTestCase(TestCase):
    def testSlotConflictUnsatisfiedDeepDeps(self):
        ebuilds = {
            "dev-libs/A-1": {},
            "dev-libs/A-2": {"KEYWORDS": "~x86"},
            "dev-libs/B-1": {"DEPEND": "dev-libs/A"},
            "dev-libs/C-1": {"DEPEND": ">=dev-libs/A-2"},
            "dev-libs/D-1": {"DEPEND": "dev-libs/A"},
        }

        installed = {
            "dev-libs/broken-1": {
                "RDEPEND": "dev-libs/A dev-libs/initially-unsatisfied"
            },
        }

        world = (
            "dev-libs/A",
            "dev-libs/B",
            "dev-libs/C",
            "dev-libs/D",
            "dev-libs/broken",
        )

        test_cases = (
            # Test bug #520950, where unsatisfied deps of installed
            # packages are supposed to be ignored when they are beyond
            # the depth requested by the user.
            ResolverPlaygroundTestCase(
                ["dev-libs/B", "dev-libs/C", "dev-libs/D"],
                all_permutations=True,
                options={"--autounmask": "y", "--complete-graph": True},
                mergelist=[
                    "dev-libs/A-2",
                    "dev-libs/B-1",
                    "dev-libs/C-1",
                    "dev-libs/D-1",
                ],
                ignore_mergelist_order=True,
                unstable_keywords=["dev-libs/A-2"],
                unsatisfied_deps=[],
                success=False,
            ),
            ResolverPlaygroundTestCase(
                ["@world"],
                options={"--autounmask": "y", "--complete-graph": True},
                mergelist=[
                    "dev-libs/A-2",
                    "dev-libs/B-1",
                    "dev-libs/C-1",
                    "dev-libs/D-1",
                ],
                ignore_mergelist_order=True,
                unstable_keywords=["dev-libs/A-2"],
                unsatisfied_deps=["dev-libs/broken"],
                success=False,
            ),
            # Test --selective with --deep = 0
            ResolverPlaygroundTestCase(
                ["@world"],
                options={
                    "--autounmask": "y",
                    "--complete-graph": True,
                    "--selective": True,
                    "--deep": 0,
                },
                mergelist=[
                    "dev-libs/A-2",
                    "dev-libs/B-1",
                    "dev-libs/C-1",
                    "dev-libs/D-1",
                ],
                ignore_mergelist_order=True,
                unstable_keywords=["dev-libs/A-2"],
                unsatisfied_deps=[],
                success=False,
            ),
            # Test --deep = 1
            ResolverPlaygroundTestCase(
                ["@world"],
                options={
                    "--autounmask": "y",
                    "--autounmask-backtrack": "y",
                    "--complete-graph": True,
                    "--selective": True,
                    "--deep": 1,
                },
                mergelist=[
                    "dev-libs/A-2",
                    "dev-libs/B-1",
                    "dev-libs/C-1",
                    "dev-libs/D-1",
                ],
                ignore_mergelist_order=True,
                unstable_keywords=["dev-libs/A-2"],
                unsatisfied_deps=["dev-libs/initially-unsatisfied"],
                success=False,
            ),
            # With --autounmask-backtrack=y:
            # [ebuild  N    ~] dev-libs/A-2
            # [ebuild  N     ] dev-libs/C-1
            # [ebuild  N     ] dev-libs/D-1
            # [ebuild  N     ] dev-libs/B-1
            #
            # The following keyword changes are necessary to proceed:
            # (see "package.accept_keywords" in the portage(5) man page for more details)
            # required by dev-libs/C-1::test_repo
            # required by @selected
            # required by @world (argument)
            # =dev-libs/A-2 ~x86
            #
            #!!! Problems have been detected with your world file
            #!!! Please run emaint --check world
            #
            #
            #!!! Ebuilds for the following packages are either all
            #!!! masked or don't exist:
            # dev-libs/broken
            #
            # emerge: there are no ebuilds to satisfy "dev-libs/initially-unsatisfied".
            # (dependency required by "dev-libs/broken-1::test_repo" [installed])
            # (dependency required by "@selected" [set])
            # (dependency required by "@world" [argument])
            # Without --autounmask-backtrack=y:
            #!!! Multiple package instances within a single package slot have been pulled
            #!!! into the dependency graph, resulting in a slot conflict:
            #
            # dev-libs/A:0
            #
            #  (dev-libs/A-1:0/0::test_repo, ebuild scheduled for merge) pulled in by
            #    (no parents that aren't satisfied by other packages in this slot)
            #
            #  (dev-libs/A-2:0/0::test_repo, ebuild scheduled for merge) pulled in by
            #    >=dev-libs/A-2 required by (dev-libs/C-1:0/0::test_repo, ebuild scheduled for merge)
            #    ^^           ^
            #
            # The following keyword changes are necessary to proceed:
            # (see "package.accept_keywords" in the portage(5) man page for more details)
            # required by dev-libs/C-1::test_repo
            # required by @selected
            # required by @world (argument)
            # =dev-libs/A-2 ~x86
            #
            # emerge: there are no ebuilds to satisfy "dev-libs/initially-unsatisfied".
            # (dependency required by "dev-libs/broken-1::test_repo" [installed])
            # (dependency required by "@selected" [set])
            # (dependency required by "@world" [argument])
            # Test --deep = True
            ResolverPlaygroundTestCase(
                ["@world"],
                options={
                    "--autounmask": "y",
                    "--autounmask-backtrack": "y",
                    "--complete-graph": True,
                    "--selective": True,
                    "--deep": True,
                },
                mergelist=[
                    "dev-libs/A-2",
                    "dev-libs/B-1",
                    "dev-libs/C-1",
                    "dev-libs/D-1",
                ],
                ignore_mergelist_order=True,
                unstable_keywords=["dev-libs/A-2"],
                unsatisfied_deps=["dev-libs/initially-unsatisfied"],
                success=False,
            ),
            # The effects of --autounmask-backtrack are the same as the previous test case.
            # Both test cases can randomly succeed with --autounmask-backtrack=n, when
            # "backtracking due to unsatisfied dep" randomly occurs before the autounmask
            # unstable keyword change. It would be possible to eliminate backtracking here
            # by recognizing that there are no alternatives to satisfy the dev-libs/broken
            # atom in the world file. Then the test cases will consistently succeed with
            # --autounmask-backtrack=n.
        )

        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()