]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t6300: use test_atom for some un-modern tests
authorJeff King <peff@peff.net>
Sun, 24 Jan 2016 23:08:18 +0000 (18:08 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Jan 2016 20:33:45 +0000 (12:33 -0800)
Because this script has to test so many formatters, we have
the nice "test_atom" helper, but we don't use it
consistently. Let's do so. This is shorter, gets rid of some
tests that have their "expected" setup outside of a
test_expect_success block, and lets us organize the changes
better (e.g., putting "refname:short" near "refname").

We also expand the "%(push)" tests a little to match the
"%(upstream)" ones.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t6300-for-each-ref.sh

index 03873b09d1a4480549e1b8ab92fc3780fb874d89..859b2374269e630db3653fc153267bb9382fe748 100755 (executable)
@@ -49,11 +49,15 @@ test_atom() {
 }
 
 test_atom head refname refs/heads/master
+test_atom head refname:short master
 test_atom head upstream refs/remotes/origin/master
+test_atom head upstream:short origin/master
 test_atom head push refs/remotes/myfork/master
+test_atom head push:short myfork/master
 test_atom head objecttype commit
 test_atom head objectsize 171
 test_atom head objectname $(git rev-parse refs/heads/master)
+test_atom head objectname:short $(git rev-parse --short refs/heads/master)
 test_atom head tree $(git rev-parse refs/heads/master^{tree})
 test_atom head parent ''
 test_atom head numparent 0
@@ -86,11 +90,13 @@ test_atom head contents 'Initial
 test_atom head HEAD '*'
 
 test_atom tag refname refs/tags/testtag
+test_atom tag refname:short testtag
 test_atom tag upstream ''
 test_atom tag push ''
 test_atom tag objecttype tag
 test_atom tag objectsize 154
 test_atom tag objectname $(git rev-parse refs/tags/testtag)
+test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
 test_atom tag tree ''
 test_atom tag parent ''
 test_atom tag numparent ''
@@ -338,47 +344,14 @@ for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
        "
 done
 
-cat >expected <<\EOF
-master
-testtag
-EOF
-
-test_expect_success 'Check short refname format' '
-       (git for-each-ref --format="%(refname:short)" refs/heads &&
-       git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
-       test_cmp expected actual
-'
-
-cat >expected <<EOF
-origin/master
-EOF
-
-test_expect_success 'Check short upstream format' '
-       git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
-       test_cmp expected actual
-'
-
 test_expect_success 'setup for upstream:track[short]' '
        test_commit two
 '
 
-cat >expected <<EOF
-[ahead 1]
-EOF
-
-test_expect_success 'Check upstream:track format' '
-       git for-each-ref --format="%(upstream:track)" refs/heads >actual &&
-       test_cmp expected actual
-'
-
-cat >expected <<EOF
->
-EOF
-
-test_expect_success 'Check upstream:trackshort format' '
-       git for-each-ref --format="%(upstream:trackshort)" refs/heads >actual &&
-       test_cmp expected actual
-'
+test_atom head upstream:track '[ahead 1]'
+test_atom head upstream:trackshort '>'
+test_atom head push:track '[ahead 1]'
+test_atom head push:trackshort '>'
 
 test_expect_success 'Check that :track[short] cannot be used with other atoms' '
        test_must_fail git for-each-ref --format="%(refname:track)" 2>/dev/null &&
@@ -398,21 +371,6 @@ test_expect_success 'Check that :track[short] works when upstream is invalid' '
        test_cmp expected actual
 '
 
-test_expect_success '%(push) supports tracking specifiers, too' '
-       echo "[ahead 1]" >expected &&
-       git for-each-ref --format="%(push:track)" refs/heads >actual &&
-       test_cmp expected actual
-'
-
-cat >expected <<EOF
-$(git rev-parse --short HEAD)
-EOF
-
-test_expect_success 'Check short objectname format' '
-       git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
-       test_cmp expected actual
-'
-
 test_expect_success 'Check for invalid refname format' '
        test_must_fail git for-each-ref --format="%(refname:INVALID)"
 '