Merge lp:~spiv/bzr/test-isolation-speed into lp:bzr

Proposed by Andrew Bennetts
Status: Merged
Approved by: Martin Pool
Approved revision: 6018
Merged at revision: 6020
Proposed branch: lp:~spiv/bzr/test-isolation-speed
Merge into: lp:bzr
Diff against target: 48 lines (+15/-5)
2 files modified
bzrlib/tests/__init__.py (+9/-5)
doc/en/release-notes/bzr-2.4.txt (+6/-0)
To merge this branch: bzr merge lp:~spiv/bzr/test-isolation-speed
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+67475@code.launchpad.net

Commit message

Speed up TestCaseWithMemoryTransport._check_safety_net by reading the dirstate file directly rather than using WorkingTree.open().

Description of the change

This hack reduces the total time for the test suite to run on my laptop by perhaps 10%. It replaces the WorkingTree.open(root).last_revision() == 'null:' check in _check_safety_net with just comparing the raw bytes of the dirstate file to their pristine state.

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

cute

in theory we should see this show up in the babune graphs after it lands

Revision history for this message
Andrew Bennetts (spiv) wrote :

sent to pqm by email

lp:~spiv/bzr/test-isolation-speed updated
6019. By Andrew Bennetts

Merge lp:bzr/2.4.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2011-06-27 15:42:09 +0000
+++ bzrlib/tests/__init__.py 2011-07-11 02:09:17 +0000
@@ -2505,7 +2505,11 @@
2505 real branch.2505 real branch.
2506 """2506 """
2507 root = TestCaseWithMemoryTransport.TEST_ROOT2507 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'))
25092513
2510 def _check_safety_net(self):2514 def _check_safety_net(self):
2511 """Check that the safety .bzr directory have not been touched.2515 """Check that the safety .bzr directory have not been touched.
@@ -2514,10 +2518,10 @@
2514 propagating. This method ensures than a test did not leaked.2518 propagating. This method ensures than a test did not leaked.
2515 """2519 """
2516 root = TestCaseWithMemoryTransport.TEST_ROOT2520 root = TestCaseWithMemoryTransport.TEST_ROOT
2517 self.permit_url(_mod_transport.get_transport(root).base)2521 t = _mod_transport.get_transport(root)
2518 wt = workingtree.WorkingTree.open(root)2522 self.permit_url(t.base)
2519 last_rev = wt.last_revision()2523 if (t.get_bytes('.bzr/checkout/dirstate') !=
2520 if last_rev != 'null:':2524 TestCaseWithMemoryTransport._SAFETY_NET_PRISTINE_DIRSTATE):
2521 # The current test have modified the /bzr directory, we need to2525 # The current test have modified the /bzr directory, we need to
2522 # recreate a new one or all the followng tests will fail.2526 # recreate a new one or all the followng tests will fail.
2523 # If you need to inspect its content uncomment the following line2527 # If you need to inspect its content uncomment the following line
25242528
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- doc/en/release-notes/bzr-2.4.txt 2011-07-08 07:41:36 +0000
+++ doc/en/release-notes/bzr-2.4.txt 2011-07-11 02:09:17 +0000
@@ -63,6 +63,12 @@
63 due to the order that `build_snapshot` performs its actions.63 due to the order that `build_snapshot` performs its actions.
64 (Andrew Bennetts)64 (Andrew Bennetts)
6565
66* `TestCaseWithMemoryTransport` is faster now: `_check_safety_net` now
67 just compares the bytes in the dirstate file to its pristine state,
68 rather than opening the WorkingTree and calling ``last_revision()``.
69 This reduces the overall test suite time by about 10% on my laptop.
70 (Andrew Bennetts)
71
6672
67bzr 2.4b573bzr 2.4b5
68#########74#########