aboutsummaryrefslogtreecommitdiff
blob: d06b8c173a711f77f7d99b16b5a9f76e899d9b29 (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
import sys
sys.path.append("../..")
from tinderbox import Tinderbox

import unittest
import portage
from util import flatten_deps

class TinderboxTest(unittest.TestCase):

    def setUp(self):
        self.tb = Tinderbox()
        self.trees = portage.create_trees()
        self.portapi = self.trees[portage.root]["porttree"].dbapi
        self.portset = portage.config(clone=portage.settings)
        self.pkgs = ['dev-db/hsqldb-1.8.0.10','app-shells/bash-3.2_p39','sys-apps/portage-2.1.4.5']

    def testCreateDepGroups(self):
        settings = self.portset
        portapi = self.portapi
        for pkg in self.pkgs:
            deps = portapi.aux_get(pkg, ["DEPEND"])
            deps = portage.dep.paren_reduce(deps[0])
            settings.setcpv(pkg, mydb=self.portapi)
            use_enabled = set(settings["PORTAGE_USE"].split())
            iuse = set(settings["IUSE"].split())
            use_deps = portage.dep.use_reduce(deps, list(use_enabled & iuse))

            use_deps = self.tb._normalize_dependencies(use_deps)
            use_deps = flatten_deps(use_deps)
            self.tb.create_dep_groups(use_deps)

    def testNormalizeDeps(self):
        settings = self.portset
        portapi = self.portapi
        for pkg in self.pkgs:
            deps = portapi.aux_get(pkg, ["DEPEND"])
            deps = portage.dep.paren_reduce(deps[0])
            settings.setcpv(pkg, mydb=self.portapi)
            use_enabled = set(settings["PORTAGE_USE"].split())
            iuse = set(settings["IUSE"].split())
            use_deps = portage.dep.use_reduce(deps, list(use_enabled & iuse))
            use_deps = self.tb._normalize_dependencies(use_deps)
            for dep in use_deps:
                self.assertTrue(portage.dep.isvalidatom(dep))




if __name__ == '__main__':
    unittest.main()