Bind FEATURES=-test to USE=-test for bug #373209.
[portage.git] / pym / portage / tests / resolver / test_features_test_use.py
1 # Copyright 2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 from portage.tests import TestCase
5 from portage.tests.resolver.ResolverPlayground import (ResolverPlayground,
6         ResolverPlaygroundTestCase)
7
8 class FeaturesTestUse(TestCase):
9
10         def testFeaturesTestUse(self):
11                 ebuilds = {
12                         "dev-libs/A-1" : {
13                                 "IUSE": "test"
14                         },
15                         "dev-libs/B-1" : {
16                                 "IUSE": "test foo"
17                         },
18                 }
19
20                 installed = {
21                         "dev-libs/A-1" : {
22                                 "USE": "",
23                                 "IUSE": "test"
24                         },
25                         "dev-libs/B-1" : {
26                                 "USE": "foo",
27                                 "IUSE": "test foo"
28                         },
29                 }
30
31                 user_config = {
32                         "make.conf" : ("FEATURES=test", "USE=\"-test -foo\"")
33                 }
34
35                 test_cases = (
36
37                         # USE=test state should not trigger --newuse rebuilds, as
38                         # specified in bug #373209, comment #3.
39                         ResolverPlaygroundTestCase(
40                                 ["dev-libs/A"],
41                                 options = {"--newuse": True, "--selective": True},
42                                 success = True,
43                                 mergelist = []),
44
45                         # USE=-test -> USE=test, with USE=test forced by FEATURES=test
46                         ResolverPlaygroundTestCase(
47                                 ["dev-libs/A"],
48                                 options = {},
49                                 success = True,
50                                 mergelist = ["dev-libs/A-1"]),
51
52                         # USE=foo -> USE=-foo, with USE=test forced by FEATURES=test
53                         ResolverPlaygroundTestCase(
54                                 ["dev-libs/B"],
55                                 options = {"--newuse": True, "--selective": True},
56                                 success = True,
57                                 mergelist = ["dev-libs/B-1"]),
58                 )
59
60                 playground = ResolverPlayground(ebuilds=ebuilds,
61                         installed=installed, user_config=user_config, debug=False)
62                 try:
63                         for test_case in test_cases:
64                                 playground.run_TestCase(test_case)
65                                 self.assertEqual(test_case.test_success, True, test_case.fail_msg)
66                 finally:
67                         playground.cleanup()
68