[MERGE] More windows test fixes

Mark Hammond mhammond at skippinet.com.au
Fri Aug 15 02:06:27 BST 2008


> Comment:
> -        self.addCleanup(result_basis.unlock)
> -        self.assertEqual(expected_inventory, result_basis.inventory)
> +        try:
> +            self.assertEqual(expected_inventory,
> result_basis.inventory)
> +        finally:
> +            result_basis.unlock()
> 
> ^- Why is addCleanup not sufficient here?

Because the test later attempts to remove the directory with the lock, but
the cleanup functions do not run until the test completes.  Specifically,
without that change:

% bzr selftest UpdateToOneParentViaDeltaTests
Traceback (most recent call last):
  File "bzrlib\tests\workingtree_implementations\test_parents.py", line 677,
in test_removes
    new_shape, new_revid)
  File "bzrlib\tests\workingtree_implementations\test_parents.py", line 438,
in assertTransitionFromBasisToShape
    osutils.rmtree('tree')
  File "bzrlib\osutils.py", line 411, in rmtree
    return shutil.rmtree(path, ignore_errors, onerror)
  File "shutil.py", line 169, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "shutil.py", line 174, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "bzrlib\osutils.py", line 405, in _win32_delete_readonly
    function(path)
WindowsError: [Error 32] The process cannot access the file because it is
being used by another process: 'tree\\.bzr\\branch-lock'
[Exception repeated many times]
----------------------------------------------------------------------
Ran 51 tests in 25.460s
FAILED (errors=34)

With that patch:
Ran 51 tests in 13.940s
tests passed

> I guess I'm concerned because we use addCleanup in a lot of places,

I've no evidence addCleanup isn't called - it just isn't always appropriate
for closing files or removing locks due to its timing.

> real_os_link = getattr(os, 'link', None)
> if real_os_link is None:
>      raise TestNotApplicable('This platform does not provide os.link')
> 
> N/A because there isn't really a way for a user to provide the support.
> 
> I would also like to see us do it at the beginning of the test, so that
> you don't spend the time to do commit, etc, just to abort the test.

Done.

> The rest seems good.

cool - thanks.

Mark

-------------- next part --------------
A non-text attachment was scrubbed...
Name: files_in_use.patch
Type: application/octet-stream
Size: 15271 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080815/cc3eb2f1/attachment-0001.obj 


More information about the bazaar mailing list