29
from bzrlib.tests import script
32
def load_tests(standard_tests, module, loader):
33
result = loader.suiteClass()
35
sp_tests, remaining_tests = tests.split_suite_by_condition(
36
standard_tests, tests.condition_isinstance((
37
TestParametrizedResolveConflicts,
39
# Each test class defines its own scenarios. This is needed for
40
# TestResolvePathConflictBefore531967 that verifies that the same tests as
41
# TestResolvePathConflict still pass.
42
for test in tests.iter_suite_tests(sp_tests):
43
tests.apply_scenarios(test, test.scenarios(), result)
45
# No parametrization for the remaining tests
46
result.addTests(remaining_tests)
29
from bzrlib.tests import (
35
load_tests = scenarios.load_tests_apply_scenarios
51
38
# TODO: Test commit with some added, and added-but-missing files
298
"""Return the scenario list for the conflict type defined by the class.
300
Each scenario is of the form:
301
(common, (left_name, left_dict), (right_name, right_dict))
305
* left_name and right_name are the scenario names that will be combined
307
* left_dict and right_dict are the attributes specific to each half of
308
the scenario. They should include at least 'actions' and 'check' and
309
will be available as '_this' and '_other' test instance attributes.
311
Daughters classes are free to add their specific attributes as they see
312
fit in any of the three dicts.
314
This is a class method so that load_tests can find it.
316
'_base_actions' in the common dict, 'actions' and 'check' in the left
317
and right dicts use names that map to methods in the test classes. Some
318
prefixes are added to these names to get the correspong methods (see
319
_get_actions() and _get_check()). The motivation here is to avoid
320
collisions in the class namespace.
322
# Only concrete classes return actual scenarios
284
"""The scenario list for the conflict type defined by the class.
286
Each scenario is of the form:
287
(common, (left_name, left_dict), (right_name, right_dict))
291
* left_name and right_name are the scenario names that will be combined
293
* left_dict and right_dict are the attributes specific to each half of
294
the scenario. They should include at least 'actions' and 'check' and
295
will be available as '_this' and '_other' test instance attributes.
297
Daughters classes are free to add their specific attributes as they see
298
fit in any of the three dicts.
300
This is a class method so that load_tests can find it.
302
'_base_actions' in the common dict, 'actions' and 'check' in the left
303
and right dicts use names that map to methods in the test classes. Some
304
prefixes are added to these names to get the correspong methods (see
305
_get_actions() and _get_check()). The motivation here is to avoid
306
collisions in the class namespace.
326
310
super(TestParametrizedResolveConflicts, self).setUp()
391
375
class TestResolveContentsConflict(TestParametrizedResolveConflicts):
393
_conflict_type = conflicts.ContentsConflict,
377
_conflict_type = conflicts.ContentsConflict
395
# Set by load_tests from scenarios()
379
# Set by the scenarios
396
380
# path and file-id for the file involved in the conflict
384
scenarios = mirror_scenarios(
403
386
# File modified/deleted
404
387
(dict(_base_actions='create_file',
405
388
_path='file', _file_id='file-id'),
407
390
dict(actions='modify_file', check='file_has_more_content')),
409
392
dict(actions='delete_file', check='file_doesnt_exist')),),
411
return mirror_scenarios(base_scenarios)
413
395
def do_create_file(self):
414
396
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
437
419
class TestResolvePathConflict(TestParametrizedResolveConflicts):
439
_conflict_type = conflicts.PathConflict,
421
_conflict_type = conflicts.PathConflict
441
423
def do_nothing(self):
446
# Each side dict additionally defines:
447
# - path path involved (can be '<deleted>')
426
# Each side dict additionally defines:
427
# - path path involved (can be '<deleted>')
429
scenarios = mirror_scenarios(
450
431
# File renamed/deleted
451
432
(dict(_base_actions='create_file'),
484
465
dict(actions='rename_dir2', check='dir_renamed2',
485
466
path='new-dir2', file_id='dir-id')),),
487
return mirror_scenarios(base_scenarios)
489
469
def do_create_file(self):
490
470
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
569
549
class TestResolveDuplicateEntry(TestParametrizedResolveConflicts):
571
_conflict_type = conflicts.DuplicateEntry,
551
_conflict_type = conflicts.DuplicateEntry
575
# Each side dict additionally defines:
553
scenarios = mirror_scenarios(
579
555
# File created with different file-ids
580
556
(dict(_base_actions='nothing'),
581
557
('filea_created',
584
560
('fileb_created',
585
561
dict(actions='create_file_b', check='file_content_b',
586
562
path='file', file_id='file-b-id')),),
588
return mirror_scenarios(base_scenarios)
590
565
def do_nothing(self):
625
600
# tests MissingParent resolution :-/
631
$ bzr commit -m 'Create trunk'
607
$ bzr commit -m 'Create trunk' -q
633
608
$ echo 'trunk content' >dir/file
635
$ bzr commit -m 'Add dir/file in trunk'
637
$ bzr branch . -r 1 ../branch
609
$ bzr add -q dir/file
610
$ bzr commit -q -m 'Add dir/file in trunk'
611
$ bzr branch -q . -r 1 ../branch
640
$ bzr commit -m 'Remove dir in branch'
614
$ bzr commit -q -m 'Remove dir in branch'
642
615
$ bzr merge ../trunk
650
623
def test_take_this(self):
651
624
self.run_script("""
625
$ bzr rm -q dir --force
653
626
$ bzr resolve dir
654
$ bzr commit --strict -m 'No more conflicts nor unknown files'
627
2>2 conflict(s) resolved, 0 remaining
628
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
657
631
def test_take_other(self):
658
632
self.run_script("""
659
633
$ bzr resolve dir
660
$ bzr commit --strict -m 'No more conflicts nor unknown files'
634
2>2 conflict(s) resolved, 0 remaining
635
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
670
646
$ echo 'trunk content' >dir/file
672
$ bzr commit -m 'Create trunk'
648
$ bzr commit -m 'Create trunk' -q
674
649
$ echo 'trunk content' >dir/file2
676
$ bzr commit -m 'Add dir/file2 in branch'
678
$ bzr branch . -r 1 ../branch
650
$ bzr add -q dir/file2
651
$ bzr commit -q -m 'Add dir/file2 in branch'
652
$ bzr branch -q . -r 1 ../branch
680
$ bzr rm dir/file --force
682
$ bzr commit -m 'Remove dir/file'
654
$ bzr rm -q dir/file --force
656
$ bzr commit -q -m 'Remove dir/file'
684
657
$ bzr merge ../trunk
692
665
def test_keep_them_all(self):
693
666
self.run_script("""
694
667
$ bzr resolve dir
695
$ bzr commit --strict -m 'No more conflicts nor unknown files'
668
2>2 conflict(s) resolved, 0 remaining
669
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
698
672
def test_adopt_child(self):
699
673
self.run_script("""
700
$ bzr mv dir/file2 file2
674
$ bzr mv -q dir/file2 file2
675
$ bzr rm -q dir --force
702
676
$ bzr resolve dir
703
$ bzr commit --strict -m 'No more conflicts nor unknown files'
677
2>2 conflict(s) resolved, 0 remaining
678
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
706
681
def test_kill_them_all(self):
707
682
self.run_script("""
683
$ bzr rm -q dir --force
709
684
$ bzr resolve dir
710
$ bzr commit --strict -m 'No more conflicts nor unknown files'
685
2>2 conflict(s) resolved, 0 remaining
686
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
713
689
def test_resolve_taking_this(self):
714
690
self.run_script("""
715
691
$ bzr resolve --take-this dir
716
$ bzr commit --strict -m 'No more conflicts nor unknown files'
693
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
719
696
def test_resolve_taking_other(self):
720
697
self.run_script("""
721
698
$ bzr resolve --take-other dir
722
$ bzr commit --strict -m 'No more conflicts nor unknown files'
700
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
732
711
$ echo 'trunk content' >dir/file
734
$ bzr commit -m 'Create trunk'
736
$ bzr rm dir/file --force
738
$ bzr commit -m 'Remove dir/file'
740
$ bzr branch . -r 1 ../branch
713
$ bzr commit -m 'Create trunk' -q
714
$ bzr rm -q dir/file --force
715
$ bzr rm -q dir --force
716
$ bzr commit -q -m 'Remove dir/file'
717
$ bzr branch -q . -r 1 ../branch
742
719
$ echo 'branch content' >dir/file2
744
$ bzr commit -m 'Add dir/file2 in branch'
720
$ bzr add -q dir/file2
721
$ bzr commit -q -m 'Add dir/file2 in branch'
746
722
$ bzr merge ../trunk
748
724
2>Conflict: can't delete dir because it is not empty. Not deleting.
753
729
def test_keep_them_all(self):
754
730
self.run_script("""
755
731
$ bzr resolve dir
756
$ bzr commit --strict -m 'No more conflicts nor unknown files'
732
2>2 conflict(s) resolved, 0 remaining
733
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
759
736
def test_adopt_child(self):
760
737
self.run_script("""
761
$ bzr mv dir/file2 file2
738
$ bzr mv -q dir/file2 file2
739
$ bzr rm -q dir --force
763
740
$ bzr resolve dir
764
$ bzr commit --strict -m 'No more conflicts nor unknown files'
741
2>2 conflict(s) resolved, 0 remaining
742
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
767
745
def test_kill_them_all(self):
768
746
self.run_script("""
747
$ bzr rm -q dir --force
770
748
$ bzr resolve dir
771
$ bzr commit --strict -m 'No more conflicts nor unknown files'
749
2>2 conflict(s) resolved, 0 remaining
750
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
774
753
def test_resolve_taking_this(self):
775
754
self.run_script("""
776
755
$ bzr resolve --take-this dir
777
$ bzr commit --strict -m 'No more conflicts nor unknown files'
756
2>2 conflict(s) resolved, 0 remaining
757
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
780
760
def test_resolve_taking_other(self):
781
761
self.run_script("""
782
762
$ bzr resolve --take-other dir
783
$ bzr commit --strict -m 'No more conflicts nor unknown files'
765
2>2 conflict(s) resolved, 0 remaining
766
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
787
770
class TestResolveParentLoop(TestParametrizedResolveConflicts):
789
_conflict_type = conflicts.ParentLoop,
772
_conflict_type = conflicts.ParentLoop
791
774
_this_args = None
792
775
_other_args = None
796
# Each side dict additionally defines:
797
# - dir_id: the directory being moved
798
# - target_id: The target directory
799
# - xfail: whether the test is expected to fail if the action is
800
# involved as 'other'
777
# Each side dict additionally defines:
778
# - dir_id: the directory being moved
779
# - target_id: The target directory
780
# - xfail: whether the test is expected to fail if the action is
781
# involved as 'other'
782
scenarios = mirror_scenarios(
802
784
# Dirs moved into each other
803
785
(dict(_base_actions='create_dir1_dir2'),
804
786
('dir1_into_dir2',
815
797
('dir3_into_dir2',
816
798
dict(actions='move_dir3_into_dir2', check='dir3_4_moved',
817
799
dir_id='dir3-id', target_id='dir2-id', xfail=True))),
819
return mirror_scenarios(base_scenarios)
821
802
def do_create_dir1_dir2(self):
822
803
return [('add', ('dir1', 'dir1-id', 'directory', '')),
887
$ bzr commit -m 'Create trunk'
870
$ bzr commit -m 'Create trunk' -q
888
871
$ echo "Boing" >foo/bar
890
$ bzr commit -m 'Add foo/bar'
892
$ bzr branch . -r 1 ../branch
873
$ bzr commit -q -m 'Add foo/bar'
874
$ bzr branch -q . -r 1 ../branch
895
877
$ echo "Boo!" >foo
896
$ bzr commit -m 'foo is now a file'
878
$ bzr commit -q -m 'foo is now a file'
898
879
$ bzr merge ../trunk
900
881
2>RK foo => foo.new/
907
888
def test_take_this(self):
908
889
self.run_script("""
909
$ bzr rm foo.new --force
890
$ bzr rm -q foo.new --force
910
891
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
911
892
# aside ? -- vila 090916
913
894
$ bzr resolve foo.new
914
$ bzr commit --strict -m 'No more conflicts nor unknown files'
895
2>1 conflict(s) resolved, 0 remaining
896
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
917
899
def test_take_other(self):
918
900
self.run_script("""
901
$ bzr rm -q foo --force
902
$ bzr mv -q foo.new foo
921
903
$ bzr resolve foo
922
$ bzr commit --strict -m 'No more conflicts nor unknown files'
904
2>1 conflict(s) resolved, 0 remaining
905
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
925
908
def test_resolve_taking_this(self):
926
909
self.run_script("""
927
910
$ bzr resolve --take-this foo.new
928
$ bzr commit --strict -m 'No more conflicts nor unknown files'
912
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
931
915
def test_resolve_taking_other(self):
932
916
self.run_script("""
933
917
$ bzr resolve --take-other foo.new
934
$ bzr commit --strict -m 'No more conflicts nor unknown files'
919
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
944
929
self.run_script("""
948
$ bzr commit -m 'Create trunk'
935
$ bzr commit -m 'Create trunk' -q
950
937
$ echo "Boo!" >foo
951
$ bzr commit -m 'foo is now a file'
953
$ bzr branch . -r 1 ../branch
938
$ bzr commit -m 'foo is now a file' -q
939
$ bzr branch -q . -r 1 ../branch -q
955
941
$ echo "Boing" >foo/bar
957
$ bzr commit -m 'Add foo/bar'
942
$ bzr add -q foo/bar -q
943
$ bzr commit -m 'Add foo/bar' -q
959
944
$ bzr merge ../trunk
960
945
2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]