~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-07-11 02:46:35 UTC
  • mfrom: (6017.1.2 test-isolation-speed)
  • Revision ID: pqm@pqm.ubuntu.com-20110711024635-f39c8kz23s347m1t
(spiv) Speed up TestCaseWithMemoryTransport._check_safety_net by reading the
 dirstate file directly rather than using WorkingTree.open(). (Andrew
 Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2505
2505
        real branch.
2506
2506
        """
2507
2507
        root = TestCaseWithMemoryTransport.TEST_ROOT
2508
 
        bzrdir.BzrDir.create_standalone_workingtree(root)
 
2508
        wt = bzrdir.BzrDir.create_standalone_workingtree(root)
 
2509
        # Hack for speed: remember the raw bytes of the dirstate file so that
 
2510
        # we don't need to re-open the wt to check it hasn't changed.
 
2511
        TestCaseWithMemoryTransport._SAFETY_NET_PRISTINE_DIRSTATE = (
 
2512
            wt.control_transport.get_bytes('dirstate'))
2509
2513
 
2510
2514
    def _check_safety_net(self):
2511
2515
        """Check that the safety .bzr directory have not been touched.
2514
2518
        propagating. This method ensures than a test did not leaked.
2515
2519
        """
2516
2520
        root = TestCaseWithMemoryTransport.TEST_ROOT
2517
 
        self.permit_url(_mod_transport.get_transport(root).base)
2518
 
        wt = workingtree.WorkingTree.open(root)
2519
 
        last_rev = wt.last_revision()
2520
 
        if last_rev != 'null:':
 
2521
        t = _mod_transport.get_transport(root)
 
2522
        self.permit_url(t.base)
 
2523
        if (t.get_bytes('.bzr/checkout/dirstate') != 
 
2524
                TestCaseWithMemoryTransport._SAFETY_NET_PRISTINE_DIRSTATE):
2521
2525
            # The current test have modified the /bzr directory, we need to
2522
2526
            # recreate a new one or all the followng tests will fail.
2523
2527
            # If you need to inspect its content uncomment the following line