29
from bzrlib.tests import (
35
load_tests = scenarios.load_tests_apply_scenarios
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)
38
51
# TODO: Test commit with some added, and added-but-missing files
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.
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
310
326
super(TestParametrizedResolveConflicts, self).setUp()
375
391
class TestResolveContentsConflict(TestParametrizedResolveConflicts):
377
_conflict_type = conflicts.ContentsConflict
393
_conflict_type = conflicts.ContentsConflict,
379
# Set by the scenarios
395
# Set by load_tests from scenarios()
380
396
# path and file-id for the file involved in the conflict
384
scenarios = mirror_scenarios(
386
403
# File modified/deleted
387
404
(dict(_base_actions='create_file',
388
405
_path='file', _file_id='file-id'),
390
407
dict(actions='modify_file', check='file_has_more_content')),
392
409
dict(actions='delete_file', check='file_doesnt_exist')),),
411
return mirror_scenarios(base_scenarios)
395
413
def do_create_file(self):
396
414
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
419
437
class TestResolvePathConflict(TestParametrizedResolveConflicts):
421
_conflict_type = conflicts.PathConflict
439
_conflict_type = conflicts.PathConflict,
423
441
def do_nothing(self):
426
# Each side dict additionally defines:
427
# - path path involved (can be '<deleted>')
429
scenarios = mirror_scenarios(
446
# Each side dict additionally defines:
447
# - path path involved (can be '<deleted>')
431
450
# File renamed/deleted
432
451
(dict(_base_actions='create_file'),
465
484
dict(actions='rename_dir2', check='dir_renamed2',
466
485
path='new-dir2', file_id='dir-id')),),
487
return mirror_scenarios(base_scenarios)
469
489
def do_create_file(self):
470
490
return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
549
569
class TestResolveDuplicateEntry(TestParametrizedResolveConflicts):
551
_conflict_type = conflicts.DuplicateEntry
571
_conflict_type = conflicts.DuplicateEntry,
553
scenarios = mirror_scenarios(
575
# Each side dict additionally defines:
555
579
# File created with different file-ids
556
580
(dict(_base_actions='nothing'),
557
581
('filea_created',
560
584
('fileb_created',
561
585
dict(actions='create_file_b', check='file_content_b',
562
586
path='file', file_id='file-b-id')),),
588
return mirror_scenarios(base_scenarios)
565
590
def do_nothing(self):
600
625
# tests MissingParent resolution :-/
607
$ bzr commit -m 'Create trunk' -q
631
$ bzr commit -m 'Create trunk'
608
633
$ echo 'trunk content' >dir/file
609
$ bzr add -q dir/file
610
$ bzr commit -q -m 'Add dir/file in trunk'
611
$ bzr branch -q . -r 1 ../branch
635
$ bzr commit -m 'Add dir/file in trunk'
637
$ bzr branch . -r 1 ../branch
614
$ bzr commit -q -m 'Remove dir in branch'
640
$ bzr commit -m 'Remove dir in branch'
615
642
$ bzr merge ../trunk
623
650
def test_take_this(self):
624
651
self.run_script("""
625
$ bzr rm -q dir --force
626
653
$ bzr resolve dir
627
2>2 conflict(s) resolved, 0 remaining
628
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
654
$ bzr commit --strict -m 'No more conflicts nor unknown files'
631
657
def test_take_other(self):
632
658
self.run_script("""
633
659
$ bzr resolve dir
634
2>2 conflict(s) resolved, 0 remaining
635
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
660
$ bzr commit --strict -m 'No more conflicts nor unknown files'
646
670
$ echo 'trunk content' >dir/file
648
$ bzr commit -m 'Create trunk' -q
672
$ bzr commit -m 'Create trunk'
649
674
$ echo 'trunk content' >dir/file2
650
$ bzr add -q dir/file2
651
$ bzr commit -q -m 'Add dir/file2 in branch'
652
$ bzr branch -q . -r 1 ../branch
676
$ bzr commit -m 'Add dir/file2 in branch'
678
$ bzr branch . -r 1 ../branch
654
$ bzr rm -q dir/file --force
656
$ bzr commit -q -m 'Remove dir/file'
680
$ bzr rm dir/file --force
682
$ bzr commit -m 'Remove dir/file'
657
684
$ bzr merge ../trunk
665
692
def test_keep_them_all(self):
666
693
self.run_script("""
667
694
$ bzr resolve dir
668
2>2 conflict(s) resolved, 0 remaining
669
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
695
$ bzr commit --strict -m 'No more conflicts nor unknown files'
672
698
def test_adopt_child(self):
673
699
self.run_script("""
674
$ bzr mv -q dir/file2 file2
675
$ bzr rm -q dir --force
700
$ bzr mv dir/file2 file2
676
702
$ bzr resolve dir
677
2>2 conflict(s) resolved, 0 remaining
678
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
703
$ bzr commit --strict -m 'No more conflicts nor unknown files'
681
706
def test_kill_them_all(self):
682
707
self.run_script("""
683
$ bzr rm -q dir --force
684
709
$ bzr resolve dir
685
2>2 conflict(s) resolved, 0 remaining
686
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
710
$ bzr commit --strict -m 'No more conflicts nor unknown files'
689
713
def test_resolve_taking_this(self):
690
714
self.run_script("""
691
715
$ bzr resolve --take-this dir
693
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
716
$ bzr commit --strict -m 'No more conflicts nor unknown files'
696
719
def test_resolve_taking_other(self):
697
720
self.run_script("""
698
721
$ bzr resolve --take-other dir
700
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
722
$ bzr commit --strict -m 'No more conflicts nor unknown files'
711
732
$ echo 'trunk content' >dir/file
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
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
719
742
$ echo 'branch content' >dir/file2
720
$ bzr add -q dir/file2
721
$ bzr commit -q -m 'Add dir/file2 in branch'
744
$ bzr commit -m 'Add dir/file2 in branch'
722
746
$ bzr merge ../trunk
724
748
2>Conflict: can't delete dir because it is not empty. Not deleting.
729
753
def test_keep_them_all(self):
730
754
self.run_script("""
731
755
$ bzr resolve dir
732
2>2 conflict(s) resolved, 0 remaining
733
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
756
$ bzr commit --strict -m 'No more conflicts nor unknown files'
736
759
def test_adopt_child(self):
737
760
self.run_script("""
738
$ bzr mv -q dir/file2 file2
739
$ bzr rm -q dir --force
761
$ bzr mv dir/file2 file2
740
763
$ bzr resolve dir
741
2>2 conflict(s) resolved, 0 remaining
742
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
764
$ bzr commit --strict -m 'No more conflicts nor unknown files'
745
767
def test_kill_them_all(self):
746
768
self.run_script("""
747
$ bzr rm -q dir --force
748
770
$ bzr resolve dir
749
2>2 conflict(s) resolved, 0 remaining
750
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
771
$ bzr commit --strict -m 'No more conflicts nor unknown files'
753
774
def test_resolve_taking_this(self):
754
775
self.run_script("""
755
776
$ bzr resolve --take-this dir
756
2>2 conflict(s) resolved, 0 remaining
757
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
777
$ bzr commit --strict -m 'No more conflicts nor unknown files'
760
780
def test_resolve_taking_other(self):
761
781
self.run_script("""
762
782
$ bzr resolve --take-other dir
765
2>2 conflict(s) resolved, 0 remaining
766
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
783
$ bzr commit --strict -m 'No more conflicts nor unknown files'
770
787
class TestResolveParentLoop(TestParametrizedResolveConflicts):
772
_conflict_type = conflicts.ParentLoop
789
_conflict_type = conflicts.ParentLoop,
774
791
_this_args = None
775
792
_other_args = None
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(
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'
784
802
# Dirs moved into each other
785
803
(dict(_base_actions='create_dir1_dir2'),
786
804
('dir1_into_dir2',
797
815
('dir3_into_dir2',
798
816
dict(actions='move_dir3_into_dir2', check='dir3_4_moved',
799
817
dir_id='dir3-id', target_id='dir2-id', xfail=True))),
819
return mirror_scenarios(base_scenarios)
802
821
def do_create_dir1_dir2(self):
803
822
return [('add', ('dir1', 'dir1-id', 'directory', '')),
870
$ bzr commit -m 'Create trunk' -q
887
$ bzr commit -m 'Create trunk'
871
888
$ echo "Boing" >foo/bar
873
$ bzr commit -q -m 'Add foo/bar'
874
$ bzr branch -q . -r 1 ../branch
890
$ bzr commit -m 'Add foo/bar'
892
$ bzr branch . -r 1 ../branch
877
895
$ echo "Boo!" >foo
878
$ bzr commit -q -m 'foo is now a file'
896
$ bzr commit -m 'foo is now a file'
879
898
$ bzr merge ../trunk
881
900
2>RK foo => foo.new/
888
907
def test_take_this(self):
889
908
self.run_script("""
890
$ bzr rm -q foo.new --force
909
$ bzr rm foo.new --force
891
910
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
892
911
# aside ? -- vila 090916
894
913
$ bzr resolve foo.new
895
2>1 conflict(s) resolved, 0 remaining
896
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
914
$ bzr commit --strict -m 'No more conflicts nor unknown files'
899
917
def test_take_other(self):
900
918
self.run_script("""
901
$ bzr rm -q foo --force
902
$ bzr mv -q foo.new foo
903
921
$ bzr resolve foo
904
2>1 conflict(s) resolved, 0 remaining
905
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
922
$ bzr commit --strict -m 'No more conflicts nor unknown files'
908
925
def test_resolve_taking_this(self):
909
926
self.run_script("""
910
927
$ bzr resolve --take-this foo.new
912
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
928
$ bzr commit --strict -m 'No more conflicts nor unknown files'
915
931
def test_resolve_taking_other(self):
916
932
self.run_script("""
917
933
$ bzr resolve --take-other foo.new
919
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
934
$ bzr commit --strict -m 'No more conflicts nor unknown files'
929
944
self.run_script("""
935
$ bzr commit -m 'Create trunk' -q
948
$ bzr commit -m 'Create trunk'
937
950
$ echo "Boo!" >foo
938
$ bzr commit -m 'foo is now a file' -q
939
$ bzr branch -q . -r 1 ../branch -q
951
$ bzr commit -m 'foo is now a file'
953
$ bzr branch . -r 1 ../branch
941
955
$ echo "Boing" >foo/bar
942
$ bzr add -q foo/bar -q
943
$ bzr commit -m 'Add foo/bar' -q
957
$ bzr commit -m 'Add foo/bar'
944
959
$ bzr merge ../trunk
945
960
2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]