Mercurial > treepkg
comparison 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 |
comparison
equal
deleted
inserted
replaced
127:e83e96ef12b1 | 128:5155b4f9443d |
---|---|
12 import unittest | 12 import unittest |
13 | 13 |
14 from treepkg.run import call | 14 from treepkg.run import call |
15 from treepkg.cmdexpand import cmdexpand | 15 from treepkg.cmdexpand import cmdexpand |
16 from treepkg.util import writefile | 16 from treepkg.util import writefile |
17 from treepkg.packager import PackagerGroup, import_packager_module | 17 from treepkg.packager import PackagerGroup, import_packager_module, \ |
18 CyclicDependencyError | |
18 import treepkg.subversion as subversion | 19 import treepkg.subversion as subversion |
19 import treepkg | 20 import treepkg |
20 | 21 |
21 from filesupport import FileTestMixin | 22 from filesupport import FileTestMixin |
22 | 23 |
409 self.check_class_modules(module, [("PackageTrack", treepkg.packager), | 410 self.check_class_modules(module, [("PackageTrack", treepkg.packager), |
410 ("RevisionPackager", module)]) | 411 ("RevisionPackager", module)]) |
411 | 412 |
412 self.assertEquals(module.PackageTrack.revision_packager_cls, | 413 self.assertEquals(module.PackageTrack.revision_packager_cls, |
413 module.RevisionPackager) | 414 module.RevisionPackager) |
415 | |
416 | |
417 class PackageTrackWithDependencies(treepkg.packager.PackageTrack): | |
418 | |
419 def __init__(self, name, handle_dependencies, requires, provides): | |
420 defaults = dict(base_dir="/home/builder/tracks/" + name, | |
421 svn_url="svn://example.com", | |
422 root_cmd=["false"], | |
423 pbuilderrc="/home/builder/pbuilderrc", | |
424 deb_email="treepkg@example.com", deb_fullname="treepkg", | |
425 handle_dependencies=handle_dependencies) | |
426 super(PackageTrackWithDependencies, | |
427 self).__init__(name, **defaults) | |
428 self.dependencies = (set(requires.split()), set(provides.split())) | |
429 | |
430 def determine_dependencies(self): | |
431 pass | |
432 | |
433 | |
434 class TestPackageDependencies(unittest.TestCase): | |
435 | |
436 def test_track_order(self): | |
437 P = PackageTrackWithDependencies | |
438 tracks = [P("library", True, "base-dev", "library library-dev"), | |
439 P("other", False, "cdbs base-dev", "other"), | |
440 P("base", True, "", "base base-dev"), | |
441 P("program", True, "library-dev libc", "program program-doc"), | |
442 ] | |
443 group = PackagerGroup(tracks, 3600) | |
444 sorted_tracks = group.get_package_tracks() | |
445 track_indices = dict([(track.name, index) for index, track in | |
446 enumerate(sorted_tracks)]) | |
447 def check_order(track1, track2): | |
448 self.failUnless(track_indices[track1] < track_indices[track2]) | |
449 | |
450 check_order("base", "library") | |
451 check_order("library", "program") | |
452 check_order("base", "program") | |
453 | |
454 # sanity check whether other is still there. It doesn't matter | |
455 # where | |
456 self.failUnless("other" in track_indices) | |
457 | |
458 def test_track_order_cycle(self): | |
459 P = PackageTrackWithDependencies | |
460 tracks = [P("library", True, "base-dev", "library library-dev"), | |
461 P("cycle", True, "program", "cycle"), | |
462 P("other", False, "cdbs base-dev", "other"), | |
463 P("base", True, "cycle", "base base-dev"), | |
464 P("program", True, "library-dev libc", "program program-doc"), | |
465 ] | |
466 try: | |
467 group = PackagerGroup(tracks, 3600) | |
468 sorted_tracks = group.get_package_tracks() | |
469 except CyclicDependencyError, exc: | |
470 pass | |
471 else: | |
472 self.fail("PackagerGroup did not detect cyclic dependencies") |