/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__known_graph.py

  • Committer: John Arbash Meinel
  • Date: 2009-08-17 16:35:07 UTC
  • mto: This revision was merged to the branch mainline in revision 4629.
  • Revision ID: john@arbash-meinel.com-20090817163507-0j9tdamcybwqu8rn
Add tests that we detect GraphCycleError

Turned out to be quite important, because otherwise KnownGraph.merge_sort()
ends up in an infinite loop w/ a GraphCycle.
(unlike topo_sort which pretty much just ignores those nodes.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
708
708
             (17, 'A', 0, (1,), True),
709
709
             ],
710
710
            )
 
711
 
 
712
    def test_ghost(self):
 
713
        # merge_sort should be able to ignore ghosts
 
714
        # A
 
715
        # |
 
716
        # B ghost
 
717
        # |/
 
718
        # C
 
719
        self.assertSortAndIterate(
 
720
            {'A': [],
 
721
             'B': ['A'],
 
722
             'C': ['B', 'ghost'],
 
723
            },
 
724
            'C',
 
725
            [(0, 'C', 0, (3,), False),
 
726
             (1, 'B', 0, (2,), False),
 
727
             (2, 'A', 0, (1,), True),
 
728
            ])
 
729
 
 
730
    def test_graph_cycle(self):
 
731
        # merge_sort should fail with a simple error when a graph cycle is
 
732
        # encountered.
 
733
        #
 
734
        # A
 
735
        # |,-.
 
736
        # B  |
 
737
        # |  |
 
738
        # C  ^
 
739
        # |  |
 
740
        # D  |
 
741
        # |'-'
 
742
        # E
 
743
        self.assertRaises(errors.GraphCycleError,
 
744
            self.assertSortAndIterate,
 
745
                {'A': [],
 
746
                 'B': ['D'],
 
747
                 'C': ['B'],
 
748
                 'D': ['C'],
 
749
                 'E': ['D'],
 
750
                },
 
751
                'E',
 
752
                [])