Skip to content

Commit ab53920

Browse files
committed
Merge branch 'jn/subtree-test-fixes'
Test fix. * jn/subtree-test-fixes: subtree test: simplify preparation of expected results subtree test: add missing && to &&-chain
2 parents dd4ab3e + 6a8ad88 commit ab53920

File tree

1 file changed

+31
-90
lines changed

1 file changed

+31
-90
lines changed

contrib/subtree/t/t7900-subtree.sh

Lines changed: 31 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -540,26 +540,10 @@ test_expect_success 'make sure exactly the right set of files ends up in the sub
540540
git fetch .. subproj-br &&
541541
git merge FETCH_HEAD &&
542542
543-
chks="sub1
544-
sub2
545-
sub3
546-
sub4" &&
547-
chks_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
548-
$chks
549-
TXT
550-
) &&
551-
chkms="main-sub1
552-
main-sub2
553-
main-sub3
554-
main-sub4" &&
555-
chkms_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
556-
$chkms
557-
TXT
558-
) &&
559-
560-
subfiles=$(git ls-files) &&
561-
check_equal "$subfiles" "$chkms
562-
$chks"
543+
test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 \
544+
sub1 sub2 sub3 sub4 >expect &&
545+
git ls-files >actual &&
546+
test_cmp expect actual
563547
)
564548
'
565549

@@ -606,25 +590,11 @@ test_expect_success 'make sure the subproj *only* contains commits that affect t
606590
git fetch .. subproj-br &&
607591
git merge FETCH_HEAD &&
608592
609-
chks="sub1
610-
sub2
611-
sub3
612-
sub4" &&
613-
chks_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
614-
$chks
615-
TXT
616-
) &&
617-
chkms="main-sub1
618-
main-sub2
619-
main-sub3
620-
main-sub4" &&
621-
chkms_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
622-
$chkms
623-
TXT
624-
) &&
625-
allchanges=$(git log --name-only --pretty=format:"" | sort | sed "/^$/d") &&
626-
check_equal "$allchanges" "$chkms
627-
$chks"
593+
test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 \
594+
sub1 sub2 sub3 sub4 >expect &&
595+
git log --name-only --pretty=format:"" >log &&
596+
sort <log | sed "/^\$/ d" >actual &&
597+
test_cmp expect actual
628598
)
629599
'
630600

@@ -675,29 +645,16 @@ test_expect_success 'make sure exactly the right set of files ends up in the mai
675645
cd "$subtree_test_count" &&
676646
git subtree pull --prefix="sub dir" ./"sub proj" master &&
677647
678-
chkm="main1
679-
main2" &&
680-
chks="sub1
681-
sub2
682-
sub3
683-
sub4" &&
684-
chks_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
685-
$chks
686-
TXT
687-
) &&
688-
chkms="main-sub1
689-
main-sub2
690-
main-sub3
691-
main-sub4" &&
692-
chkms_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
693-
$chkms
694-
TXT
695-
) &&
696-
mainfiles=$(git ls-files) &&
697-
check_equal "$mainfiles" "$chkm
698-
$chkms_sub
699-
$chks_sub"
700-
)
648+
test_write_lines main1 main2 >chkm &&
649+
test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 >chkms &&
650+
sed "s,^,sub dir/," chkms >chkms_sub &&
651+
test_write_lines sub1 sub2 sub3 sub4 >chks &&
652+
sed "s,^,sub dir/," chks >chks_sub &&
653+
654+
cat chkm chkms_sub chks_sub >expect &&
655+
git ls-files >actual &&
656+
test_cmp expect actual
657+
)
701658
'
702659

703660
next_test
@@ -708,7 +665,7 @@ test_expect_success 'make sure each filename changed exactly once in the entire
708665
test_create_commit "$subtree_test_count/sub proj" sub1 &&
709666
(
710667
cd "$subtree_test_count" &&
711-
git config log.date relative
668+
git config log.date relative &&
712669
git fetch ./"sub proj" master &&
713670
git subtree add --prefix="sub dir" FETCH_HEAD
714671
) &&
@@ -748,37 +705,21 @@ test_expect_success 'make sure each filename changed exactly once in the entire
748705
cd "$subtree_test_count" &&
749706
git subtree pull --prefix="sub dir" ./"sub proj" master &&
750707
751-
chkm="main1
752-
main2" &&
753-
chks="sub1
754-
sub2
755-
sub3
756-
sub4" &&
757-
chks_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
758-
$chks
759-
TXT
760-
) &&
761-
chkms="main-sub1
762-
main-sub2
763-
main-sub3
764-
main-sub4" &&
765-
chkms_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
766-
$chkms
767-
TXT
768-
) &&
708+
test_write_lines main1 main2 >chkm &&
709+
test_write_lines sub1 sub2 sub3 sub4 >chks &&
710+
test_write_lines main-sub1 main-sub2 main-sub3 main-sub4 >chkms &&
711+
sed "s,^,sub dir/," chkms >chkms_sub &&
769712
770713
# main-sub?? and /"sub dir"/main-sub?? both change, because those are the
771714
# changes that were split into their own history. And "sub dir"/sub?? never
772715
# change, since they were *only* changed in the subtree branch.
773-
allchanges=$(git log --name-only --pretty=format:"" | sort | sed "/^$/d") &&
774-
expected=''"$(cat <<TXT | sort
775-
$chkms
776-
$chkm
777-
$chks
778-
$chkms_sub
779-
TXT
780-
)"'' &&
781-
check_equal "$allchanges" "$expected"
716+
git log --name-only --pretty=format:"" >log &&
717+
sort <log >sorted-log &&
718+
sed "/^$/ d" sorted-log >actual &&
719+
720+
cat chkms chkm chks chkms_sub >expect-unsorted &&
721+
sort expect-unsorted >expect &&
722+
test_cmp expect actual
782723
)
783724
'
784725

0 commit comments

Comments
 (0)