Mercurial > treepkg
diff test/test_packager.py @ 128:5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
PackageTrack now extracts dependency information from the debian/control
file and PackagerGroup sorts the tracks based on this information so
that packages on which other packages in the group depend on are built
first and their newly built binaries are installed added to the pbuilder
instance.
Also add some test cases.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Fri, 23 May 2008 16:11:22 +0000 |
parents | 34e08d52956e |
children | e1c7cd896310 |
line wrap: on
line diff
--- a/test/test_packager.py Thu May 22 19:13:12 2008 +0000 +++ b/test/test_packager.py Fri May 23 16:11:22 2008 +0000 @@ -14,7 +14,8 @@ from treepkg.run import call from treepkg.cmdexpand import cmdexpand from treepkg.util import writefile -from treepkg.packager import PackagerGroup, import_packager_module +from treepkg.packager import PackagerGroup, import_packager_module, \ + CyclicDependencyError import treepkg.subversion as subversion import treepkg @@ -411,3 +412,61 @@ self.assertEquals(module.PackageTrack.revision_packager_cls, module.RevisionPackager) + + +class PackageTrackWithDependencies(treepkg.packager.PackageTrack): + + def __init__(self, name, handle_dependencies, requires, provides): + defaults = dict(base_dir="/home/builder/tracks/" + name, + svn_url="svn://example.com", + root_cmd=["false"], + pbuilderrc="/home/builder/pbuilderrc", + deb_email="treepkg@example.com", deb_fullname="treepkg", + handle_dependencies=handle_dependencies) + super(PackageTrackWithDependencies, + self).__init__(name, **defaults) + self.dependencies = (set(requires.split()), set(provides.split())) + + def determine_dependencies(self): + pass + + +class TestPackageDependencies(unittest.TestCase): + + def test_track_order(self): + P = PackageTrackWithDependencies + tracks = [P("library", True, "base-dev", "library library-dev"), + P("other", False, "cdbs base-dev", "other"), + P("base", True, "", "base base-dev"), + P("program", True, "library-dev libc", "program program-doc"), + ] + group = PackagerGroup(tracks, 3600) + sorted_tracks = group.get_package_tracks() + track_indices = dict([(track.name, index) for index, track in + enumerate(sorted_tracks)]) + def check_order(track1, track2): + self.failUnless(track_indices[track1] < track_indices[track2]) + + check_order("base", "library") + check_order("library", "program") + check_order("base", "program") + + # sanity check whether other is still there. It doesn't matter + # where + self.failUnless("other" in track_indices) + + def test_track_order_cycle(self): + P = PackageTrackWithDependencies + tracks = [P("library", True, "base-dev", "library library-dev"), + P("cycle", True, "program", "cycle"), + P("other", False, "cdbs base-dev", "other"), + P("base", True, "cycle", "base base-dev"), + P("program", True, "library-dev libc", "program program-doc"), + ] + try: + group = PackagerGroup(tracks, 3600) + sorted_tracks = group.get_package_tracks() + except CyclicDependencyError, exc: + pass + else: + self.fail("PackagerGroup did not detect cyclic dependencies")