Rev 3229: Merge in tests that demonstrate the failure to stack data correctly. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

Robert Collins robertc at robertcollins.net
Wed Feb 20 04:46:52 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

------------------------------------------------------------
revno: 3229
revision-id:robertc at robertcollins.net-20080220044647-5rws6n3tn2xfjfvr
parent: robertc at robertcollins.net-20080220004239-jieihiu0h1kno7fc
parent: robertc at robertcollins.net-20080220044500-vs5ywyhc85b2gavx
committer: Robert Collins <robertc at robertcollins.net>
branch nick: Development1
timestamp: Wed 2008-02-20 15:46:47 +1100
message:
  Merge in tests that demonstrate the failure to stack data correctly.
added:
  bzrlib/tests/repository_external_reference_implementations/ repository_external_-20080220025549-nnm2s80it1lvcwnc-1
  bzrlib/tests/repository_external_reference_implementations/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
  bzrlib/tests/repository_external_reference_implementations/test_add_inventory.py test_add_inventory.p-20080220025549-nnm2s80it1lvcwnc-3
  bzrlib/tests/repository_external_reference_implementations/test_add_revision.py test_add_revision.py-20080220034108-ao1u8qgakqbo5a08-1
  bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py test_add_signature_t-20080220041905-1j2g4lyz3c6h34v4-1
  bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py test_all_revision_id-20080220041905-1j2g4lyz3c6h34v4-2
  bzrlib/tests/repository_external_reference_implementations/test_break_lock.py test_break_lock.py-20080220042825-1f48qmpnuqqp5wg2-1
  bzrlib/tests/repository_external_reference_implementations/test_check.py test_check.py-20080220044229-sxxe747gzi6q8fyv-1
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
    ------------------------------------------------------------
    revno: 3227.1.2
    revision-id:robertc at robertcollins.net-20080220044500-vs5ywyhc85b2gavx
    parent: robertc at robertcollins.net-20080220030028-c3r2ue2nd4h3a1th
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: external_reference_tests
    timestamp: Wed 2008-02-20 15:45:00 +1100
    message:
      More external reference tests.
    added:
      bzrlib/tests/repository_external_reference_implementations/test_add_revision.py test_add_revision.py-20080220034108-ao1u8qgakqbo5a08-1
      bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py test_add_signature_t-20080220041905-1j2g4lyz3c6h34v4-1
      bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py test_all_revision_id-20080220041905-1j2g4lyz3c6h34v4-2
      bzrlib/tests/repository_external_reference_implementations/test_break_lock.py test_break_lock.py-20080220042825-1f48qmpnuqqp5wg2-1
      bzrlib/tests/repository_external_reference_implementations/test_check.py test_check.py-20080220044229-sxxe747gzi6q8fyv-1
    modified:
      bzrlib/tests/repository_external_reference_implementations/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
    ------------------------------------------------------------
    revno: 3227.1.1
    revision-id:robertc at robertcollins.net-20080220030028-c3r2ue2nd4h3a1th
    parent: robertc at robertcollins.net-20080220002317-5bdinlaczri004x2
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: external_reference_tests
    timestamp: Wed 2008-02-20 14:00:28 +1100
    message:
      Add add_inventory external reference interface tests and tweak broken test support function adapt_tests.
    added:
      bzrlib/tests/repository_external_reference_implementations/ repository_external_-20080220025549-nnm2s80it1lvcwnc-1
      bzrlib/tests/repository_external_reference_implementations/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
      bzrlib/tests/repository_external_reference_implementations/test_add_inventory.py test_add_inventory.p-20080220025549-nnm2s80it1lvcwnc-3
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
=== modified file 'NEWS'
--- a/NEWS	2008-02-19 04:11:34 +0000
+++ b/NEWS	2008-02-20 03:00:28 +0000
@@ -27,6 +27,9 @@
 
   TESTING:
 
+    * ``bzrlib.tests.adapt_tests`` was broken and unused - it has been fixed.
+      (Robert Collins)
+
   INTERNALS:
 
     * New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2008-02-06 00:41:04 +0000
+++ b/bzrlib/tests/__init__.py	2008-02-20 03:00:28 +0000
@@ -2705,6 +2705,7 @@
                    'bzrlib.tests.test_registry',
                    'bzrlib.tests.test_remote',
                    'bzrlib.tests.test_repository',
+                   'bzrlib.tests.repository_external_reference_implementations',
                    'bzrlib.tests.test_revert',
                    'bzrlib.tests.test_revision',
                    'bzrlib.tests.test_revisionnamespaces',
@@ -2897,16 +2898,16 @@
 
 def adapt_modules(mods_list, adapter, loader, suite):
     """Adapt the modules in mods_list using adapter and add to suite."""
-    for test in iter_suite_tests(loader.loadTestsFromModuleNames(mods_list)):
+    tests = loader.loadTestsFromModuleNames(mods_list)
+    adapt_tests(tests, adapter, suite)
+
+
+def adapt_tests(tests_list, adapter, suite):
+    """Adapt the tests in tests_list using adapter and add to suite."""
+    for test in iter_suite_tests(tests_list):
         suite.addTests(adapter.adapt(test))
 
 
-def adapt_tests(tests_list, adapter, loader, suite):
-    """Adapt the tests in tests_list using adapter and add to suite."""
-    for test in tests_list:
-        suite.addTests(adapter.adapt(loader.loadTestsFromName(test)))
-
-
 def _rmtree_temp_dir(dirname):
     # If LANG=C we probably have created some bogus paths
     # which rmtree(unicode) will fail to delete

=== added directory 'bzrlib/tests/repository_external_reference_implementations'
=== added file 'bzrlib/tests/repository_external_reference_implementations/__init__.py'
--- a/bzrlib/tests/repository_external_reference_implementations/__init__.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/__init__.py	2008-02-20 04:45:00 +0000
@@ -0,0 +1,102 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+"""Repository implementation tests for external reference repositories.
+
+These test the conformance of repositories which refer to other repositories
+for some data.
+"""
+
+from bzrlib import (
+    repository,
+    remote,
+    )
+from bzrlib.bzrdir import BzrDir
+from bzrlib.tests import (
+                          adapt_modules,
+                          adapt_tests,
+                          TestScenarioApplier,
+                          TestSuite,
+                          )
+from bzrlib.tests.repository_implementations import (
+    all_repository_format_scenarios,
+    TestCaseWithRepository,
+    )
+
+
+class TestCaseWithExternalReferenceRepository(TestCaseWithRepository):
+
+    def make_referring(self, relpath, target_path):
+        """Get a new repository that refers to a_repository.
+        
+        :param relpath: The path to create the repository at.
+        :param a_repository: A repository to refer to.
+        """
+        repo = self.make_repository(relpath)
+        repo.add_fallback_repository(self.readonly_repository(target_path))
+        return repo
+
+    def readonly_repository(self, relpath):
+        return BzrDir.open_from_transport(
+            self.get_readonly_transport(relpath)).open_repository()
+
+
+class TestCorrectFormat(TestCaseWithExternalReferenceRepository):
+
+    def test_repository_format(self):
+        # make sure the repository on tree.branch is of the desired format,
+        # because developers use this api to setup the tree, branch and 
+        # repository for their tests: having it not give the right repository
+        # type would invalidate the tests.
+        self.make_branch_and_tree('repo')
+        repo = self.make_referring('referring', 'repo')
+        self.assertIsInstance(repo._format,
+            self.repository_format.__class__)
+
+
+def load_tests(standard_tests, module, loader):
+    # format_scenarios is all the implementations of Repository; i.e. all disk
+    # formats plus RemoteRepository.
+    adapter = TestScenarioApplier()
+    scenarios = all_repository_format_scenarios()
+    adapter.scenarios = []
+    for scenario in scenarios:
+        format = scenario[1]['repository_format']
+        # For remote repositories, we need at least one external reference
+        # capable format to test it: defer this until landing such a format.
+        # if isinstance(format, remote.RemoteRepositoryFormat):
+        #     scenario[1]['bzrdir_format'].repository_format = 
+        if format.supports_external_lookups:
+            adapter.scenarios.append(scenario)
+
+    prefix = module.__name__ + '.test_'
+    test_repository_modules = [
+        'add_inventory',
+        'add_revision',
+        'add_signature_text',
+        'all_revision_ids',
+        'break_lock',
+        'check',
+        ]
+    module_name_list = [prefix + module_name
+        for module_name in test_repository_modules]
+
+    # Parameterize repository_implementations test modules by format.
+    result = TestSuite()
+    adapt_tests(standard_tests, adapter, result)
+    adapt_modules(module_name_list, adapter, loader, result)
+    return result

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_add_inventory.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_add_inventory.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_add_inventory.py	2008-02-20 03:00:28 +0000
@@ -0,0 +1,49 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for add_inventory on a repository with external references."""
+
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestAddInventory(TestCaseWithExternalReferenceRepository):
+
+    def test_add_inventory_goes_to_repo(self):
+        # adding an inventory only writes to the repository add_inventory is
+        # called on.
+        tree = self.make_branch_and_tree('sample')
+        revid = tree.commit('one')
+        inv = tree.branch.repository.get_inventory(revid)
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.lock_write()
+        try:
+            repo.start_write_group()
+            try:
+                repo.add_inventory(revid, inv, [])
+            except:
+                repo.abort_write_group()
+                raise
+            else:
+                repo.commit_write_group()
+        finally:
+            repo.unlock()
+        inv2 = repo.get_inventory(revid)
+        self.assertEqual(inv._byid, inv2._byid)
+        self.assertRaises(errors.RevisionNotPresent, base.get_inventory, revid)

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_add_revision.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_add_revision.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_add_revision.py	2008-02-20 04:45:00 +0000
@@ -0,0 +1,51 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for add_revision on a repository with external references."""
+
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestAddRevision(TestCaseWithExternalReferenceRepository):
+
+    def test_add_revision_goes_to_repo(self):
+        # adding a revision only writes to the repository add_revision is
+        # called on.
+        tree = self.make_branch_and_tree('sample')
+        revid = tree.commit('one')
+        inv = tree.branch.repository.get_inventory(revid)
+        rev = tree.branch.repository.get_revision(revid)
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.lock_write()
+        try:
+            repo.start_write_group()
+            try:
+                rev = tree.branch.repository.get_revision(revid)
+                repo.add_revision(revid, rev, inv=inv)
+            except:
+                repo.abort_write_group()
+                raise
+            else:
+                repo.commit_write_group()
+        finally:
+            repo.unlock()
+        rev2 = repo.get_revision(revid)
+        self.assertEqual(rev, rev2)
+        self.assertRaises(errors.NoSuchRevision, base.get_revision, revid)

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_add_signature_text.py	2008-02-20 04:45:00 +0000
@@ -0,0 +1,51 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for add_signature_text on a repository with external references."""
+
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestAddSignatureText(TestCaseWithExternalReferenceRepository):
+
+    def test_add_signature_text_goes_to_repo(self):
+        # adding a signature only writes to the repository add_signature_text
+        # is called on.
+        tree = self.make_branch_and_tree('sample')
+        revid = tree.commit('one')
+        inv = tree.branch.repository.get_inventory(revid)
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.lock_write()
+        try:
+            repo.start_write_group()
+            try:
+                rev = tree.branch.repository.get_revision(revid)
+                repo.add_revision(revid, rev, inv=inv)
+                repo.add_signature_text(revid, "text")
+            except:
+                repo.abort_write_group()
+                raise
+            else:
+                repo.commit_write_group()
+        finally:
+            repo.unlock()
+        repo.get_signature_text(revid)
+        self.assertRaises(errors.NoSuchRevision, base.get_signature_text,
+            revid)

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_all_revision_ids.py	2008-02-20 04:45:00 +0000
@@ -0,0 +1,64 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for all_revision_ids on a repository with external references."""
+
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestAllRevisionIds(TestCaseWithExternalReferenceRepository):
+
+    def test_all_revision_ids_empty(self):
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        self.assertEqual(set([]), repo.all_revision_ids())
+
+    def test_all_revision_ids_from_base(self):
+        tree = self.make_branch_and_tree('base')
+        revid = tree.commit('one')
+        repo = self.make_referring('referring', 'base')
+        self.assertEqual(set([revid]), repo.all_revision_ids())
+
+    def test_all_revision_ids_from_repo(self):
+        tree = self.make_branch_and_tree('spare')
+        revid = tree.commit('one')
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.fetch(tree.branch.repository, revid)
+        self.assertEqual(set([revid]), repo.all_revision_ids())
+
+    def test_all_revision_ids_from_both(self):
+        tree = self.make_branch_and_tree('spare')
+        revid = tree.commit('one')
+        base_tree = self.make_branch_and_tree('base')
+        revid2 = base_tree.commit('two')
+        repo = self.make_referring('referring', 'base')
+        repo.fetch(tree.branch.repository, revid)
+        self.assertEqual(set([revid, revid2]), repo.all_revision_ids())
+
+    def test_duplicate_ids_do_not_affect_length(self):
+        tree = self.make_branch_and_tree('spare')
+        revid = tree.commit('one')
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        repo.fetch(tree.branch.repository, revid)
+        base.fetch(tree.branch.repository, revid)
+        self.assertEqual(set([revid]), repo.all_revision_ids())
+        self.assertEqual(1, len(repo.all_revision_ids()))
+

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_break_lock.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_break_lock.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_break_lock.py	2008-02-20 04:45:00 +0000
@@ -0,0 +1,50 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for break_lock on a repository with external references."""
+
+import bzrlib.ui
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestBreakLock(TestCaseWithExternalReferenceRepository):
+
+    def test_break_lock(self):
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        unused_repo = repo.bzrdir.open_repository()
+        base.lock_write()
+        self.addCleanup(base.unlock)
+        # break_lock when locked should
+        repo.lock_write()
+        self.assertEqual(repo.get_physical_lock_status(),
+            unused_repo.get_physical_lock_status())
+        if not unused_repo.get_physical_lock_status():
+            # 'lock_write' has not taken a physical mutex out.
+            repo.unlock()
+            return
+        # we want a UI factory that accepts canned input for the tests:
+        # while SilentUIFactory still accepts stdin, we need to customise
+        # ours
+        self.old_factory = bzrlib.ui.ui_factory
+        self.addCleanup(self.restoreFactory)
+        bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
+        bzrlib.ui.ui_factory.stdin = StringIO("y\n")
+        unused_repo.break_lock()
+        self.assertRaises(errors.LockBroken, repo.unlock)

=== added file 'bzrlib/tests/repository_external_reference_implementations/test_check.py'
--- a/bzrlib/tests/repository_external_reference_implementations/test_check.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_external_reference_implementations/test_check.py	2008-02-20 04:45:00 +0000
@@ -0,0 +1,44 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for check on a repository with external references."""
+
+import bzrlib.ui
+from bzrlib import errors
+from bzrlib.tests.repository_external_reference_implementations import (
+    TestCaseWithExternalReferenceRepository,
+    )
+
+
+class TestCheck(TestCaseWithExternalReferenceRepository):
+
+    def test_check_file_graph_across_external_boundary_ok(self):
+        tree = self.make_branch_and_tree('base')
+        self.build_tree(['base/file'])
+        tree.add(['file'], ['file-id'])
+        rev1_id = tree.commit('one')
+        referring = self.make_branch_and_tree('referring')
+        readonly_base = self.readonly_repository('base')
+        referring.branch.repository.add_fallback_repository(readonly_base)
+        self.build_tree_contents([('referring/file', 'change')])
+        rev2_id = referring.commit('two')
+        check_result = referring.branch.repository.check(
+            referring.branch.repository.all_revision_ids())
+        check_result.report_results(verbose=False)
+        log = self._get_log(keep_log_file=True)
+        self.assertContainsRe(
+            log,
+            "0 inconsistent parents")

=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py	2008-02-20 00:42:39 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py	2008-02-20 04:46:47 +0000
@@ -50,42 +50,47 @@
 from bzrlib.transport.memory import MemoryServer
 
 
-class RepositoryTestProviderAdapter(TestScenarioApplier):
-    """A tool to generate a suite testing multiple repository formats at once.
+def formats_to_scenarios(formats, transport_server, transport_readonly_server,
+    vfs_transport_factory=None):
+    """Transform the input formats to a list of scenarios.
 
-    This is done by copying the test once for each transport and injecting
-    the transport_server, transport_readonly_server, and bzrdir_format and
-    repository_format classes into each copy. Each copy is also given a new id()
-    to make it easy to identify.
+    :param formats: A list of (repository_format, bzrdir_format).
     """
-
-    def __init__(self, transport_server, transport_readonly_server, formats,
-                 vfs_transport_factory=None):
-        TestScenarioApplier.__init__(self)
-        self._transport_server = transport_server
-        self._transport_readonly_server = transport_readonly_server
-        self._vfs_transport_factory = vfs_transport_factory
-        self.scenarios = self.formats_to_scenarios(formats)
-    
-    def formats_to_scenarios(self, formats):
-        """Transform the input formats to a list of scenarios.
-
-        :param formats: A list of (repository_format, bzrdir_format).
-        """
-        result = []
-        for repository_format, bzrdir_format in formats:
-            scenario = (repository_format.__class__.__name__,
-                {"transport_server":self._transport_server,
-                 "transport_readonly_server":self._transport_readonly_server,
-                 "bzrdir_format":bzrdir_format,
-                 "repository_format":repository_format,
-                 })
-            # Only override the test's vfs_transport_factory if one was
-            # specified, otherwise just leave the default in place.
-            if self._vfs_transport_factory:
-                scenario[1]['vfs_transport_factory'] = self._vfs_transport_factory
-            result.append(scenario)
-        return result
+    result = []
+    for repository_format, bzrdir_format in formats:
+        scenario = (repository_format.__class__.__name__,
+            {"transport_server":transport_server,
+             "transport_readonly_server":transport_readonly_server,
+             "bzrdir_format":bzrdir_format,
+             "repository_format":repository_format,
+             })
+        # Only override the test's vfs_transport_factory if one was
+        # specified, otherwise just leave the default in place.
+        if vfs_transport_factory:
+            scenario[1]['vfs_transport_factory'] = vfs_transport_factory
+        result.append(scenario)
+    return result
+
+
+def all_repository_format_scenarios():
+    """Return a list of test scenarios for parameterising repository tests."""
+    registry = repository.format_registry
+    all_formats = [registry.get(k) for k in registry.keys()]
+    all_formats.extend(weaverepo._legacy_formats)
+    # format_scenarios is all the implementations of Repository; i.e. all disk
+    # formats plus RemoteRepository.
+    format_scenarios = formats_to_scenarios(
+        [(format, format._matchingbzrdir) for format in all_formats],
+        default_transport,
+        # None here will cause a readonly decorator to be created
+        # by the TestCaseWithTransport.get_readonly_transport method.
+        None)
+    format_scenarios.extend(formats_to_scenarios(
+        [(RemoteRepositoryFormat(), RemoteBzrDirFormat())],
+        SmartTCPServer_for_testing,
+        ReadonlySmartTCPServer_for_testing,
+        MemoryServer))
+    return format_scenarios
 
 
 class TestCaseWithRepository(TestCaseWithBzrDir):
@@ -832,31 +837,9 @@
     IncorrectlyOrderedParentsScenario,
     UnreferencedFileParentsFromNoOpMergeScenario,
     ]
-    
+
 
 def test_suite():
-    registry = repository.format_registry
-    all_formats = [registry.get(k) for k in registry.keys()]
-    all_formats.extend(weaverepo._legacy_formats)
-    disk_format_adapter = RepositoryTestProviderAdapter(
-        default_transport,
-        # None here will cause a readonly decorator to be created
-        # by the TestCaseWithTransport.get_readonly_transport method.
-        None,
-        [(format, format._matchingbzrdir) for format in all_formats])
-
-    remote_repo_adapter = RepositoryTestProviderAdapter(
-        SmartTCPServer_for_testing,
-        ReadonlySmartTCPServer_for_testing,
-        [(RemoteRepositoryFormat(), RemoteBzrDirFormat())],
-        MemoryServer
-        )
-
-    # format_scenarios is all the implementations of Repository; i.e. all disk
-    # formats plus RemoteRepository.
-    format_scenarios = (disk_format_adapter.scenarios +
-                        remote_repo_adapter.scenarios)
-
     prefix = 'bzrlib.tests.repository_implementations.'
     test_repository_modules = [
         'test_add_fallback_repository',
@@ -883,6 +866,7 @@
                         for module_name in test_repository_modules]
 
     # Parameterize repository_implementations test modules by format.
+    format_scenarios = all_repository_format_scenarios()
     result = multiply_tests_from_modules(module_name_list, format_scenarios)
 
     # test_check_reconcile needs to be parameterized by format *and* by broken



More information about the bazaar-commits mailing list