Skip to content

Commit a8e0f50

Browse files
harry-hovgitster
authored andcommitted
t6300: unify %(trailers) and %(contents:trailers) tests
Currently, there are different tests for testing %(trailers) and %(contents:trailers) causing redundant copy. Its time to get rid of duplicate code. Mentored-by: Christian Couder <[email protected]> Mentored-by: Heba Waly <[email protected]> Signed-off-by: Hariom Verma <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47ae905 commit a8e0f50

File tree

1 file changed

+14
-42
lines changed

1 file changed

+14
-42
lines changed

t/t6300-for-each-ref.sh

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -738,61 +738,40 @@ test_expect_success 'set up trailers for next test' '
738738
'
739739

740740
test_expect_success '%(trailers:unfold) unfolds trailers' '
741-
git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual &&
742741
{
743742
unfold <trailers
744743
echo
745744
} >expect &&
745+
git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual &&
746+
test_cmp expect actual &&
747+
git for-each-ref --format="%(contents:trailers:unfold)" refs/heads/master >actual &&
746748
test_cmp expect actual
747749
'
748750

749751
test_expect_success '%(trailers:only) shows only "key: value" trailers' '
750-
git for-each-ref --format="%(trailers:only)" refs/heads/master >actual &&
751752
{
752753
grep -v patch.description <trailers &&
753754
echo
754755
} >expect &&
756+
git for-each-ref --format="%(trailers:only)" refs/heads/master >actual &&
757+
test_cmp expect actual &&
758+
git for-each-ref --format="%(contents:trailers:only)" refs/heads/master >actual &&
755759
test_cmp expect actual
756760
'
757761

758762
test_expect_success '%(trailers:only) and %(trailers:unfold) work together' '
759-
git for-each-ref --format="%(trailers:only,unfold)" refs/heads/master >actual &&
760-
git for-each-ref --format="%(trailers:unfold,only)" refs/heads/master >reverse &&
761-
test_cmp actual reverse &&
762763
{
763764
grep -v patch.description <trailers | unfold &&
764765
echo
765766
} >expect &&
766-
test_cmp expect actual
767-
'
768-
769-
test_expect_success '%(contents:trailers:unfold) unfolds trailers' '
770-
git for-each-ref --format="%(contents:trailers:unfold)" refs/heads/master >actual &&
771-
{
772-
unfold <trailers
773-
echo
774-
} >expect &&
775-
test_cmp expect actual
776-
'
777-
778-
test_expect_success '%(contents:trailers:only) shows only "key: value" trailers' '
779-
git for-each-ref --format="%(contents:trailers:only)" refs/heads/master >actual &&
780-
{
781-
grep -v patch.description <trailers &&
782-
echo
783-
} >expect &&
784-
test_cmp expect actual
785-
'
786-
787-
test_expect_success '%(contents:trailers:only) and %(contents:trailers:unfold) work together' '
767+
git for-each-ref --format="%(trailers:only,unfold)" refs/heads/master >actual &&
768+
test_cmp expect actual &&
769+
git for-each-ref --format="%(trailers:unfold,only)" refs/heads/master >actual &&
770+
test_cmp actual actual &&
788771
git for-each-ref --format="%(contents:trailers:only,unfold)" refs/heads/master >actual &&
789-
git for-each-ref --format="%(contents:trailers:unfold,only)" refs/heads/master >reverse &&
790-
test_cmp actual reverse &&
791-
{
792-
grep -v patch.description <trailers | unfold &&
793-
echo
794-
} >expect &&
795-
test_cmp expect actual
772+
test_cmp expect actual &&
773+
git for-each-ref --format="%(contents:trailers:unfold,only)" refs/heads/master >actual &&
774+
test_cmp actual actual
796775
'
797776

798777
test_expect_success '%(trailers) rejects unknown trailers arguments' '
@@ -801,14 +780,7 @@ test_expect_success '%(trailers) rejects unknown trailers arguments' '
801780
fatal: unknown %(trailers) argument: unsupported
802781
EOF
803782
test_must_fail git for-each-ref --format="%(trailers:unsupported)" 2>actual &&
804-
test_i18ncmp expect actual
805-
'
806-
807-
test_expect_success '%(contents:trailers) rejects unknown trailers arguments' '
808-
# error message cannot be checked under i18n
809-
cat >expect <<-EOF &&
810-
fatal: unknown %(trailers) argument: unsupported
811-
EOF
783+
test_i18ncmp expect actual &&
812784
test_must_fail git for-each-ref --format="%(contents:trailers:unsupported)" 2>actual &&
813785
test_i18ncmp expect actual
814786
'

0 commit comments

Comments
 (0)