From: Will Palmer Date: Sun, 11 Jul 2010 13:16:54 GMT Subject: [PATCHv2 1/2] add basic tests for merge-tree Message-ID: <1278854215-9022-2-git-send-email-wmpalmer@gmail.com> In-Reply-To: <1278854215-9022-1-git-send-email-wmpalmer@gmail.com> merge-tree had no test cases, so here we add some very basic tests for it, including some known-breakages. Signed-off-by: Will Palmer --- t/t4300-merge-tree.sh | 277 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 277 insertions(+), 0 deletions(-) create mode 100755 t/t4300-merge-tree.sh diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh new file mode 100755 index 0000000..b2ae3a1 --- /dev/null +++ b/t/t4300-merge-tree.sh @@ -0,0 +1,277 @@ +#!/bin/sh +# +# Copyright (c) 2010 Will Palmer +# + +test_description='git merge-tree' +. ./test-lib.sh + +test_expect_success setup ' + test_commit "initial" "initial-file" "initial" +' + +test_expect_'file add A, !B' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_failure 'file add !A, B' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_success 'file add A, B (same)' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_success 'file add A, B (different)' ' + cat >expected <>>>>>> .their +EXPECTED + + git reset --hard initial + test_commit "add-a-b-diff-A" "ONE" "AAA" + + git reset --hard initial + test_commit "add-a-b-diff-B" "ONE" "BBB" + + git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual && + test_cmp expected actual +' + +test_expect_success 'file change A, !B' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_success 'file change !A, B' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_success 'file change A, B (same)' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_success 'file change A, B (different)' ' + cat >expected <>>>>>> .their +EXPECTED + + git reset --hard initial + test_commit "change-a-b-diff-A" "initial-file" "AAA" + + git reset --hard initial + test_commit "change-a-b-diff-B" "initial-file" "BBB" + + git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual && + test_cmp expected actual +' + +test_expect_success 'file change A, B (mixed)' ' + cat >expected <>>>>>> .their + AAA + AAA + AAA +EXPECTED + + git reset --hard initial + test_commit "change-a-b-mix-base" "ONE" " +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA" + + test_commit "change-a-b-mix-A" "ONE" \ + "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/BBB/;}" actual && + test_cmp expected actual +' + +test_expect_success 'file remove A, !B' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_failure 'file remove !A, B' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_failure 'file change A, remove B' ' + cat >expected <actual && + test_cmp expected actual +' + +test_expect_success 'file remove A, change B' ' + cat >expected <actual && + test_cmp expected actual +' + +test_done -- 1.7.1.703.g42c01