319
308
return self.workingtree_to_test_tree(tree)
322
class TreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
311
def make_scenarios(transport_server, transport_readonly_server, formats):
323
312
"""Generate test suites for each Tree implementation in bzrlib.
325
314
Currently this covers all working tree formats, and RevisionTree and
326
315
DirStateRevisionTree by committing a working tree to create the revision
330
def __init__(self, transport_server, transport_readonly_server, formats):
331
"""Create a TreeTestProviderAdapter.
333
:param formats: [workingtree_format]
335
super(TreeTestProviderAdapter, self).__init__(transport_server,
336
transport_readonly_server, formats)
337
# now adjust the scenarios and add the non-working-tree tree scenarios.
338
for scenario in self.scenarios:
339
# for working tree adapted tests, preserve the tree
340
scenario[1]["_workingtree_to_test_tree"] = return_parameter
341
# add RevisionTree scenario
342
self.scenarios.append(self.create_tree_scenario(RevisionTree.__name__,
343
revision_tree_from_workingtree,))
345
# also test WorkingTree4's RevisionTree implementation which is
347
self.scenarios.append(self.create_tree_scenario(
348
DirStateRevisionTree.__name__, _dirstate_tree_from_workingtree,
349
WorkingTreeFormat4()))
350
self.scenarios.append(self.create_tree_scenario(
351
DirStateRevisionTree.__name__, _dirstate_tree_from_workingtree,
352
WorkingTreeFormat5()))
353
self.scenarios.append(self.create_tree_scenario('PreviewTree',
355
self.scenarios.append(self.create_tree_scenario('PreviewTreePost',
358
def create_tree_scenario(self, name, converter, workingtree_format=None):
359
"""Create a scenario for the specified converter
361
:param name: The name to append to tests using this converter
362
:param converter: A function that converts a workingtree into the
364
:param workingtree_format: The particular workingtree format to
366
:return: a (name, options) tuple, where options is a dict of values
367
to be used as members of the TestCase.
369
if workingtree_format is None:
370
workingtree_format = WorkingTreeFormat._default_format
371
scenario_options = WorkingTreeTestProviderAdapter.create_scenario(self,
372
workingtree_format)[1]
373
scenario_options["_workingtree_to_test_tree"] = converter
374
return name, scenario_options
377
def load_tests(basic_tests, module, loader):
378
result = loader.suiteClass()
379
# add the tests for this module
380
result.addTests(basic_tests)
382
test_tree_implementations = [
383
'bzrlib.tests.tree_implementations.test_annotate_iter',
384
'bzrlib.tests.tree_implementations.test_get_file_mtime',
385
'bzrlib.tests.tree_implementations.test_get_root_id',
386
'bzrlib.tests.tree_implementations.test_get_symlink_target',
387
'bzrlib.tests.tree_implementations.test_inv',
388
'bzrlib.tests.tree_implementations.test_iter_search_rules',
389
'bzrlib.tests.tree_implementations.test_list_files',
390
'bzrlib.tests.tree_implementations.test_path_content_summary',
391
'bzrlib.tests.tree_implementations.test_revision_tree',
392
'bzrlib.tests.tree_implementations.test_test_trees',
393
'bzrlib.tests.tree_implementations.test_tree',
394
'bzrlib.tests.tree_implementations.test_walkdirs',
318
scenarios = wt_make_scenarios(transport_server, transport_readonly_server,
320
# now adjust the scenarios and add the non-working-tree tree scenarios.
321
for scenario in scenarios:
322
# for working tree format tests, preserve the tree
323
scenario[1]["_workingtree_to_test_tree"] = return_parameter
324
# add RevisionTree scenario
325
workingtree_format = WorkingTreeFormat._default_format
326
scenarios.append((RevisionTree.__name__,
327
create_tree_scenario(transport_server, transport_readonly_server,
328
workingtree_format, revision_tree_from_workingtree,)))
330
# also test WorkingTree4/5's RevisionTree implementation which is
332
# XXX: Ask igc if WT5 revision tree actually is different.
333
scenarios.append((DirStateRevisionTree.__name__ + ",WT4",
334
create_tree_scenario(transport_server, transport_readonly_server,
335
WorkingTreeFormat4(), _dirstate_tree_from_workingtree)))
336
scenarios.append((DirStateRevisionTree.__name__ + ",WT5",
337
create_tree_scenario(transport_server, transport_readonly_server,
338
WorkingTreeFormat5(), _dirstate_tree_from_workingtree)))
339
scenarios.append(("PreviewTree", create_tree_scenario(transport_server,
340
transport_readonly_server, workingtree_format, preview_tree_pre)))
341
scenarios.append(("PreviewTreePost", create_tree_scenario(transport_server,
342
transport_readonly_server, workingtree_format, preview_tree_post)))
346
def create_tree_scenario(transport_server, transport_readonly_server,
347
workingtree_format, converter):
348
"""Create a scenario for the specified converter
350
:param converter: A function that converts a workingtree into the
352
:param workingtree_format: The particular workingtree format to
354
:return: a (name, options) tuple, where options is a dict of values
355
to be used as members of the TestCase.
357
scenario_options = wt_make_scenario(transport_server,
358
transport_readonly_server,
360
scenario_options["_workingtree_to_test_tree"] = converter
361
return scenario_options
364
def load_tests(standard_tests, module, loader):
365
per_tree_mod_names = [
368
'get_file_with_stat',
370
'get_symlink_target',
374
'path_content_summary',
397
adapter = TreeTestProviderAdapter(
380
submod_tests = loader.loadTestsFromModuleNames(
381
['bzrlib.tests.per_tree.test_' + name
382
for name in per_tree_mod_names])
383
scenarios = make_scenarios(
384
tests.default_transport,
399
385
# None here will cause a readonly decorator to be created
400
386
# by the TestCaseWithTransport.get_readonly_transport method.
402
388
WorkingTreeFormat._formats.values() + _legacy_formats)
404
389
# add the tests for the sub modules
405
adapt_modules(test_tree_implementations, adapter, loader, result)
390
return tests.multiply_tests(submod_tests, scenarios, standard_tests)