/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to doc/developers/testing.txt

Merge 2.0 into 2.1 including fixes for #262450, #373898, #498409

Show diffs side-by-side

added added

removed removed

Lines of Context:
317
317
.. ~~~~~~~~~~~~
318
318
 
319
319
 
 
320
Testing locking behaviour
 
321
-------------------------
 
322
 
 
323
In order to test the locking behaviour of commands, it is possible to install
 
324
a hook that is called when a write lock is: acquired, released or broken.
 
325
(Read locks also exist, they cannot be discovered in this way.)
 
326
 
 
327
A hook can be installed by calling bzrlib.lock.Lock.hooks.install_named_hook.
 
328
The three valid hooks are: `lock_acquired`, `lock_released` and `lock_broken`.
 
329
 
 
330
Example::
 
331
 
 
332
    locks_acquired = []
 
333
    locks_released = []
 
334
 
 
335
    lock.Lock.hooks.install_named_hook('lock_acquired',
 
336
        locks_acquired.append, None)
 
337
    lock.Lock.hooks.install_named_hook('lock_released',
 
338
        locks_released.append, None)
 
339
 
 
340
`locks_acquired` will now receive a LockResult instance for all locks acquired
 
341
since the time the hook is installed.
 
342
 
 
343
The last part of the `lock_url` allows you to identify the type of object that is locked.
 
344
 
 
345
- BzrDir: `/branch-lock`
 
346
- Working tree: `/checkout/lock`
 
347
- Branch: `/branch/lock`
 
348
- Repository: `/repository/lock`
 
349
 
 
350
To test if a lock is a write lock on a working tree, one can do the following::
 
351
 
 
352
    self.assertEndsWith(locks_acquired[0].lock_url, "/checkout/lock")
 
353
 
 
354
See bzrlib/tests/commands/test_revert.py for an example of how to use this for
 
355
testing locks.
 
356
 
320
357
 
321
358
Skipping tests
322
359
--------------
437
474
 
438
475
    self.requireFeature(StraceFeature)
439
476
 
440
 
Features already defined in bzrlib.tests include:
 
477
Available features
 
478
~~~~~~~~~~~~~~~~~~
 
479
 
 
480
Features already defined in bzrlib.tests or bzrlib.tests.features include:
441
481
 
442
482
 - SymlinkFeature,
443
483
 - HardlinkFeature,
444
484
 - OsFifoFeature,
445
485
 - UnicodeFilenameFeature,
446
 
 - FTPServerFeature, and
447
 
 - CaseInsensitiveFilesystemFeature.
 
486
 - FTPServerFeature
 
487
 - CaseInsensitiveFilesystemFeature
 
488
 - posix_permissions_feature: the test can rely on unix-style 
 
489
   permissions bits on files;
 
490
   generally true on Unix but not on all filesystems
448
491
 
449
492
 
450
493
Defining a new feature that tests can require