319
320
return self.workingtree_to_test_tree(tree)
322
class TreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
323
def make_scenarios(transport_server, transport_readonly_server, formats):
323
324
"""Generate test suites for each Tree implementation in bzrlib.
325
326
Currently this covers all working tree formats, and RevisionTree and
326
327
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
330
scenarios = wt_make_scenarios(transport_server, transport_readonly_server,
332
# now adjust the scenarios and add the non-working-tree tree scenarios.
333
for scenario in scenarios:
334
# for working tree format tests, preserve the tree
335
scenario[1]["_workingtree_to_test_tree"] = return_parameter
341
336
# 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 = [
337
workingtree_format = WorkingTreeFormat._default_format
338
scenarios.append((RevisionTree.__name__,
339
create_tree_scenario(transport_server, transport_readonly_server,
340
workingtree_format, revision_tree_from_workingtree,)))
342
# also test WorkingTree4/5's RevisionTree implementation which is
344
# XXX: Ask igc if WT5 revision tree actually is different.
345
scenarios.append((DirStateRevisionTree.__name__ + ",WT4",
346
create_tree_scenario(transport_server, transport_readonly_server,
347
WorkingTreeFormat4(), _dirstate_tree_from_workingtree)))
348
scenarios.append((DirStateRevisionTree.__name__ + ",WT5",
349
create_tree_scenario(transport_server, transport_readonly_server,
350
WorkingTreeFormat5(), _dirstate_tree_from_workingtree)))
351
scenarios.append(("PreviewTree", create_tree_scenario(transport_server,
352
transport_readonly_server, workingtree_format, preview_tree_pre)))
353
scenarios.append(("PreviewTreePost", create_tree_scenario(transport_server,
354
transport_readonly_server, workingtree_format, preview_tree_post)))
358
def create_tree_scenario(transport_server, transport_readonly_server,
359
workingtree_format, converter):
360
"""Create a scenario for the specified converter
362
:param name: The name to append to tests using this converter
363
:param converter: A function that converts a workingtree into the
365
:param workingtree_format: The particular workingtree format to
367
:return: a (name, options) tuple, where options is a dict of values
368
to be used as members of the TestCase.
370
scenario_options = wt_make_scenario(transport_server, transport_readonly_server,
372
scenario_options["_workingtree_to_test_tree"] = converter
373
return scenario_options
376
def load_tests(standard_tests, module, loader):
377
submod_tests = loader.loadTestsFromModuleNames([
383
378
'bzrlib.tests.tree_implementations.test_annotate_iter',
384
379
'bzrlib.tests.tree_implementations.test_get_file_mtime',
385
380
'bzrlib.tests.tree_implementations.test_get_root_id',