319
323
return self.workingtree_to_test_tree(tree)
322
class TreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
326
def make_scenarios(transport_server, transport_readonly_server, formats):
323
327
"""Generate test suites for each Tree implementation in bzrlib.
325
329
Currently this covers all working tree formats, and RevisionTree and
326
330
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',
333
scenarios = wt_make_scenarios(transport_server, transport_readonly_server,
335
# now adjust the scenarios and add the non-working-tree tree scenarios.
336
for scenario in scenarios:
337
# for working tree format tests, preserve the tree
338
scenario[1]["_workingtree_to_test_tree"] = return_parameter
339
# add RevisionTree scenario
340
workingtree_format = WorkingTreeFormat._default_format
341
scenarios.append((RevisionTree.__name__,
342
create_tree_scenario(transport_server, transport_readonly_server,
343
workingtree_format, revision_tree_from_workingtree,)))
345
# also test WorkingTree4/5's RevisionTree implementation which is
347
# XXX: Ask igc if WT5 revision tree actually is different.
348
scenarios.append((DirStateRevisionTree.__name__ + ",WT4",
349
create_tree_scenario(transport_server, transport_readonly_server,
350
WorkingTreeFormat4(), _dirstate_tree_from_workingtree)))
351
scenarios.append((DirStateRevisionTree.__name__ + ",WT5",
352
create_tree_scenario(transport_server, transport_readonly_server,
353
WorkingTreeFormat5(), _dirstate_tree_from_workingtree)))
354
scenarios.append(("PreviewTree", create_tree_scenario(transport_server,
355
transport_readonly_server, workingtree_format, preview_tree_pre)))
356
scenarios.append(("PreviewTreePost", create_tree_scenario(transport_server,
357
transport_readonly_server, workingtree_format, preview_tree_post)))
361
def create_tree_scenario(transport_server, transport_readonly_server,
362
workingtree_format, converter):
363
"""Create a scenario for the specified converter
365
:param converter: A function that converts a workingtree into the
367
:param workingtree_format: The particular workingtree format to
369
:return: a (name, options) tuple, where options is a dict of values
370
to be used as members of the TestCase.
372
scenario_options = wt_make_scenario(transport_server,
373
transport_readonly_server,
375
scenario_options["_workingtree_to_test_tree"] = converter
376
return scenario_options
379
def load_tests(standard_tests, module, loader):
380
per_tree_mod_names = [
383
'get_file_with_stat',
385
'get_symlink_target',
389
'path_content_summary',
397
adapter = TreeTestProviderAdapter(
395
submod_tests = loader.loadTestsFromModuleNames(
396
['bzrlib.tests.per_tree.test_' + name
397
for name in per_tree_mod_names])
398
scenarios = make_scenarios(
399
tests.default_transport,
399
400
# None here will cause a readonly decorator to be created
400
401
# by the TestCaseWithTransport.get_readonly_transport method.
402
403
WorkingTreeFormat._formats.values() + _legacy_formats)
404
404
# add the tests for the sub modules
405
adapt_modules(test_tree_implementations, adapter, loader, result)
405
return tests.multiply_tests(submod_tests, scenarios, standard_tests)