Merge lp:~lifeless/bzr/test-speed into lp:~bzr/bzr/trunk-old
- test-speed
- Merge into trunk-old
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Approve | ||
John A Meinel | Approve | ||
Review via email: mp+10720@code.launchpad.net |
Commit message
Description of the change
Robert Collins (lifeless) wrote : | # |
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_
> interface use StubProcess.
> * Remove duplicated test_start_
> * Remove unnecessary use of an SFTP server connection to test the
> behaviour of TestCase.
> * 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/
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://
iEYEARECAAYFAkq
0y8AnREcXttKeXh
=aRNZ
-----END PGP SIGNATURE-----
Vincent Ladeuil (vila) wrote : | # |
> This branch:
> * Use copy, not deepcopy, to clone tests in test parameterisation.
> * Make tests for finish_
> interface use StubProcess.
> * Remove duplicated test_start_
> * Remove unnecessary use of an SFTP server connection to test the
> behaviour of TestCase.
> * 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.
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_attribute
becomes
foo = Test("method")
case1 = copy(foo)
apply_attribute
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
1 | === modified file 'NEWS' |
2 | --- NEWS 2009-08-26 10:24:28 +0000 |
3 | +++ NEWS 2009-08-26 19:35:12 +0000 |
4 | @@ -103,6 +103,10 @@ |
5 | * Passing ``--lsprof-tests -v`` to bzr selftest will cause lsprof output to |
6 | be output for every test. Note that this is very verbose! (Robert Collins) |
7 | |
8 | +* Test parameterisation now does a shallow copy, not a deep copy of the test |
9 | + to be parameterised. This is not expected to break external use of test |
10 | + parameterisation, and is substantially faster. (Robert Collins) |
11 | + |
12 | bzr 1.18 |
13 | ######## |
14 | |
15 | |
16 | === modified file 'bzrlib/tests/__init__.py' |
17 | --- bzrlib/tests/__init__.py 2009-08-25 05:04:05 +0000 |
18 | +++ bzrlib/tests/__init__.py 2009-08-26 19:35:13 +0000 |
19 | @@ -28,6 +28,7 @@ |
20 | |
21 | import atexit |
22 | import codecs |
23 | +from copy import copy |
24 | from cStringIO import StringIO |
25 | import difflib |
26 | import doctest |
27 | @@ -2498,6 +2499,15 @@ |
28 | repository will also be accessed locally. Otherwise a lightweight |
29 | checkout is created and returned. |
30 | |
31 | + We do this because we can't physically create a tree in the local |
32 | + path, with a branch reference to the transport_factory url, and |
33 | + a branch + repository in the vfs_transport, unless the vfs_transport |
34 | + namespace is distinct from the local disk - the two branch objects |
35 | + would collide. While we could construct a tree with its branch object |
36 | + pointing at the transport_factory transport in memory, reopening it |
37 | + would behaving unexpectedly, and has in the past caused testing bugs |
38 | + when we tried to do it that way. |
39 | + |
40 | :param format: The BzrDirFormat. |
41 | :returns: the WorkingTree. |
42 | """ |
43 | @@ -3477,6 +3487,206 @@ |
44 | test_prefix_alias_registry.register('bp', 'bzrlib.plugins') |
45 | |
46 | |
47 | +def _test_suite_testmod_names(): |
48 | + """Return the standard list of test module names to test.""" |
49 | + return [ |
50 | + 'bzrlib.doc', |
51 | + 'bzrlib.tests.blackbox', |
52 | + 'bzrlib.tests.commands', |
53 | + 'bzrlib.tests.per_branch', |
54 | + 'bzrlib.tests.per_bzrdir', |
55 | + 'bzrlib.tests.per_interrepository', |
56 | + 'bzrlib.tests.per_intertree', |
57 | + 'bzrlib.tests.per_inventory', |
58 | + 'bzrlib.tests.per_interbranch', |
59 | + 'bzrlib.tests.per_lock', |
60 | + 'bzrlib.tests.per_transport', |
61 | + 'bzrlib.tests.per_tree', |
62 | + 'bzrlib.tests.per_pack_repository', |
63 | + 'bzrlib.tests.per_repository', |
64 | + 'bzrlib.tests.per_repository_chk', |
65 | + 'bzrlib.tests.per_repository_reference', |
66 | + 'bzrlib.tests.per_versionedfile', |
67 | + 'bzrlib.tests.per_workingtree', |
68 | + 'bzrlib.tests.test__annotator', |
69 | + 'bzrlib.tests.test__chk_map', |
70 | + 'bzrlib.tests.test__dirstate_helpers', |
71 | + 'bzrlib.tests.test__groupcompress', |
72 | + 'bzrlib.tests.test__known_graph', |
73 | + 'bzrlib.tests.test__rio', |
74 | + 'bzrlib.tests.test__walkdirs_win32', |
75 | + 'bzrlib.tests.test_ancestry', |
76 | + 'bzrlib.tests.test_annotate', |
77 | + 'bzrlib.tests.test_api', |
78 | + 'bzrlib.tests.test_atomicfile', |
79 | + 'bzrlib.tests.test_bad_files', |
80 | + 'bzrlib.tests.test_bencode', |
81 | + 'bzrlib.tests.test_bisect_multi', |
82 | + 'bzrlib.tests.test_branch', |
83 | + 'bzrlib.tests.test_branchbuilder', |
84 | + 'bzrlib.tests.test_btree_index', |
85 | + 'bzrlib.tests.test_bugtracker', |
86 | + 'bzrlib.tests.test_bundle', |
87 | + 'bzrlib.tests.test_bzrdir', |
88 | + 'bzrlib.tests.test__chunks_to_lines', |
89 | + 'bzrlib.tests.test_cache_utf8', |
90 | + 'bzrlib.tests.test_chk_map', |
91 | + 'bzrlib.tests.test_chk_serializer', |
92 | + 'bzrlib.tests.test_chunk_writer', |
93 | + 'bzrlib.tests.test_clean_tree', |
94 | + 'bzrlib.tests.test_commands', |
95 | + 'bzrlib.tests.test_commit', |
96 | + 'bzrlib.tests.test_commit_merge', |
97 | + 'bzrlib.tests.test_config', |
98 | + 'bzrlib.tests.test_conflicts', |
99 | + 'bzrlib.tests.test_counted_lock', |
100 | + 'bzrlib.tests.test_crash', |
101 | + 'bzrlib.tests.test_decorators', |
102 | + 'bzrlib.tests.test_delta', |
103 | + 'bzrlib.tests.test_debug', |
104 | + 'bzrlib.tests.test_deprecated_graph', |
105 | + 'bzrlib.tests.test_diff', |
106 | + 'bzrlib.tests.test_directory_service', |
107 | + 'bzrlib.tests.test_dirstate', |
108 | + 'bzrlib.tests.test_email_message', |
109 | + 'bzrlib.tests.test_eol_filters', |
110 | + 'bzrlib.tests.test_errors', |
111 | + 'bzrlib.tests.test_export', |
112 | + 'bzrlib.tests.test_extract', |
113 | + 'bzrlib.tests.test_fetch', |
114 | + 'bzrlib.tests.test_fifo_cache', |
115 | + 'bzrlib.tests.test_filters', |
116 | + 'bzrlib.tests.test_ftp_transport', |
117 | + 'bzrlib.tests.test_foreign', |
118 | + 'bzrlib.tests.test_generate_docs', |
119 | + 'bzrlib.tests.test_generate_ids', |
120 | + 'bzrlib.tests.test_globbing', |
121 | + 'bzrlib.tests.test_gpg', |
122 | + 'bzrlib.tests.test_graph', |
123 | + 'bzrlib.tests.test_groupcompress', |
124 | + 'bzrlib.tests.test_hashcache', |
125 | + 'bzrlib.tests.test_help', |
126 | + 'bzrlib.tests.test_hooks', |
127 | + 'bzrlib.tests.test_http', |
128 | + 'bzrlib.tests.test_http_response', |
129 | + 'bzrlib.tests.test_https_ca_bundle', |
130 | + 'bzrlib.tests.test_identitymap', |
131 | + 'bzrlib.tests.test_ignores', |
132 | + 'bzrlib.tests.test_index', |
133 | + 'bzrlib.tests.test_info', |
134 | + 'bzrlib.tests.test_inv', |
135 | + 'bzrlib.tests.test_inventory_delta', |
136 | + 'bzrlib.tests.test_knit', |
137 | + 'bzrlib.tests.test_lazy_import', |
138 | + 'bzrlib.tests.test_lazy_regex', |
139 | + 'bzrlib.tests.test_lock', |
140 | + 'bzrlib.tests.test_lockable_files', |
141 | + 'bzrlib.tests.test_lockdir', |
142 | + 'bzrlib.tests.test_log', |
143 | + 'bzrlib.tests.test_lru_cache', |
144 | + 'bzrlib.tests.test_lsprof', |
145 | + 'bzrlib.tests.test_mail_client', |
146 | + 'bzrlib.tests.test_memorytree', |
147 | + 'bzrlib.tests.test_merge', |
148 | + 'bzrlib.tests.test_merge3', |
149 | + 'bzrlib.tests.test_merge_core', |
150 | + 'bzrlib.tests.test_merge_directive', |
151 | + 'bzrlib.tests.test_missing', |
152 | + 'bzrlib.tests.test_msgeditor', |
153 | + 'bzrlib.tests.test_multiparent', |
154 | + 'bzrlib.tests.test_mutabletree', |
155 | + 'bzrlib.tests.test_nonascii', |
156 | + 'bzrlib.tests.test_options', |
157 | + 'bzrlib.tests.test_osutils', |
158 | + 'bzrlib.tests.test_osutils_encodings', |
159 | + 'bzrlib.tests.test_pack', |
160 | + 'bzrlib.tests.test_patch', |
161 | + 'bzrlib.tests.test_patches', |
162 | + 'bzrlib.tests.test_permissions', |
163 | + 'bzrlib.tests.test_plugins', |
164 | + 'bzrlib.tests.test_progress', |
165 | + 'bzrlib.tests.test_read_bundle', |
166 | + 'bzrlib.tests.test_reconcile', |
167 | + 'bzrlib.tests.test_reconfigure', |
168 | + 'bzrlib.tests.test_registry', |
169 | + 'bzrlib.tests.test_remote', |
170 | + 'bzrlib.tests.test_rename_map', |
171 | + 'bzrlib.tests.test_repository', |
172 | + 'bzrlib.tests.test_revert', |
173 | + 'bzrlib.tests.test_revision', |
174 | + 'bzrlib.tests.test_revisionspec', |
175 | + 'bzrlib.tests.test_revisiontree', |
176 | + 'bzrlib.tests.test_rio', |
177 | + 'bzrlib.tests.test_rules', |
178 | + 'bzrlib.tests.test_sampler', |
179 | + 'bzrlib.tests.test_selftest', |
180 | + 'bzrlib.tests.test_serializer', |
181 | + 'bzrlib.tests.test_setup', |
182 | + 'bzrlib.tests.test_sftp_transport', |
183 | + 'bzrlib.tests.test_shelf', |
184 | + 'bzrlib.tests.test_shelf_ui', |
185 | + 'bzrlib.tests.test_smart', |
186 | + 'bzrlib.tests.test_smart_add', |
187 | + 'bzrlib.tests.test_smart_request', |
188 | + 'bzrlib.tests.test_smart_transport', |
189 | + 'bzrlib.tests.test_smtp_connection', |
190 | + 'bzrlib.tests.test_source', |
191 | + 'bzrlib.tests.test_ssh_transport', |
192 | + 'bzrlib.tests.test_status', |
193 | + 'bzrlib.tests.test_store', |
194 | + 'bzrlib.tests.test_strace', |
195 | + 'bzrlib.tests.test_subsume', |
196 | + 'bzrlib.tests.test_switch', |
197 | + 'bzrlib.tests.test_symbol_versioning', |
198 | + 'bzrlib.tests.test_tag', |
199 | + 'bzrlib.tests.test_testament', |
200 | + 'bzrlib.tests.test_textfile', |
201 | + 'bzrlib.tests.test_textmerge', |
202 | + 'bzrlib.tests.test_timestamp', |
203 | + 'bzrlib.tests.test_trace', |
204 | + 'bzrlib.tests.test_transactions', |
205 | + 'bzrlib.tests.test_transform', |
206 | + 'bzrlib.tests.test_transport', |
207 | + 'bzrlib.tests.test_transport_log', |
208 | + 'bzrlib.tests.test_tree', |
209 | + 'bzrlib.tests.test_treebuilder', |
210 | + 'bzrlib.tests.test_tsort', |
211 | + 'bzrlib.tests.test_tuned_gzip', |
212 | + 'bzrlib.tests.test_ui', |
213 | + 'bzrlib.tests.test_uncommit', |
214 | + 'bzrlib.tests.test_upgrade', |
215 | + 'bzrlib.tests.test_upgrade_stacked', |
216 | + 'bzrlib.tests.test_urlutils', |
217 | + 'bzrlib.tests.test_version', |
218 | + 'bzrlib.tests.test_version_info', |
219 | + 'bzrlib.tests.test_weave', |
220 | + 'bzrlib.tests.test_whitebox', |
221 | + 'bzrlib.tests.test_win32utils', |
222 | + 'bzrlib.tests.test_workingtree', |
223 | + 'bzrlib.tests.test_workingtree_4', |
224 | + 'bzrlib.tests.test_wsgi', |
225 | + 'bzrlib.tests.test_xml', |
226 | + ] |
227 | + |
228 | + |
229 | +def _test_suite_modules_to_doctest(): |
230 | + """Return the list of modules to doctest.""" |
231 | + return [ |
232 | + 'bzrlib', |
233 | + 'bzrlib.branchbuilder', |
234 | + 'bzrlib.export', |
235 | + 'bzrlib.inventory', |
236 | + 'bzrlib.iterablefile', |
237 | + 'bzrlib.lockdir', |
238 | + 'bzrlib.merge3', |
239 | + 'bzrlib.option', |
240 | + 'bzrlib.symbol_versioning', |
241 | + 'bzrlib.tests', |
242 | + 'bzrlib.timestamp', |
243 | + 'bzrlib.version_info_formats.format_custom', |
244 | + ] |
245 | + |
246 | + |
247 | def test_suite(keep_only=None, starting_with=None): |
248 | """Build and return TestSuite for the whole of bzrlib. |
249 | |
250 | @@ -3488,184 +3698,6 @@ |
251 | This function can be replaced if you need to change the default test |
252 | suite on a global basis, but it is not encouraged. |
253 | """ |
254 | - testmod_names = [ |
255 | - 'bzrlib.doc', |
256 | - 'bzrlib.tests.blackbox', |
257 | - 'bzrlib.tests.commands', |
258 | - 'bzrlib.tests.per_branch', |
259 | - 'bzrlib.tests.per_bzrdir', |
260 | - 'bzrlib.tests.per_interrepository', |
261 | - 'bzrlib.tests.per_intertree', |
262 | - 'bzrlib.tests.per_inventory', |
263 | - 'bzrlib.tests.per_interbranch', |
264 | - 'bzrlib.tests.per_lock', |
265 | - 'bzrlib.tests.per_transport', |
266 | - 'bzrlib.tests.per_tree', |
267 | - 'bzrlib.tests.per_pack_repository', |
268 | - 'bzrlib.tests.per_repository', |
269 | - 'bzrlib.tests.per_repository_chk', |
270 | - 'bzrlib.tests.per_repository_reference', |
271 | - 'bzrlib.tests.per_versionedfile', |
272 | - 'bzrlib.tests.per_workingtree', |
273 | - 'bzrlib.tests.test__annotator', |
274 | - 'bzrlib.tests.test__chk_map', |
275 | - 'bzrlib.tests.test__dirstate_helpers', |
276 | - 'bzrlib.tests.test__groupcompress', |
277 | - 'bzrlib.tests.test__known_graph', |
278 | - 'bzrlib.tests.test__rio', |
279 | - 'bzrlib.tests.test__walkdirs_win32', |
280 | - 'bzrlib.tests.test_ancestry', |
281 | - 'bzrlib.tests.test_annotate', |
282 | - 'bzrlib.tests.test_api', |
283 | - 'bzrlib.tests.test_atomicfile', |
284 | - 'bzrlib.tests.test_bad_files', |
285 | - 'bzrlib.tests.test_bencode', |
286 | - 'bzrlib.tests.test_bisect_multi', |
287 | - 'bzrlib.tests.test_branch', |
288 | - 'bzrlib.tests.test_branchbuilder', |
289 | - 'bzrlib.tests.test_btree_index', |
290 | - 'bzrlib.tests.test_bugtracker', |
291 | - 'bzrlib.tests.test_bundle', |
292 | - 'bzrlib.tests.test_bzrdir', |
293 | - 'bzrlib.tests.test__chunks_to_lines', |
294 | - 'bzrlib.tests.test_cache_utf8', |
295 | - 'bzrlib.tests.test_chk_map', |
296 | - 'bzrlib.tests.test_chk_serializer', |
297 | - 'bzrlib.tests.test_chunk_writer', |
298 | - 'bzrlib.tests.test_clean_tree', |
299 | - 'bzrlib.tests.test_commands', |
300 | - 'bzrlib.tests.test_commit', |
301 | - 'bzrlib.tests.test_commit_merge', |
302 | - 'bzrlib.tests.test_config', |
303 | - 'bzrlib.tests.test_conflicts', |
304 | - 'bzrlib.tests.test_counted_lock', |
305 | - 'bzrlib.tests.test_crash', |
306 | - 'bzrlib.tests.test_decorators', |
307 | - 'bzrlib.tests.test_delta', |
308 | - 'bzrlib.tests.test_debug', |
309 | - 'bzrlib.tests.test_deprecated_graph', |
310 | - 'bzrlib.tests.test_diff', |
311 | - 'bzrlib.tests.test_directory_service', |
312 | - 'bzrlib.tests.test_dirstate', |
313 | - 'bzrlib.tests.test_email_message', |
314 | - 'bzrlib.tests.test_eol_filters', |
315 | - 'bzrlib.tests.test_errors', |
316 | - 'bzrlib.tests.test_export', |
317 | - 'bzrlib.tests.test_extract', |
318 | - 'bzrlib.tests.test_fetch', |
319 | - 'bzrlib.tests.test_fifo_cache', |
320 | - 'bzrlib.tests.test_filters', |
321 | - 'bzrlib.tests.test_ftp_transport', |
322 | - 'bzrlib.tests.test_foreign', |
323 | - 'bzrlib.tests.test_generate_docs', |
324 | - 'bzrlib.tests.test_generate_ids', |
325 | - 'bzrlib.tests.test_globbing', |
326 | - 'bzrlib.tests.test_gpg', |
327 | - 'bzrlib.tests.test_graph', |
328 | - 'bzrlib.tests.test_groupcompress', |
329 | - 'bzrlib.tests.test_hashcache', |
330 | - 'bzrlib.tests.test_help', |
331 | - 'bzrlib.tests.test_hooks', |
332 | - 'bzrlib.tests.test_http', |
333 | - 'bzrlib.tests.test_http_response', |
334 | - 'bzrlib.tests.test_https_ca_bundle', |
335 | - 'bzrlib.tests.test_identitymap', |
336 | - 'bzrlib.tests.test_ignores', |
337 | - 'bzrlib.tests.test_index', |
338 | - 'bzrlib.tests.test_info', |
339 | - 'bzrlib.tests.test_inv', |
340 | - 'bzrlib.tests.test_inventory_delta', |
341 | - 'bzrlib.tests.test_knit', |
342 | - 'bzrlib.tests.test_lazy_import', |
343 | - 'bzrlib.tests.test_lazy_regex', |
344 | - 'bzrlib.tests.test_lock', |
345 | - 'bzrlib.tests.test_lockable_files', |
346 | - 'bzrlib.tests.test_lockdir', |
347 | - 'bzrlib.tests.test_log', |
348 | - 'bzrlib.tests.test_lru_cache', |
349 | - 'bzrlib.tests.test_lsprof', |
350 | - 'bzrlib.tests.test_mail_client', |
351 | - 'bzrlib.tests.test_memorytree', |
352 | - 'bzrlib.tests.test_merge', |
353 | - 'bzrlib.tests.test_merge3', |
354 | - 'bzrlib.tests.test_merge_core', |
355 | - 'bzrlib.tests.test_merge_directive', |
356 | - 'bzrlib.tests.test_missing', |
357 | - 'bzrlib.tests.test_msgeditor', |
358 | - 'bzrlib.tests.test_multiparent', |
359 | - 'bzrlib.tests.test_mutabletree', |
360 | - 'bzrlib.tests.test_nonascii', |
361 | - 'bzrlib.tests.test_options', |
362 | - 'bzrlib.tests.test_osutils', |
363 | - 'bzrlib.tests.test_osutils_encodings', |
364 | - 'bzrlib.tests.test_pack', |
365 | - 'bzrlib.tests.test_patch', |
366 | - 'bzrlib.tests.test_patches', |
367 | - 'bzrlib.tests.test_permissions', |
368 | - 'bzrlib.tests.test_plugins', |
369 | - 'bzrlib.tests.test_progress', |
370 | - 'bzrlib.tests.test_read_bundle', |
371 | - 'bzrlib.tests.test_reconcile', |
372 | - 'bzrlib.tests.test_reconfigure', |
373 | - 'bzrlib.tests.test_registry', |
374 | - 'bzrlib.tests.test_remote', |
375 | - 'bzrlib.tests.test_rename_map', |
376 | - 'bzrlib.tests.test_repository', |
377 | - 'bzrlib.tests.test_revert', |
378 | - 'bzrlib.tests.test_revision', |
379 | - 'bzrlib.tests.test_revisionspec', |
380 | - 'bzrlib.tests.test_revisiontree', |
381 | - 'bzrlib.tests.test_rio', |
382 | - 'bzrlib.tests.test_rules', |
383 | - 'bzrlib.tests.test_sampler', |
384 | - 'bzrlib.tests.test_selftest', |
385 | - 'bzrlib.tests.test_serializer', |
386 | - 'bzrlib.tests.test_setup', |
387 | - 'bzrlib.tests.test_sftp_transport', |
388 | - 'bzrlib.tests.test_shelf', |
389 | - 'bzrlib.tests.test_shelf_ui', |
390 | - 'bzrlib.tests.test_smart', |
391 | - 'bzrlib.tests.test_smart_add', |
392 | - 'bzrlib.tests.test_smart_request', |
393 | - 'bzrlib.tests.test_smart_transport', |
394 | - 'bzrlib.tests.test_smtp_connection', |
395 | - 'bzrlib.tests.test_source', |
396 | - 'bzrlib.tests.test_ssh_transport', |
397 | - 'bzrlib.tests.test_status', |
398 | - 'bzrlib.tests.test_store', |
399 | - 'bzrlib.tests.test_strace', |
400 | - 'bzrlib.tests.test_subsume', |
401 | - 'bzrlib.tests.test_switch', |
402 | - 'bzrlib.tests.test_symbol_versioning', |
403 | - 'bzrlib.tests.test_tag', |
404 | - 'bzrlib.tests.test_testament', |
405 | - 'bzrlib.tests.test_textfile', |
406 | - 'bzrlib.tests.test_textmerge', |
407 | - 'bzrlib.tests.test_timestamp', |
408 | - 'bzrlib.tests.test_trace', |
409 | - 'bzrlib.tests.test_transactions', |
410 | - 'bzrlib.tests.test_transform', |
411 | - 'bzrlib.tests.test_transport', |
412 | - 'bzrlib.tests.test_transport_log', |
413 | - 'bzrlib.tests.test_tree', |
414 | - 'bzrlib.tests.test_treebuilder', |
415 | - 'bzrlib.tests.test_tsort', |
416 | - 'bzrlib.tests.test_tuned_gzip', |
417 | - 'bzrlib.tests.test_ui', |
418 | - 'bzrlib.tests.test_uncommit', |
419 | - 'bzrlib.tests.test_upgrade', |
420 | - 'bzrlib.tests.test_upgrade_stacked', |
421 | - 'bzrlib.tests.test_urlutils', |
422 | - 'bzrlib.tests.test_version', |
423 | - 'bzrlib.tests.test_version_info', |
424 | - 'bzrlib.tests.test_weave', |
425 | - 'bzrlib.tests.test_whitebox', |
426 | - 'bzrlib.tests.test_win32utils', |
427 | - 'bzrlib.tests.test_workingtree', |
428 | - 'bzrlib.tests.test_workingtree_4', |
429 | - 'bzrlib.tests.test_wsgi', |
430 | - 'bzrlib.tests.test_xml', |
431 | - ] |
432 | |
433 | loader = TestUtil.TestLoader() |
434 | |
435 | @@ -3700,24 +3732,9 @@ |
436 | suite = loader.suiteClass() |
437 | |
438 | # modules building their suite with loadTestsFromModuleNames |
439 | - suite.addTest(loader.loadTestsFromModuleNames(testmod_names)) |
440 | - |
441 | - modules_to_doctest = [ |
442 | - 'bzrlib', |
443 | - 'bzrlib.branchbuilder', |
444 | - 'bzrlib.export', |
445 | - 'bzrlib.inventory', |
446 | - 'bzrlib.iterablefile', |
447 | - 'bzrlib.lockdir', |
448 | - 'bzrlib.merge3', |
449 | - 'bzrlib.option', |
450 | - 'bzrlib.symbol_versioning', |
451 | - 'bzrlib.tests', |
452 | - 'bzrlib.timestamp', |
453 | - 'bzrlib.version_info_formats.format_custom', |
454 | - ] |
455 | - |
456 | - for mod in modules_to_doctest: |
457 | + suite.addTest(loader.loadTestsFromModuleNames(_test_suite_testmod_names())) |
458 | + |
459 | + for mod in _test_suite_modules_to_doctest(): |
460 | if not interesting_module(mod): |
461 | # No tests to keep here, move along |
462 | continue |
463 | @@ -3864,8 +3881,7 @@ |
464 | :param new_id: The id to assign to it. |
465 | :return: The new test. |
466 | """ |
467 | - from copy import deepcopy |
468 | - new_test = deepcopy(test) |
469 | + new_test = copy(test) |
470 | new_test.id = lambda: new_id |
471 | return new_test |
472 | |
473 | |
474 | === modified file 'bzrlib/tests/test_selftest.py' |
475 | --- bzrlib/tests/test_selftest.py 2009-08-25 08:11:17 +0000 |
476 | +++ bzrlib/tests/test_selftest.py 2009-08-26 19:35:13 +0000 |
477 | @@ -1773,16 +1773,16 @@ |
478 | tree = self.make_branch_and_memory_tree('a') |
479 | self.assertIsInstance(tree, bzrlib.memorytree.MemoryTree) |
480 | |
481 | - |
482 | -class TestSFTPMakeBranchAndTree(test_sftp_transport.TestCaseWithSFTPServer): |
483 | - |
484 | - def test_make_tree_for_sftp_branch(self): |
485 | - """Transports backed by local directories create local trees.""" |
486 | - # NB: This is arguably a bug in the definition of make_branch_and_tree. |
487 | + def test_make_tree_for_local_vfs_backed_transport(self): |
488 | + # make_branch_and_tree has to use local branch and repositories |
489 | + # when the vfs transport and local disk are colocated, even if |
490 | + # a different transport is in use for url generation. |
491 | + from bzrlib.transport.fakevfat import FakeVFATServer |
492 | + self.transport_server = FakeVFATServer |
493 | + self.assertFalse(self.get_url('t1').startswith('file://')) |
494 | tree = self.make_branch_and_tree('t1') |
495 | base = tree.bzrdir.root_transport.base |
496 | - self.failIf(base.startswith('sftp'), |
497 | - 'base %r is on sftp but should be local' % base) |
498 | + self.assertStartsWith(base, 'file://') |
499 | self.assertEquals(tree.bzrdir.root_transport, |
500 | tree.branch.bzrdir.root_transport) |
501 | self.assertEquals(tree.bzrdir.root_transport, |
502 | @@ -2117,7 +2117,8 @@ |
503 | return self.out, self.err |
504 | |
505 | |
506 | -class TestRunBzrSubprocess(tests.TestCaseWithTransport): |
507 | +class TestWithFakedStartBzrSubprocess(tests.TestCaseWithTransport): |
508 | + """Base class for tests testing how we might run bzr.""" |
509 | |
510 | def setUp(self): |
511 | tests.TestCaseWithTransport.setUp(self) |
512 | @@ -2134,6 +2135,9 @@ |
513 | 'working_dir':working_dir, 'allow_plugins':allow_plugins}) |
514 | return self.next_subprocess |
515 | |
516 | + |
517 | +class TestRunBzrSubprocess(TestWithFakedStartBzrSubprocess): |
518 | + |
519 | def assertRunBzrSubprocess(self, expected_args, process, *args, **kwargs): |
520 | """Run run_bzr_subprocess with args and kwargs using a stubbed process. |
521 | |
522 | @@ -2202,6 +2206,32 @@ |
523 | StubProcess(), '', allow_plugins=True) |
524 | |
525 | |
526 | +class TestFinishBzrSubprocess(TestWithFakedStartBzrSubprocess): |
527 | + |
528 | + def test_finish_bzr_subprocess_with_error(self): |
529 | + """finish_bzr_subprocess allows specification of the desired exit code. |
530 | + """ |
531 | + process = StubProcess(err="unknown command", retcode=3) |
532 | + result = self.finish_bzr_subprocess(process, retcode=3) |
533 | + self.assertEqual('', result[0]) |
534 | + self.assertContainsRe(result[1], 'unknown command') |
535 | + |
536 | + def test_finish_bzr_subprocess_ignoring_retcode(self): |
537 | + """finish_bzr_subprocess allows the exit code to be ignored.""" |
538 | + process = StubProcess(err="unknown command", retcode=3) |
539 | + result = self.finish_bzr_subprocess(process, retcode=None) |
540 | + self.assertEqual('', result[0]) |
541 | + self.assertContainsRe(result[1], 'unknown command') |
542 | + |
543 | + def test_finish_subprocess_with_unexpected_retcode(self): |
544 | + """finish_bzr_subprocess raises self.failureException if the retcode is |
545 | + not the expected one. |
546 | + """ |
547 | + process = StubProcess(err="unknown command", retcode=3) |
548 | + self.assertRaises(self.failureException, self.finish_bzr_subprocess, |
549 | + process) |
550 | + |
551 | + |
552 | class _DontSpawnProcess(Exception): |
553 | """A simple exception which just allows us to skip unnecessary steps""" |
554 | |
555 | @@ -2285,39 +2315,8 @@ |
556 | self.assertEqual(['foo', 'current'], chdirs) |
557 | |
558 | |
559 | -class TestBzrSubprocess(tests.TestCaseWithTransport): |
560 | - |
561 | - def test_start_and_stop_bzr_subprocess(self): |
562 | - """We can start and perform other test actions while that process is |
563 | - still alive. |
564 | - """ |
565 | - process = self.start_bzr_subprocess(['--version']) |
566 | - result = self.finish_bzr_subprocess(process) |
567 | - self.assertContainsRe(result[0], 'is free software') |
568 | - self.assertEqual('', result[1]) |
569 | - |
570 | - def test_start_and_stop_bzr_subprocess_with_error(self): |
571 | - """finish_bzr_subprocess allows specification of the desired exit code. |
572 | - """ |
573 | - process = self.start_bzr_subprocess(['--versionn']) |
574 | - result = self.finish_bzr_subprocess(process, retcode=3) |
575 | - self.assertEqual('', result[0]) |
576 | - self.assertContainsRe(result[1], 'unknown command') |
577 | - |
578 | - def test_start_and_stop_bzr_subprocess_ignoring_retcode(self): |
579 | - """finish_bzr_subprocess allows the exit code to be ignored.""" |
580 | - process = self.start_bzr_subprocess(['--versionn']) |
581 | - result = self.finish_bzr_subprocess(process, retcode=None) |
582 | - self.assertEqual('', result[0]) |
583 | - self.assertContainsRe(result[1], 'unknown command') |
584 | - |
585 | - def test_start_and_stop_bzr_subprocess_with_unexpected_retcode(self): |
586 | - """finish_bzr_subprocess raises self.failureException if the retcode is |
587 | - not the expected one. |
588 | - """ |
589 | - process = self.start_bzr_subprocess(['--versionn']) |
590 | - self.assertRaises(self.failureException, self.finish_bzr_subprocess, |
591 | - process) |
592 | +class TestActuallyStartBzrSubprocess(tests.TestCaseWithTransport): |
593 | + """Tests that really need to do things with an external bzr.""" |
594 | |
595 | def test_start_and_stop_bzr_subprocess_send_signal(self): |
596 | """finish_bzr_subprocess raises self.failureException if the retcode is |
597 | @@ -2331,14 +2330,6 @@ |
598 | self.assertEqual('', result[0]) |
599 | self.assertEqual('bzr: interrupted\n', result[1]) |
600 | |
601 | - def test_start_and_stop_working_dir(self): |
602 | - cwd = osutils.getcwd() |
603 | - self.make_branch_and_tree('one') |
604 | - process = self.start_bzr_subprocess(['root'], working_dir='one') |
605 | - result = self.finish_bzr_subprocess(process, universal_newlines=True) |
606 | - self.assertEndsWith(result[0], 'one\n') |
607 | - self.assertEqual('', result[1]) |
608 | - |
609 | |
610 | class TestKnownFailure(tests.TestCase): |
611 | |
612 | @@ -2726,10 +2717,52 @@ |
613 | |
614 | class TestTestSuite(tests.TestCase): |
615 | |
616 | + def test__test_suite_testmod_names(self): |
617 | + # Test that a plausible list of test module names are returned |
618 | + # by _test_suite_testmod_names. |
619 | + test_list = tests._test_suite_testmod_names() |
620 | + self.assertSubset([ |
621 | + 'bzrlib.tests.blackbox', |
622 | + 'bzrlib.tests.per_transport', |
623 | + 'bzrlib.tests.test_selftest', |
624 | + ], |
625 | + test_list) |
626 | + |
627 | + def test__test_suite_modules_to_doctest(self): |
628 | + # Test that a plausible list of modules to doctest is returned |
629 | + # by _test_suite_modules_to_doctest. |
630 | + test_list = tests._test_suite_modules_to_doctest() |
631 | + self.assertSubset([ |
632 | + 'bzrlib.timestamp', |
633 | + ], |
634 | + test_list) |
635 | + |
636 | def test_test_suite(self): |
637 | - # This test is slow - it loads the entire test suite to operate, so we |
638 | - # do a single test with one test in each category |
639 | - test_list = [ |
640 | + # test_suite() loads the entire test suite to operate. To avoid this |
641 | + # overhead, and yet still be confident that things are happening, |
642 | + # we temporarily replace two functions used by test_suite with |
643 | + # test doubles that supply a few sample tests to load, and check they |
644 | + # are loaded. |
645 | + calls = [] |
646 | + def _test_suite_testmod_names(): |
647 | + calls.append("testmod_names") |
648 | + return [ |
649 | + 'bzrlib.tests.blackbox.test_branch', |
650 | + 'bzrlib.tests.per_transport', |
651 | + 'bzrlib.tests.test_selftest', |
652 | + ] |
653 | + original_testmod_names = tests._test_suite_testmod_names |
654 | + def _test_suite_modules_to_doctest(): |
655 | + calls.append("modules_to_doctest") |
656 | + return ['bzrlib.timestamp'] |
657 | + orig_modules_to_doctest = tests._test_suite_modules_to_doctest |
658 | + def restore_names(): |
659 | + tests._test_suite_testmod_names = original_testmod_names |
660 | + tests._test_suite_modules_to_doctest = orig_modules_to_doctest |
661 | + self.addCleanup(restore_names) |
662 | + tests._test_suite_testmod_names = _test_suite_testmod_names |
663 | + tests._test_suite_modules_to_doctest = _test_suite_modules_to_doctest |
664 | + expected_test_list = [ |
665 | # testmod_names |
666 | 'bzrlib.tests.blackbox.test_branch.TestBranch.test_branch', |
667 | ('bzrlib.tests.per_transport.TransportTests' |
668 | @@ -2740,13 +2773,16 @@ |
669 | # plugins can't be tested that way since selftest may be run with |
670 | # --no-plugins |
671 | ] |
672 | - suite = tests.test_suite(test_list) |
673 | - self.assertEquals(test_list, _test_ids(suite)) |
674 | + suite = tests.test_suite() |
675 | + self.assertEqual(set(["testmod_names", "modules_to_doctest"]), |
676 | + set(calls)) |
677 | + self.assertSubset(expected_test_list, _test_ids(suite)) |
678 | |
679 | def test_test_suite_list_and_start(self): |
680 | # We cannot test this at the same time as the main load, because we want |
681 | - # to know that starting_with == None works. So a second full load is |
682 | - # incurred. |
683 | + # to know that starting_with == None works. So a second load is |
684 | + # incurred - note that the starting_with parameter causes a partial load |
685 | + # rather than a full load so this test should be pretty quick. |
686 | test_list = ['bzrlib.tests.test_selftest.TestTestSuite.test_test_suite'] |
687 | suite = tests.test_suite(test_list, |
688 | ['bzrlib.tests.test_selftest.TestTestSuite']) |
This branch: bzr_subprocess that really only care about the and_stop_ working_ dir test. make_branch_ and_tree.
* Use copy, not deepcopy, to clone tests in test parameterisation.
* Make tests for finish_
interface use StubProcess.
* Remove duplicated test_start_
* Remove unnecessary use of an SFTP server connection to test the
behaviour of TestCase.
* Refactor test_suite to make stubbing out the list of tests to load
possible without sacrificing coverage.
-Rob