[MERGE] More than double the speed of "bzr selftest"

Alexander Belchenko bialix at ukr.net
Wed Apr 18 05:23:03 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew Bennetts пишет:
> Now that I've got your attention ;)
> 
> It did it as a quick hack, so comments welcome.

> === modified file bzrlib/tests/__init__.py
> --- bzrlib/tests/__init__.py
> +++ bzrlib/tests/__init__.py
> @@ -36,6 +36,7 @@
>  from pprint import pformat
>  import re
>  import shlex
> +import shutil
>  import stat
>  from subprocess import Popen, PIPE
>  import sys
> @@ -1833,6 +1834,18 @@
>              self.log("actually: %r" % contents)
>              self.fail("contents of %s not as expected" % filename)
>  
> +    def run(self, result=None):
> +        try:
> +            return TestCaseWithMemoryTransport.run(self, result=result)
> +        finally:
> +            # If the test passed, we can delete its temporary files.
> +            if result is not None and result.wasSuccessful():
> +                # If the test raised TestSkipped during setUp, test_dir might
> +                # not be set.
> +                if getattr(self, 'test_dir', None) is not None:
> +                    assert self.test_dir.endswith('/work'), self.test_dir
> +                    shutil.rmtree(self.test_dir[:-len('/work')])
> +
>      def makeAndChdirToTestDir(self):
>          """See TestCaseWithMemoryTransport.makeAndChdirToTestDir().

Andrew, my changes is now in bzr.dev, so you can use special function
in bzrlib.tests.__init__: _rmtree_temp_dir(dirname) instead of shutil.rmtree()
for new version of your patch.
My function provides safe rmtree for our test suite.

[µ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGJZ0mzYr338mxwCURAh/2AJ0e8FuhjGevATIfd1jCnNPiNIu/eQCeOKYR
uilqSisHiXjl6wXiV+3P0VE=
=MWaK
-----END PGP SIGNATURE-----



More information about the bazaar mailing list