~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/developers/HACKING

  • Committer: Robert Collins
  • Date: 2007-07-19 06:34:09 UTC
  • mto: (2592.3.46 repository)
  • mto: This revision was merged to the branch mainline in revision 2651.
  • Revision ID: robertc@robertcollins.net-20070719063409-stu9sckrxp8wp3mo
LIBRARY API BREAKS:

  * KnitIndex.get_parents now returns tuples. (Robert Collins)

INTERNALS:

  * Unused functions on the private interface KnitIndex have been removed.
    (Robert Collins)

  * New ``knit.KnitGraphIndex`` which provides a ``KnitIndex`` layered on top
    of a ``index.GraphIndex``. (Robert Collins)

  * New ``knit.KnitVersionedFile.iter_parents`` method that allows querying
    the parents of many knit nodes at once, reducing round trips to the 
    underlying index. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
.. contents::
6
6
 
7
 
(The current version of this document is available in the file 
8
 
``doc/developers/HACKING.txt`` in the source tree, or at
9
 
http://doc.bazaar-vcs.org/bzr.dev/developers/HACKING.html)
 
7
(The current version of this document is available in the file ``HACKING``
 
8
in the source tree, or at http://doc.bazaar-vcs.org/bzr.dev/hacking.html)
10
9
 
11
10
 
12
11
Getting Started
149
148
Anyone can "vote" on the mailing list. Core developers can also vote using
150
149
Bundle Buggy. Here are the voting codes and their explanations.
151
150
 
152
 
:approve:  Reviewer wants this submission merged.
153
 
:tweak:    Reviewer wants this submission merged with small changes. (No
154
 
  re-review required.)
155
 
:abstain:  Reviewer does not intend to vote on this patch.
156
 
:resubmit: Please make changes and resubmit for review.
157
 
:reject:   Reviewer doesn't want this kind of change merged.
158
 
:comment:  Not really a vote. Reviewer just wants to comment, for now.
159
 
 
160
 
If a change gets two approvals from core reviewers, and no rejections,
161
 
then it's OK to come in.  Any of the core developers can bring it into the
162
 
bzr.dev trunk and backport it to maintenance branches if required.  The
163
 
Release Manager will merge the change into the branch for a pending
 
151
  -1    really don't want it in current form
 
152
  -0    somewhat uncomfortable 
 
153
  +0    comfortable but resubmission after changes requested
 
154
  +1 conditional        good to go after some minor changes
 
155
  +1    good to go
 
156
 
 
157
+1 conditional is used as a way to avoid another submit/review cycle for
 
158
patches that need small changes.
 
159
 
 
160
If a change gets two +1 votes from core reviewers, and no
 
161
vetos, then it's OK to come in.  Any of the core developers can bring it
 
162
into the bzr.dev trunk and backport it to maintenance branches if required.
 
163
The Release Manager will merge the change into the branch for a pending
164
164
release, if any. As a guideline, core developers usually merge their own
165
165
changes and volunteer to merge other contributions if they were the second
166
166
reviewer to agree to a change.
261
261
 
262
262
  ./bzr selftest -v -x blackbox  
263
263
 
264
 
To ensure that all tests are being run and succeeding, you can use the
265
 
--strict option which will fail if there are any missing features or known
266
 
failures, like so::
267
 
 
268
 
  ./bzr selftest --strict
269
 
 
270
264
To list tests without running them, use the --list-only option like so::
271
265
 
272
266
  ./bzr selftest --list-only
349
343
test was not run, rather than just returning which makes it look as if it
350
344
was run and passed.
351
345
 
352
 
Several different cases are distinguished:
353
 
 
354
 
TestSkipped
355
 
        Generic skip; the only type that was present up to bzr 0.18.
356
 
 
357
 
TestNotApplicable
358
 
        The test doesn't apply to the parameters with which it was run.
359
 
        This is typically used when the test is being applied to all
360
 
        implementations of an interface, but some aspects of the interface
361
 
        are optional and not present in particular concrete
362
 
        implementations.  (Some tests that should raise this currently
363
 
        either silently return or raise TestSkipped.)  Another option is
364
 
        to use more precise parameterization to avoid generating the test
365
 
        at all.
366
 
 
367
 
TestPlatformLimit
368
 
        **(Not implemented yet)**
369
 
        The test can't be run because of an inherent limitation of the
370
 
        environment, such as not having symlinks or not supporting
371
 
        unicode.
372
 
 
373
 
UnavailableFeature
374
 
        The test can't be run because a dependency (typically a Python
375
 
        library) is not available in the test environment.  These
376
 
        are in general things that the person running the test could fix 
377
 
        by installing the library.  It's OK if some of these occur when 
378
 
        an end user runs the tests or if we're specifically testing in a
379
 
        limited environment, but a full test should never see them.
380
 
 
381
 
KnownFailure
382
 
        The test exists but is known to fail, for example because the 
383
 
        code to fix it hasn't been run yet.  Raising this allows 
384
 
        you to distinguish these failures from the ones that are not 
385
 
        expected to fail.  This could be conditionally raised if something
386
 
        is broken on some platforms but not on others.
387
 
 
388
 
We plan to support three modes for running the test suite to control the
389
 
interpretation of these results.  Strict mode is for use in situations
390
 
like merges to the mainline and releases where we want to make sure that
391
 
everything that can be tested has been tested.  Lax mode is for use by
392
 
developers who want to temporarily tolerate some known failures.  The
393
 
default behaviour is obtained by ``bzr selftest`` with no options, and
394
 
also (if possible) by running under another unittest harness.
395
 
 
396
 
======================= ======= ======= ========
397
 
result                  strict  default lax
398
 
======================= ======= ======= ========
399
 
TestSkipped             pass    pass    pass
400
 
TestNotApplicable       pass    pass    pass
401
 
TestPlatformLimit       pass    pass    pass
402
 
TestDependencyMissing   fail    pass    pass
403
 
KnownFailure            fail    pass    pass
404
 
======================= ======= ======= ========
405
 
     
406
 
 
407
 
Test feature dependencies
408
 
-------------------------
409
 
 
410
 
Rather than manually checking the environment in each test, a test class
411
 
can declare its dependence on some test features.  The feature objects are
412
 
checked only once for each run of the whole test suite.
413
 
 
414
 
For historical reasons, as of May 2007 many cases that should depend on
415
 
features currently raise TestSkipped.)
416
 
 
417
 
::
 
346
A subtly different case is a test that should run, but can't run in the
 
347
current environment.  This covers tests that can only run in particular
 
348
operating systems or locales, or that depend on external libraries.  Here
 
349
we want to inform the user that they didn't get full test coverage, but
 
350
they possibly could if they installed more libraries.  These are expressed
 
351
as a dependency on a feature so we can summarise them, and so that the
 
352
test for the feature is done only once.  (For historical reasons, as of
 
353
May 2007 many cases that should depend on features currently raise
 
354
TestSkipped.)  The typical use is::
418
355
 
419
356
    class TestStrace(TestCaseWithTransport):
420
357
 
421
358
        _test_needs_features = [StraceFeature]
422
359
 
423
 
This means all tests in this class need the feature.  The feature itself
 
360
which means all tests in this class need the feature.  The feature itself
424
361
should provide a ``_probe`` method which is called once to determine if
425
362
it's available.
426
363
 
427
 
These should generally be equivalent to either TestDependencyMissing or
428
 
sometimes TestPlatformLimit.
429
 
 
430
364
 
431
365
Known failures
432
366
--------------
470
404
they're displayed or handled.
471
405
 
472
406
 
473
 
Interface implementation testing and test scenarios
474
 
---------------------------------------------------
475
 
 
476
 
There are several cases in Bazaar of multiple implementations of a common 
477
 
conceptual interface.  ("Conceptual" because 
478
 
it's not necessary for all the implementations to share a base class,
479
 
though they often do.)  Examples include transports and the working tree,
480
 
branch and repository classes. 
481
 
 
482
 
In these cases we want to make sure that every implementation correctly
483
 
fulfils the interface requirements.  For example, every Transport should
484
 
support the ``has()`` and ``get()`` and ``clone()`` methods.  We have a
485
 
sub-suite of tests in ``test_transport_implementations``.  (Most
486
 
per-implementation tests are in submodules of ``bzrlib.tests``, but not
487
 
the transport tests at the moment.)  
488
 
 
489
 
These tests are repeated for each registered Transport, by generating a
490
 
new TestCase instance for the cross product of test methods and transport
491
 
implementations.  As each test runs, it has ``transport_class`` and
492
 
``transport_server`` set to the class it should test.  Most tests don't
493
 
access these directly, but rather use ``self.get_transport`` which returns
494
 
a transport of the appropriate type.
495
 
 
496
 
The goal is to run per-implementation only tests that relate to that
497
 
particular interface.  Sometimes we discover a bug elsewhere that happens
498
 
with only one particular transport.  Once it's isolated, we can consider 
499
 
whether a test should be added for that particular implementation,
500
 
or for all implementations of the interface.
501
 
 
502
 
The multiplication of tests for different implementations is normally 
503
 
accomplished by overriding the ``test_suite`` function used to load 
504
 
tests from a module.  This function typically loads all the tests,
505
 
then applies a TestProviderAdapter to them, which generates a longer 
506
 
suite containing all the test variations.
507
 
 
508
 
 
509
 
Test scenarios
510
 
--------------
511
 
 
512
 
Some utilities are provided for generating variations of tests.  This can
513
 
be used for per-implementation tests, or other cases where the same test
514
 
code needs to run several times on different scenarios.
515
 
 
516
 
The general approach is to define a class that provides test methods,
517
 
which depend on attributes of the test object being pre-set with the
518
 
values to which the test should be applied.  The test suite should then
519
 
also provide a list of scenarios in which to run the tests.
520
 
 
521
 
Typically ``multiply_tests_from_modules`` should be called from the test
522
 
module's ``test_suite`` function.
523
 
 
524
 
 
525
407
Essential Domain Classes
526
408
########################
527
409
 
647
529
Naming
648
530
------
649
531
 
650
 
Functions, methods or members that are "private" to bzrlib are given
651
 
a leading underscore prefix.  Names without a leading underscore are
652
 
public not just across modules but to programmers using bzrlib as an
653
 
API. As a consequence, a leading underscore is appropriate for names
654
 
exposed across modules but that are not to be exposed to bzrlib API
655
 
programmers.
 
532
Functions, methods or members that are in some sense "private" are given
 
533
a leading underscore prefix.  This is just a hint that code outside the
 
534
implementation should probably not use that interface.
656
535
 
657
536
We prefer class names to be concatenated capital words (``TestCase``)
658
537
and variables, methods and functions to be lowercase words joined by