aboutsummaryrefslogtreecommitdiff
blob: 0d01d069676bda7fc072d036b53e8614ed530b35 (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
# Copyright 2017 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 BinaryPkgEbuildVisibilityTestCase(TestCase):

	def testBinaryPkgEbuildVisibility(self):

		binpkgs = {
			"app-misc/foo-3" : {},
			"app-misc/foo-2" : {},
			"app-misc/foo-1" : {},
		}

		ebuilds = {
			"app-misc/foo-2" : {},
			"app-misc/foo-1" : {},
		}

		installed = {
			"app-misc/foo-1" : {},
		}

		world = ["app-misc/foo"]

		test_cases = (

			# Test bug #612960, where --use-ebuild-visibility failed
			# to reject binary packages for which ebuilds were not
			# available.
			ResolverPlaygroundTestCase(
				["@world"],
				options = {
					"--update": True,
					"--deep": True,
					"--use-ebuild-visibility": 'y',
					"--usepkgonly": True,
				},
				success = True,
				mergelist = [
					'[binary]app-misc/foo-2',
				],
			),

			ResolverPlaygroundTestCase(
				["@world"],
				options = {
					"--update": True,
					"--deep": True,
					"--usepkgonly": True,
				},
				success = True,
				mergelist = [
					'[binary]app-misc/foo-3',
				],
			),

			ResolverPlaygroundTestCase(
				["@world"],
				options = {
					"--update": True,
					"--deep": True,
					"--usepkg": True,
				},
				success = True,
				mergelist = [
					'[binary]app-misc/foo-2',
				],
			),

			ResolverPlaygroundTestCase(
				["=app-misc/foo-3"],
				options = {
					"--use-ebuild-visibility": 'y',
					"--usepkgonly": True,
				},
				success = False,
			),

			ResolverPlaygroundTestCase(
				["app-misc/foo"],
				options = {
					"--use-ebuild-visibility": 'y',
					"--usepkgonly": True,
				},
				success = True,
				mergelist = [
					'[binary]app-misc/foo-2',
				],
			),

			ResolverPlaygroundTestCase(
				["app-misc/foo"],
				options = {
					"--usepkgonly": True,
				},
				success = True,
				mergelist = [
					'[binary]app-misc/foo-3',
				],
			),

			# The default behavior is to enforce ebuild visibility as
			# long as a visible package is available to satisfy the
			# current atom. In the following test case, ebuild visibility
			# is ignored in order to satisfy the =app-misc/foo-3 atom.
			ResolverPlaygroundTestCase(
				["=app-misc/foo-3"],
				options = {
					"--usepkg": True,
				},
				success = True,
				mergelist = [
					'[binary]app-misc/foo-3',
				],
			),

			# Verify that --use-ebuild-visibility works with --usepkg
			# when no other visible package is available.
			ResolverPlaygroundTestCase(
				["=app-misc/foo-3"],
				options = {
					"--use-ebuild-visibility": "y",
					"--usepkg": True,
				},
				success = False,
			),
		)

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