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 <chriscool@tuxfamily.org> Mentored-by: Heba Waly <heba.waly@gmail.com> Signed-off-by: Hariom Verma <hariom18599@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Hariom Verma committed
Aug 21, 2020 at 10:11 UTC
a8e0f50edc8c4203834587541eed842497e83287
1 file changed
+14
-42
t/t6300-for-each-ref.sh
+14
-42
@@ -738,61 +738,40 @@ test_expect_success 'set up trailers for next test' '
738
'
739
740
test_expect_success '%(trailers:unfold) unfolds trailers' '
741
- git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual &&
741
{
742
unfold <trailers
743
echo
744
} >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 &&
748
test_cmp expect actual
749
'
750
751
test_expect_success '%(trailers:only) shows only "key: value" trailers' '
750
- git for-each-ref --format="%(trailers:only)" refs/heads/master >actual &&
752
{
753
grep -v patch.description <trailers &&
754
echo
755
} >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 &&
759
test_cmp expect actual
760
'
761
762
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 &&
763
{
764
grep -v patch.description <trailers | unfold &&
765
echo
766
} >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 &&
771
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
775
'
776
777
test_expect_success '%(trailers) rejects unknown trailers arguments' '
@@ -801,14 +780,7 @@ test_expect_success '%(trailers) rejects unknown trailers arguments' '
780
fatal: unknown %(trailers) argument: unsupported
781
EOF
782
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 &&
784
test_must_fail git for-each-ref --format="%(contents:trailers:unsupported)" 2>actual &&
785
test_i18ncmp expect actual
786
'