Merge lp:~lifeless/bzr/test-speed into lp:~bzr/bzr/trunk-old

Proposed by Robert Collins
Status: Merged
Merge reported by: Robert Collins
Merged at revision: not available
Proposed branch: lp:~lifeless/bzr/test-speed
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 688 lines
To merge this branch: bzr merge lp:~lifeless/bzr/test-speed
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
John A Meinel Approve
Review via email: mp+10720@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

This branch:
* Use copy, not deepcopy, to clone tests in test parameterisation.
* Make tests for finish_bzr_subprocess that really only care about the
   interface use StubProcess.
* Remove duplicated test_start_and_stop_working_dir test.
* Remove unnecessary use of an SFTP server connection to test the
   behaviour of TestCase.make_branch_and_tree.
* Refactor test_suite to make stubbing out the list of tests to load
possible without sacrificing coverage.

-Rob

Revision history for this message
John A Meinel (jameinel) wrote :

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

Robert Collins wrote:
> Robert Collins has proposed merging lp:~lifeless/bzr/test-speed into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
>
> This branch:
> * Use copy, not deepcopy, to clone tests in test parameterisation.

^- My primary concern is whether this is actually valid. Obviously you
believe so or you wouldn't have done it.

My understanding is that the main difference is things like:

 l = [[1]]
 lcopy = copy(l)
 ldeepcopy = deepcopy(l)
 l[0] is lcopy[0]
 l[0] is not ldeepcopy[0]

Now, I don't think we store any state in member variables that would end
up persisting between tests. I suppose if we did then you would get test
failures?

How much of an impact does this actually have? If it is .02s out 10s
loading, then it isn't really worthwhile versus the safety. If it is
more than 10% then it seems reasonable.

> * Make tests for finish_bzr_subprocess that really only care about the
> interface use StubProcess.
> * Remove duplicated test_start_and_stop_working_dir test.
> * Remove unnecessary use of an SFTP server connection to test the
> behaviour of TestCase.make_branch_and_tree.
> * Refactor test_suite to make stubbing out the list of tests to load
> possible without sacrificing coverage.

This seems like a lot of churn that is somewhat likely to cause
conflicts (as the data has now been moved). If you find it a lot easier,
I guess that is ok. I've always found:

^V B B B I #

(block select, down page, insert before, comment char)

to work well for stubbing out lots of tests at once.

You can even use

^V % I #

(jump to matching parenthesis/brace/etc) to block out the whole group in
just a couple keystrokes. And I know you use ViM :)

>
> -Rob

Anyway, other than the copy/deepcopy question, this doesn't seem to
reduce code coverage (note that I didn't check to make sure all the test
names were still present after the move.) So I'll defer to your
judgement about the rest.

 review: approve

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqVQ84ACgkQJdeBCYSNAANDswCfRoctFvjboQvSDWaPkqdN5zuo
0y8AnREcXttKeXhpdj71zA/KpgMRRsZg
=aRNZ
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

> This branch:
> * Use copy, not deepcopy, to clone tests in test parameterisation.
> * Make tests for finish_bzr_subprocess that really only care about the
> interface use StubProcess.
> * Remove duplicated test_start_and_stop_working_dir test.
> * Remove unnecessary use of an SFTP server connection to test the
> behaviour of TestCase.make_branch_and_tree.
> * Refactor test_suite to make stubbing out the list of tests to load
> possible without sacrificing coverage.
>

Cough, that's two or three submissions crammed into one, here.

I approve them all, but yet.

I think the copy usage is fine, setUp() is really the test constructor so nothing occurring before that should have an impact on a test.

That may be worth adding a comment though.

You may want to check if your subprocess modifications (removing some bzr --version abusive uses) have addressed the bug about running the test suite in a bound branch.

review: Approve
Revision history for this message
Robert Collins (lifeless) wrote :

On Wed, 2009-08-26 at 14:18 +0000, John A Meinel wrote:
> Review: Approve
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Robert Collins wrote:
> > Robert Collins has proposed merging lp:~lifeless/bzr/test-speed into lp:bzr.
> >
> > Requested reviews:
> > bzr-core (bzr-core)
> >
> > This branch:
> > * Use copy, not deepcopy, to clone tests in test parameterisation.
>
> ^- My primary concern is whether this is actually valid. Obviously you
> believe so or you wouldn't have done it.

Its only the test objects we copy:
so
foo = Test("method")
case1 = deepcopy(foo)
apply_attributes_here
becomes
foo = Test("method")
case1 = copy(foo)
apply_attributes_here

There aren't any attributes on the test at all; attributes on the class
will still be on the class -
foo.bar = gam
wouldn't be affecting them anyway.

So its pretty safe.

> > * Refactor test_suite to make stubbing out the list of tests to load
> > possible without sacrificing coverage.
>
> This seems like a lot of churn that is somewhat likely to cause
> conflicts (as the data has now been moved). If you find it a lot easier,
> I guess that is ok. I've always found:

Its stubbed out by the test suite now, rather than by hand ;). So editor
stubbing is a bit different :).

> Anyway, other than the copy/deepcopy question, this doesn't seem to
> reduce code coverage (note that I didn't check to make sure all the test
> names were still present after the move.) So I'll defer to your
> judgement about the rest.

Thanks, landing.

-Rob

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-08-26 10:24:28 +0000
+++ NEWS 2009-08-26 19:35:12 +0000
@@ -103,6 +103,10 @@
103* Passing ``--lsprof-tests -v`` to bzr selftest will cause lsprof output to103* Passing ``--lsprof-tests -v`` to bzr selftest will cause lsprof output to
104 be output for every test. Note that this is very verbose! (Robert Collins)104 be output for every test. Note that this is very verbose! (Robert Collins)
105105
106* Test parameterisation now does a shallow copy, not a deep copy of the test
107 to be parameterised. This is not expected to break external use of test
108 parameterisation, and is substantially faster. (Robert Collins)
109
106bzr 1.18110bzr 1.18
107########111########
108112
109113
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2009-08-25 05:04:05 +0000
+++ bzrlib/tests/__init__.py 2009-08-26 19:35:13 +0000
@@ -28,6 +28,7 @@
2828
29import atexit29import atexit
30import codecs30import codecs
31from copy import copy
31from cStringIO import StringIO32from cStringIO import StringIO
32import difflib33import difflib
33import doctest34import doctest
@@ -2498,6 +2499,15 @@
2498 repository will also be accessed locally. Otherwise a lightweight2499 repository will also be accessed locally. Otherwise a lightweight
2499 checkout is created and returned.2500 checkout is created and returned.
25002501
2502 We do this because we can't physically create a tree in the local
2503 path, with a branch reference to the transport_factory url, and
2504 a branch + repository in the vfs_transport, unless the vfs_transport
2505 namespace is distinct from the local disk - the two branch objects
2506 would collide. While we could construct a tree with its branch object
2507 pointing at the transport_factory transport in memory, reopening it
2508 would behaving unexpectedly, and has in the past caused testing bugs
2509 when we tried to do it that way.
2510
2501 :param format: The BzrDirFormat.2511 :param format: The BzrDirFormat.
2502 :returns: the WorkingTree.2512 :returns: the WorkingTree.
2503 """2513 """
@@ -3477,6 +3487,206 @@
3477test_prefix_alias_registry.register('bp', 'bzrlib.plugins')3487test_prefix_alias_registry.register('bp', 'bzrlib.plugins')
34783488
34793489
3490def _test_suite_testmod_names():
3491 """Return the standard list of test module names to test."""
3492 return [
3493 'bzrlib.doc',
3494 'bzrlib.tests.blackbox',
3495 'bzrlib.tests.commands',
3496 'bzrlib.tests.per_branch',
3497 'bzrlib.tests.per_bzrdir',
3498 'bzrlib.tests.per_interrepository',
3499 'bzrlib.tests.per_intertree',
3500 'bzrlib.tests.per_inventory',
3501 'bzrlib.tests.per_interbranch',
3502 'bzrlib.tests.per_lock',
3503 'bzrlib.tests.per_transport',
3504 'bzrlib.tests.per_tree',
3505 'bzrlib.tests.per_pack_repository',
3506 'bzrlib.tests.per_repository',
3507 'bzrlib.tests.per_repository_chk',
3508 'bzrlib.tests.per_repository_reference',
3509 'bzrlib.tests.per_versionedfile',
3510 'bzrlib.tests.per_workingtree',
3511 'bzrlib.tests.test__annotator',
3512 'bzrlib.tests.test__chk_map',
3513 'bzrlib.tests.test__dirstate_helpers',
3514 'bzrlib.tests.test__groupcompress',
3515 'bzrlib.tests.test__known_graph',
3516 'bzrlib.tests.test__rio',
3517 'bzrlib.tests.test__walkdirs_win32',
3518 'bzrlib.tests.test_ancestry',
3519 'bzrlib.tests.test_annotate',
3520 'bzrlib.tests.test_api',
3521 'bzrlib.tests.test_atomicfile',
3522 'bzrlib.tests.test_bad_files',
3523 'bzrlib.tests.test_bencode',
3524 'bzrlib.tests.test_bisect_multi',
3525 'bzrlib.tests.test_branch',
3526 'bzrlib.tests.test_branchbuilder',
3527 'bzrlib.tests.test_btree_index',
3528 'bzrlib.tests.test_bugtracker',
3529 'bzrlib.tests.test_bundle',
3530 'bzrlib.tests.test_bzrdir',
3531 'bzrlib.tests.test__chunks_to_lines',
3532 'bzrlib.tests.test_cache_utf8',
3533 'bzrlib.tests.test_chk_map',
3534 'bzrlib.tests.test_chk_serializer',
3535 'bzrlib.tests.test_chunk_writer',
3536 'bzrlib.tests.test_clean_tree',
3537 'bzrlib.tests.test_commands',
3538 'bzrlib.tests.test_commit',
3539 'bzrlib.tests.test_commit_merge',
3540 'bzrlib.tests.test_config',
3541 'bzrlib.tests.test_conflicts',
3542 'bzrlib.tests.test_counted_lock',
3543 'bzrlib.tests.test_crash',
3544 'bzrlib.tests.test_decorators',
3545 'bzrlib.tests.test_delta',
3546 'bzrlib.tests.test_debug',
3547 'bzrlib.tests.test_deprecated_graph',
3548 'bzrlib.tests.test_diff',
3549 'bzrlib.tests.test_directory_service',
3550 'bzrlib.tests.test_dirstate',
3551 'bzrlib.tests.test_email_message',
3552 'bzrlib.tests.test_eol_filters',
3553 'bzrlib.tests.test_errors',
3554 'bzrlib.tests.test_export',
3555 'bzrlib.tests.test_extract',
3556 'bzrlib.tests.test_fetch',
3557 'bzrlib.tests.test_fifo_cache',
3558 'bzrlib.tests.test_filters',
3559 'bzrlib.tests.test_ftp_transport',
3560 'bzrlib.tests.test_foreign',
3561 'bzrlib.tests.test_generate_docs',
3562 'bzrlib.tests.test_generate_ids',
3563 'bzrlib.tests.test_globbing',
3564 'bzrlib.tests.test_gpg',
3565 'bzrlib.tests.test_graph',
3566 'bzrlib.tests.test_groupcompress',
3567 'bzrlib.tests.test_hashcache',
3568 'bzrlib.tests.test_help',
3569 'bzrlib.tests.test_hooks',
3570 'bzrlib.tests.test_http',
3571 'bzrlib.tests.test_http_response',
3572 'bzrlib.tests.test_https_ca_bundle',
3573 'bzrlib.tests.test_identitymap',
3574 'bzrlib.tests.test_ignores',
3575 'bzrlib.tests.test_index',
3576 'bzrlib.tests.test_info',
3577 'bzrlib.tests.test_inv',
3578 'bzrlib.tests.test_inventory_delta',
3579 'bzrlib.tests.test_knit',
3580 'bzrlib.tests.test_lazy_import',
3581 'bzrlib.tests.test_lazy_regex',
3582 'bzrlib.tests.test_lock',
3583 'bzrlib.tests.test_lockable_files',
3584 'bzrlib.tests.test_lockdir',
3585 'bzrlib.tests.test_log',
3586 'bzrlib.tests.test_lru_cache',
3587 'bzrlib.tests.test_lsprof',
3588 'bzrlib.tests.test_mail_client',
3589 'bzrlib.tests.test_memorytree',
3590 'bzrlib.tests.test_merge',
3591 'bzrlib.tests.test_merge3',
3592 'bzrlib.tests.test_merge_core',
3593 'bzrlib.tests.test_merge_directive',
3594 'bzrlib.tests.test_missing',
3595 'bzrlib.tests.test_msgeditor',
3596 'bzrlib.tests.test_multiparent',
3597 'bzrlib.tests.test_mutabletree',
3598 'bzrlib.tests.test_nonascii',
3599 'bzrlib.tests.test_options',
3600 'bzrlib.tests.test_osutils',
3601 'bzrlib.tests.test_osutils_encodings',
3602 'bzrlib.tests.test_pack',
3603 'bzrlib.tests.test_patch',
3604 'bzrlib.tests.test_patches',
3605 'bzrlib.tests.test_permissions',
3606 'bzrlib.tests.test_plugins',
3607 'bzrlib.tests.test_progress',
3608 'bzrlib.tests.test_read_bundle',
3609 'bzrlib.tests.test_reconcile',
3610 'bzrlib.tests.test_reconfigure',
3611 'bzrlib.tests.test_registry',
3612 'bzrlib.tests.test_remote',
3613 'bzrlib.tests.test_rename_map',
3614 'bzrlib.tests.test_repository',
3615 'bzrlib.tests.test_revert',
3616 'bzrlib.tests.test_revision',
3617 'bzrlib.tests.test_revisionspec',
3618 'bzrlib.tests.test_revisiontree',
3619 'bzrlib.tests.test_rio',
3620 'bzrlib.tests.test_rules',
3621 'bzrlib.tests.test_sampler',
3622 'bzrlib.tests.test_selftest',
3623 'bzrlib.tests.test_serializer',
3624 'bzrlib.tests.test_setup',
3625 'bzrlib.tests.test_sftp_transport',
3626 'bzrlib.tests.test_shelf',
3627 'bzrlib.tests.test_shelf_ui',
3628 'bzrlib.tests.test_smart',
3629 'bzrlib.tests.test_smart_add',
3630 'bzrlib.tests.test_smart_request',
3631 'bzrlib.tests.test_smart_transport',
3632 'bzrlib.tests.test_smtp_connection',
3633 'bzrlib.tests.test_source',
3634 'bzrlib.tests.test_ssh_transport',
3635 'bzrlib.tests.test_status',
3636 'bzrlib.tests.test_store',
3637 'bzrlib.tests.test_strace',
3638 'bzrlib.tests.test_subsume',
3639 'bzrlib.tests.test_switch',
3640 'bzrlib.tests.test_symbol_versioning',
3641 'bzrlib.tests.test_tag',
3642 'bzrlib.tests.test_testament',
3643 'bzrlib.tests.test_textfile',
3644 'bzrlib.tests.test_textmerge',
3645 'bzrlib.tests.test_timestamp',
3646 'bzrlib.tests.test_trace',
3647 'bzrlib.tests.test_transactions',
3648 'bzrlib.tests.test_transform',
3649 'bzrlib.tests.test_transport',
3650 'bzrlib.tests.test_transport_log',
3651 'bzrlib.tests.test_tree',
3652 'bzrlib.tests.test_treebuilder',
3653 'bzrlib.tests.test_tsort',
3654 'bzrlib.tests.test_tuned_gzip',
3655 'bzrlib.tests.test_ui',
3656 'bzrlib.tests.test_uncommit',
3657 'bzrlib.tests.test_upgrade',
3658 'bzrlib.tests.test_upgrade_stacked',
3659 'bzrlib.tests.test_urlutils',
3660 'bzrlib.tests.test_version',
3661 'bzrlib.tests.test_version_info',
3662 'bzrlib.tests.test_weave',
3663 'bzrlib.tests.test_whitebox',
3664 'bzrlib.tests.test_win32utils',
3665 'bzrlib.tests.test_workingtree',
3666 'bzrlib.tests.test_workingtree_4',
3667 'bzrlib.tests.test_wsgi',
3668 'bzrlib.tests.test_xml',
3669 ]
3670
3671
3672def _test_suite_modules_to_doctest():
3673 """Return the list of modules to doctest."""
3674 return [
3675 'bzrlib',
3676 'bzrlib.branchbuilder',
3677 'bzrlib.export',
3678 'bzrlib.inventory',
3679 'bzrlib.iterablefile',
3680 'bzrlib.lockdir',
3681 'bzrlib.merge3',
3682 'bzrlib.option',
3683 'bzrlib.symbol_versioning',
3684 'bzrlib.tests',
3685 'bzrlib.timestamp',
3686 'bzrlib.version_info_formats.format_custom',
3687 ]
3688
3689
3480def test_suite(keep_only=None, starting_with=None):3690def test_suite(keep_only=None, starting_with=None):
3481 """Build and return TestSuite for the whole of bzrlib.3691 """Build and return TestSuite for the whole of bzrlib.
34823692
@@ -3488,184 +3698,6 @@
3488 This function can be replaced if you need to change the default test3698 This function can be replaced if you need to change the default test
3489 suite on a global basis, but it is not encouraged.3699 suite on a global basis, but it is not encouraged.
3490 """3700 """
3491 testmod_names = [
3492 'bzrlib.doc',
3493 'bzrlib.tests.blackbox',
3494 'bzrlib.tests.commands',
3495 'bzrlib.tests.per_branch',
3496 'bzrlib.tests.per_bzrdir',
3497 'bzrlib.tests.per_interrepository',
3498 'bzrlib.tests.per_intertree',
3499 'bzrlib.tests.per_inventory',
3500 'bzrlib.tests.per_interbranch',
3501 'bzrlib.tests.per_lock',
3502 'bzrlib.tests.per_transport',
3503 'bzrlib.tests.per_tree',
3504 'bzrlib.tests.per_pack_repository',
3505 'bzrlib.tests.per_repository',
3506 'bzrlib.tests.per_repository_chk',
3507 'bzrlib.tests.per_repository_reference',
3508 'bzrlib.tests.per_versionedfile',
3509 'bzrlib.tests.per_workingtree',
3510 'bzrlib.tests.test__annotator',
3511 'bzrlib.tests.test__chk_map',
3512 'bzrlib.tests.test__dirstate_helpers',
3513 'bzrlib.tests.test__groupcompress',
3514 'bzrlib.tests.test__known_graph',
3515 'bzrlib.tests.test__rio',
3516 'bzrlib.tests.test__walkdirs_win32',
3517 'bzrlib.tests.test_ancestry',
3518 'bzrlib.tests.test_annotate',
3519 'bzrlib.tests.test_api',
3520 'bzrlib.tests.test_atomicfile',
3521 'bzrlib.tests.test_bad_files',
3522 'bzrlib.tests.test_bencode',
3523 'bzrlib.tests.test_bisect_multi',
3524 'bzrlib.tests.test_branch',
3525 'bzrlib.tests.test_branchbuilder',
3526 'bzrlib.tests.test_btree_index',
3527 'bzrlib.tests.test_bugtracker',
3528 'bzrlib.tests.test_bundle',
3529 'bzrlib.tests.test_bzrdir',
3530 'bzrlib.tests.test__chunks_to_lines',
3531 'bzrlib.tests.test_cache_utf8',
3532 'bzrlib.tests.test_chk_map',
3533 'bzrlib.tests.test_chk_serializer',
3534 'bzrlib.tests.test_chunk_writer',
3535 'bzrlib.tests.test_clean_tree',
3536 'bzrlib.tests.test_commands',
3537 'bzrlib.tests.test_commit',
3538 'bzrlib.tests.test_commit_merge',
3539 'bzrlib.tests.test_config',
3540 'bzrlib.tests.test_conflicts',
3541 'bzrlib.tests.test_counted_lock',
3542 'bzrlib.tests.test_crash',
3543 'bzrlib.tests.test_decorators',
3544 'bzrlib.tests.test_delta',
3545 'bzrlib.tests.test_debug',
3546 'bzrlib.tests.test_deprecated_graph',
3547 'bzrlib.tests.test_diff',
3548 'bzrlib.tests.test_directory_service',
3549 'bzrlib.tests.test_dirstate',
3550 'bzrlib.tests.test_email_message',
3551 'bzrlib.tests.test_eol_filters',
3552 'bzrlib.tests.test_errors',
3553 'bzrlib.tests.test_export',
3554 'bzrlib.tests.test_extract',
3555 'bzrlib.tests.test_fetch',
3556 'bzrlib.tests.test_fifo_cache',
3557 'bzrlib.tests.test_filters',
3558 'bzrlib.tests.test_ftp_transport',
3559 'bzrlib.tests.test_foreign',
3560 'bzrlib.tests.test_generate_docs',
3561 'bzrlib.tests.test_generate_ids',
3562 'bzrlib.tests.test_globbing',
3563 'bzrlib.tests.test_gpg',
3564 'bzrlib.tests.test_graph',
3565 'bzrlib.tests.test_groupcompress',
3566 'bzrlib.tests.test_hashcache',
3567 'bzrlib.tests.test_help',
3568 'bzrlib.tests.test_hooks',
3569 'bzrlib.tests.test_http',
3570 'bzrlib.tests.test_http_response',
3571 'bzrlib.tests.test_https_ca_bundle',
3572 'bzrlib.tests.test_identitymap',
3573 'bzrlib.tests.test_ignores',
3574 'bzrlib.tests.test_index',
3575 'bzrlib.tests.test_info',
3576 'bzrlib.tests.test_inv',
3577 'bzrlib.tests.test_inventory_delta',
3578 'bzrlib.tests.test_knit',
3579 'bzrlib.tests.test_lazy_import',
3580 'bzrlib.tests.test_lazy_regex',
3581 'bzrlib.tests.test_lock',
3582 'bzrlib.tests.test_lockable_files',
3583 'bzrlib.tests.test_lockdir',
3584 'bzrlib.tests.test_log',
3585 'bzrlib.tests.test_lru_cache',
3586 'bzrlib.tests.test_lsprof',
3587 'bzrlib.tests.test_mail_client',
3588 'bzrlib.tests.test_memorytree',
3589 'bzrlib.tests.test_merge',
3590 'bzrlib.tests.test_merge3',
3591 'bzrlib.tests.test_merge_core',
3592 'bzrlib.tests.test_merge_directive',
3593 'bzrlib.tests.test_missing',
3594 'bzrlib.tests.test_msgeditor',
3595 'bzrlib.tests.test_multiparent',
3596 'bzrlib.tests.test_mutabletree',
3597 'bzrlib.tests.test_nonascii',
3598 'bzrlib.tests.test_options',
3599 'bzrlib.tests.test_osutils',
3600 'bzrlib.tests.test_osutils_encodings',
3601 'bzrlib.tests.test_pack',
3602 'bzrlib.tests.test_patch',
3603 'bzrlib.tests.test_patches',
3604 'bzrlib.tests.test_permissions',
3605 'bzrlib.tests.test_plugins',
3606 'bzrlib.tests.test_progress',
3607 'bzrlib.tests.test_read_bundle',
3608 'bzrlib.tests.test_reconcile',
3609 'bzrlib.tests.test_reconfigure',
3610 'bzrlib.tests.test_registry',
3611 'bzrlib.tests.test_remote',
3612 'bzrlib.tests.test_rename_map',
3613 'bzrlib.tests.test_repository',
3614 'bzrlib.tests.test_revert',
3615 'bzrlib.tests.test_revision',
3616 'bzrlib.tests.test_revisionspec',
3617 'bzrlib.tests.test_revisiontree',
3618 'bzrlib.tests.test_rio',
3619 'bzrlib.tests.test_rules',
3620 'bzrlib.tests.test_sampler',
3621 'bzrlib.tests.test_selftest',
3622 'bzrlib.tests.test_serializer',
3623 'bzrlib.tests.test_setup',
3624 'bzrlib.tests.test_sftp_transport',
3625 'bzrlib.tests.test_shelf',
3626 'bzrlib.tests.test_shelf_ui',
3627 'bzrlib.tests.test_smart',
3628 'bzrlib.tests.test_smart_add',
3629 'bzrlib.tests.test_smart_request',
3630 'bzrlib.tests.test_smart_transport',
3631 'bzrlib.tests.test_smtp_connection',
3632 'bzrlib.tests.test_source',
3633 'bzrlib.tests.test_ssh_transport',
3634 'bzrlib.tests.test_status',
3635 'bzrlib.tests.test_store',
3636 'bzrlib.tests.test_strace',
3637 'bzrlib.tests.test_subsume',
3638 'bzrlib.tests.test_switch',
3639 'bzrlib.tests.test_symbol_versioning',
3640 'bzrlib.tests.test_tag',
3641 'bzrlib.tests.test_testament',
3642 'bzrlib.tests.test_textfile',
3643 'bzrlib.tests.test_textmerge',
3644 'bzrlib.tests.test_timestamp',
3645 'bzrlib.tests.test_trace',
3646 'bzrlib.tests.test_transactions',
3647 'bzrlib.tests.test_transform',
3648 'bzrlib.tests.test_transport',
3649 'bzrlib.tests.test_transport_log',
3650 'bzrlib.tests.test_tree',
3651 'bzrlib.tests.test_treebuilder',
3652 'bzrlib.tests.test_tsort',
3653 'bzrlib.tests.test_tuned_gzip',
3654 'bzrlib.tests.test_ui',
3655 'bzrlib.tests.test_uncommit',
3656 'bzrlib.tests.test_upgrade',
3657 'bzrlib.tests.test_upgrade_stacked',
3658 'bzrlib.tests.test_urlutils',
3659 'bzrlib.tests.test_version',
3660 'bzrlib.tests.test_version_info',
3661 'bzrlib.tests.test_weave',
3662 'bzrlib.tests.test_whitebox',
3663 'bzrlib.tests.test_win32utils',
3664 'bzrlib.tests.test_workingtree',
3665 'bzrlib.tests.test_workingtree_4',
3666 'bzrlib.tests.test_wsgi',
3667 'bzrlib.tests.test_xml',
3668 ]
36693701
3670 loader = TestUtil.TestLoader()3702 loader = TestUtil.TestLoader()
36713703
@@ -3700,24 +3732,9 @@
3700 suite = loader.suiteClass()3732 suite = loader.suiteClass()
37013733
3702 # modules building their suite with loadTestsFromModuleNames3734 # modules building their suite with loadTestsFromModuleNames
3703 suite.addTest(loader.loadTestsFromModuleNames(testmod_names))3735 suite.addTest(loader.loadTestsFromModuleNames(_test_suite_testmod_names()))
37043736
3705 modules_to_doctest = [3737 for mod in _test_suite_modules_to_doctest():
3706 'bzrlib',
3707 'bzrlib.branchbuilder',
3708 'bzrlib.export',
3709 'bzrlib.inventory',
3710 'bzrlib.iterablefile',
3711 'bzrlib.lockdir',
3712 'bzrlib.merge3',
3713 'bzrlib.option',
3714 'bzrlib.symbol_versioning',
3715 'bzrlib.tests',
3716 'bzrlib.timestamp',
3717 'bzrlib.version_info_formats.format_custom',
3718 ]
3719
3720 for mod in modules_to_doctest:
3721 if not interesting_module(mod):3738 if not interesting_module(mod):
3722 # No tests to keep here, move along3739 # No tests to keep here, move along
3723 continue3740 continue
@@ -3864,8 +3881,7 @@
3864 :param new_id: The id to assign to it.3881 :param new_id: The id to assign to it.
3865 :return: The new test.3882 :return: The new test.
3866 """3883 """
3867 from copy import deepcopy3884 new_test = copy(test)
3868 new_test = deepcopy(test)
3869 new_test.id = lambda: new_id3885 new_test.id = lambda: new_id
3870 return new_test3886 return new_test
38713887
38723888
=== modified file 'bzrlib/tests/test_selftest.py'
--- bzrlib/tests/test_selftest.py 2009-08-25 08:11:17 +0000
+++ bzrlib/tests/test_selftest.py 2009-08-26 19:35:13 +0000
@@ -1773,16 +1773,16 @@
1773 tree = self.make_branch_and_memory_tree('a')1773 tree = self.make_branch_and_memory_tree('a')
1774 self.assertIsInstance(tree, bzrlib.memorytree.MemoryTree)1774 self.assertIsInstance(tree, bzrlib.memorytree.MemoryTree)
17751775
17761776 def test_make_tree_for_local_vfs_backed_transport(self):
1777class TestSFTPMakeBranchAndTree(test_sftp_transport.TestCaseWithSFTPServer):1777 # make_branch_and_tree has to use local branch and repositories
17781778 # when the vfs transport and local disk are colocated, even if
1779 def test_make_tree_for_sftp_branch(self):1779 # a different transport is in use for url generation.
1780 """Transports backed by local directories create local trees."""1780 from bzrlib.transport.fakevfat import FakeVFATServer
1781 # NB: This is arguably a bug in the definition of make_branch_and_tree.1781 self.transport_server = FakeVFATServer
1782 self.assertFalse(self.get_url('t1').startswith('file://'))
1782 tree = self.make_branch_and_tree('t1')1783 tree = self.make_branch_and_tree('t1')
1783 base = tree.bzrdir.root_transport.base1784 base = tree.bzrdir.root_transport.base
1784 self.failIf(base.startswith('sftp'),1785 self.assertStartsWith(base, 'file://')
1785 'base %r is on sftp but should be local' % base)
1786 self.assertEquals(tree.bzrdir.root_transport,1786 self.assertEquals(tree.bzrdir.root_transport,
1787 tree.branch.bzrdir.root_transport)1787 tree.branch.bzrdir.root_transport)
1788 self.assertEquals(tree.bzrdir.root_transport,1788 self.assertEquals(tree.bzrdir.root_transport,
@@ -2117,7 +2117,8 @@
2117 return self.out, self.err2117 return self.out, self.err
21182118
21192119
2120class TestRunBzrSubprocess(tests.TestCaseWithTransport):2120class TestWithFakedStartBzrSubprocess(tests.TestCaseWithTransport):
2121 """Base class for tests testing how we might run bzr."""
21212122
2122 def setUp(self):2123 def setUp(self):
2123 tests.TestCaseWithTransport.setUp(self)2124 tests.TestCaseWithTransport.setUp(self)
@@ -2134,6 +2135,9 @@
2134 'working_dir':working_dir, 'allow_plugins':allow_plugins})2135 'working_dir':working_dir, 'allow_plugins':allow_plugins})
2135 return self.next_subprocess2136 return self.next_subprocess
21362137
2138
2139class TestRunBzrSubprocess(TestWithFakedStartBzrSubprocess):
2140
2137 def assertRunBzrSubprocess(self, expected_args, process, *args, **kwargs):2141 def assertRunBzrSubprocess(self, expected_args, process, *args, **kwargs):
2138 """Run run_bzr_subprocess with args and kwargs using a stubbed process.2142 """Run run_bzr_subprocess with args and kwargs using a stubbed process.
21392143
@@ -2202,6 +2206,32 @@
2202 StubProcess(), '', allow_plugins=True)2206 StubProcess(), '', allow_plugins=True)
22032207
22042208
2209class TestFinishBzrSubprocess(TestWithFakedStartBzrSubprocess):
2210
2211 def test_finish_bzr_subprocess_with_error(self):
2212 """finish_bzr_subprocess allows specification of the desired exit code.
2213 """
2214 process = StubProcess(err="unknown command", retcode=3)
2215 result = self.finish_bzr_subprocess(process, retcode=3)
2216 self.assertEqual('', result[0])
2217 self.assertContainsRe(result[1], 'unknown command')
2218
2219 def test_finish_bzr_subprocess_ignoring_retcode(self):
2220 """finish_bzr_subprocess allows the exit code to be ignored."""
2221 process = StubProcess(err="unknown command", retcode=3)
2222 result = self.finish_bzr_subprocess(process, retcode=None)
2223 self.assertEqual('', result[0])
2224 self.assertContainsRe(result[1], 'unknown command')
2225
2226 def test_finish_subprocess_with_unexpected_retcode(self):
2227 """finish_bzr_subprocess raises self.failureException if the retcode is
2228 not the expected one.
2229 """
2230 process = StubProcess(err="unknown command", retcode=3)
2231 self.assertRaises(self.failureException, self.finish_bzr_subprocess,
2232 process)
2233
2234
2205class _DontSpawnProcess(Exception):2235class _DontSpawnProcess(Exception):
2206 """A simple exception which just allows us to skip unnecessary steps"""2236 """A simple exception which just allows us to skip unnecessary steps"""
22072237
@@ -2285,39 +2315,8 @@
2285 self.assertEqual(['foo', 'current'], chdirs)2315 self.assertEqual(['foo', 'current'], chdirs)
22862316
22872317
2288class TestBzrSubprocess(tests.TestCaseWithTransport):2318class TestActuallyStartBzrSubprocess(tests.TestCaseWithTransport):
22892319 """Tests that really need to do things with an external bzr."""
2290 def test_start_and_stop_bzr_subprocess(self):
2291 """We can start and perform other test actions while that process is
2292 still alive.
2293 """
2294 process = self.start_bzr_subprocess(['--version'])
2295 result = self.finish_bzr_subprocess(process)
2296 self.assertContainsRe(result[0], 'is free software')
2297 self.assertEqual('', result[1])
2298
2299 def test_start_and_stop_bzr_subprocess_with_error(self):
2300 """finish_bzr_subprocess allows specification of the desired exit code.
2301 """
2302 process = self.start_bzr_subprocess(['--versionn'])
2303 result = self.finish_bzr_subprocess(process, retcode=3)
2304 self.assertEqual('', result[0])
2305 self.assertContainsRe(result[1], 'unknown command')
2306
2307 def test_start_and_stop_bzr_subprocess_ignoring_retcode(self):
2308 """finish_bzr_subprocess allows the exit code to be ignored."""
2309 process = self.start_bzr_subprocess(['--versionn'])
2310 result = self.finish_bzr_subprocess(process, retcode=None)
2311 self.assertEqual('', result[0])
2312 self.assertContainsRe(result[1], 'unknown command')
2313
2314 def test_start_and_stop_bzr_subprocess_with_unexpected_retcode(self):
2315 """finish_bzr_subprocess raises self.failureException if the retcode is
2316 not the expected one.
2317 """
2318 process = self.start_bzr_subprocess(['--versionn'])
2319 self.assertRaises(self.failureException, self.finish_bzr_subprocess,
2320 process)
23212320
2322 def test_start_and_stop_bzr_subprocess_send_signal(self):2321 def test_start_and_stop_bzr_subprocess_send_signal(self):
2323 """finish_bzr_subprocess raises self.failureException if the retcode is2322 """finish_bzr_subprocess raises self.failureException if the retcode is
@@ -2331,14 +2330,6 @@
2331 self.assertEqual('', result[0])2330 self.assertEqual('', result[0])
2332 self.assertEqual('bzr: interrupted\n', result[1])2331 self.assertEqual('bzr: interrupted\n', result[1])
23332332
2334 def test_start_and_stop_working_dir(self):
2335 cwd = osutils.getcwd()
2336 self.make_branch_and_tree('one')
2337 process = self.start_bzr_subprocess(['root'], working_dir='one')
2338 result = self.finish_bzr_subprocess(process, universal_newlines=True)
2339 self.assertEndsWith(result[0], 'one\n')
2340 self.assertEqual('', result[1])
2341
23422333
2343class TestKnownFailure(tests.TestCase):2334class TestKnownFailure(tests.TestCase):
23442335
@@ -2726,10 +2717,52 @@
27262717
2727class TestTestSuite(tests.TestCase):2718class TestTestSuite(tests.TestCase):
27282719
2720 def test__test_suite_testmod_names(self):
2721 # Test that a plausible list of test module names are returned
2722 # by _test_suite_testmod_names.
2723 test_list = tests._test_suite_testmod_names()
2724 self.assertSubset([
2725 'bzrlib.tests.blackbox',
2726 'bzrlib.tests.per_transport',
2727 'bzrlib.tests.test_selftest',
2728 ],
2729 test_list)
2730
2731 def test__test_suite_modules_to_doctest(self):
2732 # Test that a plausible list of modules to doctest is returned
2733 # by _test_suite_modules_to_doctest.
2734 test_list = tests._test_suite_modules_to_doctest()
2735 self.assertSubset([
2736 'bzrlib.timestamp',
2737 ],
2738 test_list)
2739
2729 def test_test_suite(self):2740 def test_test_suite(self):
2730 # This test is slow - it loads the entire test suite to operate, so we2741 # test_suite() loads the entire test suite to operate. To avoid this
2731 # do a single test with one test in each category2742 # overhead, and yet still be confident that things are happening,
2732 test_list = [2743 # we temporarily replace two functions used by test_suite with
2744 # test doubles that supply a few sample tests to load, and check they
2745 # are loaded.
2746 calls = []
2747 def _test_suite_testmod_names():
2748 calls.append("testmod_names")
2749 return [
2750 'bzrlib.tests.blackbox.test_branch',
2751 'bzrlib.tests.per_transport',
2752 'bzrlib.tests.test_selftest',
2753 ]
2754 original_testmod_names = tests._test_suite_testmod_names
2755 def _test_suite_modules_to_doctest():
2756 calls.append("modules_to_doctest")
2757 return ['bzrlib.timestamp']
2758 orig_modules_to_doctest = tests._test_suite_modules_to_doctest
2759 def restore_names():
2760 tests._test_suite_testmod_names = original_testmod_names
2761 tests._test_suite_modules_to_doctest = orig_modules_to_doctest
2762 self.addCleanup(restore_names)
2763 tests._test_suite_testmod_names = _test_suite_testmod_names
2764 tests._test_suite_modules_to_doctest = _test_suite_modules_to_doctest
2765 expected_test_list = [
2733 # testmod_names2766 # testmod_names
2734 'bzrlib.tests.blackbox.test_branch.TestBranch.test_branch',2767 'bzrlib.tests.blackbox.test_branch.TestBranch.test_branch',
2735 ('bzrlib.tests.per_transport.TransportTests'2768 ('bzrlib.tests.per_transport.TransportTests'
@@ -2740,13 +2773,16 @@
2740 # plugins can't be tested that way since selftest may be run with2773 # plugins can't be tested that way since selftest may be run with
2741 # --no-plugins2774 # --no-plugins
2742 ]2775 ]
2743 suite = tests.test_suite(test_list)2776 suite = tests.test_suite()
2744 self.assertEquals(test_list, _test_ids(suite))2777 self.assertEqual(set(["testmod_names", "modules_to_doctest"]),
2778 set(calls))
2779 self.assertSubset(expected_test_list, _test_ids(suite))
27452780
2746 def test_test_suite_list_and_start(self):2781 def test_test_suite_list_and_start(self):
2747 # We cannot test this at the same time as the main load, because we want2782 # We cannot test this at the same time as the main load, because we want
2748 # to know that starting_with == None works. So a second full load is2783 # to know that starting_with == None works. So a second load is
2749 # incurred.2784 # incurred - note that the starting_with parameter causes a partial load
2785 # rather than a full load so this test should be pretty quick.
2750 test_list = ['bzrlib.tests.test_selftest.TestTestSuite.test_test_suite']2786 test_list = ['bzrlib.tests.test_selftest.TestTestSuite.test_test_suite']
2751 suite = tests.test_suite(test_list,2787 suite = tests.test_suite(test_list,
2752 ['bzrlib.tests.test_selftest.TestTestSuite'])2788 ['bzrlib.tests.test_selftest.TestTestSuite'])