~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_locking.py

  • Committer: Martin Pool
  • Date: 2009-09-14 01:48:28 UTC
  • mfrom: (4685 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4688.
  • Revision ID: mbp@sourcefrog.net-20090914014828-ydr9rlkdfq2sv57z
Merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for the (un)lock interfaces on all working tree implemenations."""
18
18
 
 
19
import sys
 
20
 
19
21
from bzrlib import (
20
22
    branch,
21
23
    errors,
22
24
    lockdir,
23
25
    )
 
26
from bzrlib.tests import TestSkipped
24
27
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
25
28
 
26
29
 
105
108
 
106
109
        :param methodname: The lock method to use to establish locks.
107
110
        """
 
111
        if sys.platform == "win32":
 
112
            raise TestSkipped("don't use oslocks on win32 in unix manner")
 
113
        # This helper takes a write lock on the source tree, then opens a
 
114
        # second copy and tries to grab a read lock. This works on Unix and is
 
115
        # a reasonable way to detect when the file is actually written to, but
 
116
        # it won't work (as a test) on Windows. It might be nice to instead
 
117
        # stub out the functions used to write and that way do both less work
 
118
        # and also be able to execute on Windows.
 
119
        self.thisFailsStrictLockCheck()
108
120
        # when unlocking the last lock count from tree_write_lock,
109
121
        # the tree should do a flush().
110
122
        # we test that by changing the inventory using set_root_id
128
140
        tree.set_root_id('new-root')
129
141
        # to detect that the inventory is written by unlock, we
130
142
        # first check that it was not written yet.
 
143
        # TODO: This requires taking a read lock while we are holding the above
 
144
        #       write lock, which shouldn't actually be possible
131
145
        reference_tree = tree.bzrdir.open_workingtree()
132
146
        self.assertEqual(old_root, reference_tree.get_root_id())
133
147
        # now unlock the second held lock, which should do nothing.