Merge lp:~abentley/bzr/config-cache-bugs into lp:bzr

Proposed by Aaron Bentley
Status: Merged
Approved by: Martin Packman
Approved revision: no longer in the source branch.
Merged at revision: 6487
Proposed branch: lp:~abentley/bzr/config-cache-bugs
Merge into: lp:bzr
Diff against target: 48 lines (+39/-0)
1 file modified
bzrlib/tests/test_branch.py (+39/-0)
To merge this branch: bzr merge lp:~abentley/bzr/config-cache-bugs
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
Review via email: mp+96227@code.launchpad.net

Description of the change

This branch adds tests for some config edge cases; cache coherence and
interoperation of branch.get_config() and branch.get_config_stack().

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks Aaron, the tests look useful.

review: Approve
Revision history for this message
Aaron Bentley (abentley) wrote :

These tests demonstrate two bugs:
#948344: BranchConfig and BranchStack do not interoperate correctly
#948339: BranchStack caching misbehaves

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/tests/test_branch.py'
--- bzrlib/tests/test_branch.py 2012-02-23 19:45:15 +0000
+++ bzrlib/tests/test_branch.py 2012-03-08 15:24:32 +0000
@@ -694,6 +694,45 @@
694 'Value "not-a-bool" is not valid for "append_revisions_only"',694 'Value "not-a-bool" is not valid for "append_revisions_only"',
695 self.warnings[0])695 self.warnings[0])
696696
697 def test_use_fresh_values(self):
698 copy = _mod_branch.Branch.open(self.branch.base)
699 copy.lock_write()
700 try:
701 copy.get_config_stack().set('foo', 'bar')
702 finally:
703 copy.unlock()
704 self.assertFalse(self.branch.is_locked())
705 result = self.branch.get_config_stack().get('foo')
706 # Bug: https://bugs.launchpad.net/bzr/+bug/948339
707 self.expectFailure('Unlocked branches cache their configs',
708 self.assertEqual, 'bar', result)
709
710 def test_set_from_config_get_from_config_stack(self):
711 self.branch.lock_write()
712 self.addCleanup(self.branch.unlock)
713 self.branch.get_config().set_user_option('foo', 'bar')
714 result = self.branch.get_config_stack().get('foo')
715 # https://bugs.launchpad.net/bzr/+bug/948344
716 self.expectFailure('BranchStack uses cache after set_user_option',
717 self.assertEqual, 'bar', result)
718
719 def test_set_from_config_stack_get_from_config(self):
720 self.branch.lock_write()
721 self.addCleanup(self.branch.unlock)
722 self.branch.get_config_stack().set('foo', 'bar')
723 self.assertEqual('bar',
724 self.branch.get_config().get_user_option('foo'))
725
726 def test_set_delays_write(self):
727 self.branch.lock_write()
728 self.addCleanup(self.branch.unlock)
729 self.branch.get_config_stack().set('foo', 'bar')
730 copy = _mod_branch.Branch.open(self.branch.base)
731 result = copy.get_config_stack().get('foo')
732 # Bug: https://bugs.launchpad.net/bzr/+bug/948339
733 self.expectFailure("Config writes are not cached.", self.assertIs,
734 None, result)
735
697736
698class TestPullResult(tests.TestCase):737class TestPullResult(tests.TestCase):
699738