~bzr/bzr-bisect/trunk

« back to all changes in this revision

Viewing changes to tests.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-25 13:21:00 UTC
  • mfrom: (82.1.1 lazy)
  • Revision ID: jelmer@samba.org-20111125132100-6rr5ftv20h1w3tds
Merge support for lazy loading.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import shutil
24
24
 
25
25
import bzrlib
26
 
import bzrlib.bzrdir
27
 
import bzrlib.tests
28
 
import bzrlib.revisionspec
29
 
import bzrlib.plugins.bisect as bisect
 
26
from bzrlib.bzrdir import BzrDir
 
27
from bzrlib.plugins import bisect
 
28
from bzrlib.plugins.bisect import cmds
30
29
from bzrlib.tests import (
31
30
    KnownFailure,
 
31
    TestCaseWithTransport,
32
32
    TestSkipped,
33
33
    )
34
34
 
35
 
class BisectTestCase(bzrlib.tests.TestCaseWithTransport):
 
35
class BisectTestCase(TestCaseWithTransport):
36
36
    """Test harness specific to the bisect plugin."""
37
37
 
38
38
    def assertRevno(self, rev):
57
57
        # a branch from version 1 containing three revisions
58
58
        # merged at version 2.
59
59
 
60
 
        bzrlib.tests.TestCaseWithTransport.setUp(self)
61
 
 
 
60
        TestCaseWithTransport.setUp(self)
62
61
 
63
62
        self.tree = self.make_branch_and_tree(".")
64
63
 
74
73
                                                     'test_file_append')))
75
74
        self.tree.commit(message = "add test files")
76
75
 
77
 
        bzrlib.bzrdir.BzrDir.open(".").sprout("../temp-clone")
78
 
        clone_bzrdir = bzrlib.bzrdir.BzrDir.open("../temp-clone")
 
76
        BzrDir.open(".").sprout("../temp-clone")
 
77
        clone_bzrdir = BzrDir.open("../temp-clone")
79
78
        clone_tree = clone_bzrdir.open_workingtree()
80
79
        for content in ["one dot one", "one dot two", "one dot three"]:
81
80
            test_file = open("../temp-clone/test_file", "w")
157
156
        # Not a very good test; just makes sure the code doesn't fail,
158
157
        # not that the output makes any sense.
159
158
        sio = StringIO()
160
 
        bisect.BisectCurrent().show_rev_log(out=sio)
 
159
        cmds.BisectCurrent().show_rev_log(out=sio)
161
160
 
162
161
    def testShowLogSubtree(self):
163
162
        """Test that a subtree's log can be shown."""
164
 
        current = bisect.BisectCurrent()
 
163
        current = cmds.BisectCurrent()
165
164
        current.switch(self.subtree_rev)
166
165
        sio = StringIO()
167
166
        current.show_rev_log(out=sio)
168
167
 
169
168
    def testSwitchVersions(self):
170
169
        """Test switching versions."""
171
 
        current = bisect.BisectCurrent()
 
170
        current = cmds.BisectCurrent()
172
171
        self.assertRevno(5)
173
172
        current.switch(4)
174
173
        self.assertRevno(4)
175
174
 
176
175
    def testReset(self):
177
176
        """Test resetting the working tree to a non-bisected state."""
178
 
        current = bisect.BisectCurrent()
 
177
        current = cmds.BisectCurrent()
179
178
        current.switch(4)
180
179
        current.reset()
181
180
        self.assertRevno(5)
182
 
        assert not os.path.exists(bisect.bisect_rev_path)
 
181
        assert not os.path.exists(cmds.bisect_rev_path)
183
182
 
184
183
    def testIsMergePoint(self):
185
184
        """Test merge point detection."""
186
 
        current = bisect.BisectCurrent()
 
185
        current = cmds.BisectCurrent()
187
186
        self.assertRevno(5)
188
187
        assert not current.is_merge_point()
189
188
        current.switch(2)
195
194
 
196
195
    def testCreateBlank(self):
197
196
        """Test creation of new log."""
198
 
        bisect_log = bisect.BisectLog()
 
197
        bisect_log = cmds.BisectLog()
199
198
        bisect_log.save()
200
 
        assert os.path.exists(bisect.bisect_info_path)
 
199
        assert os.path.exists(cmds.bisect_info_path)
201
200
 
202
201
    def testLoad(self):
203
202
        """Test loading a log."""
204
 
        preloaded_log = open(bisect.bisect_info_path, "w")
 
203
        preloaded_log = open(cmds.bisect_info_path, "w")
205
204
        preloaded_log.write("rev1 yes\nrev2 no\nrev3 yes\n")
206
205
        preloaded_log.close()
207
206
 
208
 
        bisect_log = bisect.BisectLog()
 
207
        bisect_log = cmds.BisectLog()
209
208
        assert len(bisect_log._items) == 3
210
209
        assert bisect_log._items[0] == ("rev1", "yes")
211
210
        assert bisect_log._items[1] == ("rev2", "no")
213
212
 
214
213
    def testSave(self):
215
214
        """Test saving the log."""
216
 
        bisect_log = bisect.BisectLog()
 
215
        bisect_log = cmds.BisectLog()
217
216
        bisect_log._items = [("rev1", "yes"), ("rev2", "no"), ("rev3", "yes")]
218
217
        bisect_log.save()
219
218
 
220
 
        logfile = open(bisect.bisect_info_path)
 
219
        logfile = open(cmds.bisect_info_path)
221
220
        assert logfile.read() == "rev1 yes\nrev2 no\nrev3 yes\n"
222
221
 
223
222