Skip to content

Commit 1d094db

Browse files
peffgitster
authored andcommitted
t6300: use test_atom for some un-modern tests
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7548842 commit 1d094db

File tree

1 file changed

+10
-52
lines changed

1 file changed

+10
-52
lines changed

t/t6300-for-each-ref.sh

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ test_atom() {
4949
}
5050

5151
test_atom head refname refs/heads/master
52+
test_atom head refname:short master
5253
test_atom head upstream refs/remotes/origin/master
54+
test_atom head upstream:short origin/master
5355
test_atom head push refs/remotes/myfork/master
56+
test_atom head push:short myfork/master
5457
test_atom head objecttype commit
5558
test_atom head objectsize 171
5659
test_atom head objectname $(git rev-parse refs/heads/master)
60+
test_atom head objectname:short $(git rev-parse --short refs/heads/master)
5761
test_atom head tree $(git rev-parse refs/heads/master^{tree})
5862
test_atom head parent ''
5963
test_atom head numparent 0
@@ -86,11 +90,13 @@ test_atom head contents 'Initial
8690
test_atom head HEAD '*'
8791

8892
test_atom tag refname refs/tags/testtag
93+
test_atom tag refname:short testtag
8994
test_atom tag upstream ''
9095
test_atom tag push ''
9196
test_atom tag objecttype tag
9297
test_atom tag objectsize 154
9398
test_atom tag objectname $(git rev-parse refs/tags/testtag)
99+
test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
94100
test_atom tag tree ''
95101
test_atom tag parent ''
96102
test_atom tag numparent ''
@@ -338,47 +344,14 @@ for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
338344
"
339345
done
340346

341-
cat >expected <<\EOF
342-
master
343-
testtag
344-
EOF
345-
346-
test_expect_success 'Check short refname format' '
347-
(git for-each-ref --format="%(refname:short)" refs/heads &&
348-
git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
349-
test_cmp expected actual
350-
'
351-
352-
cat >expected <<EOF
353-
origin/master
354-
EOF
355-
356-
test_expect_success 'Check short upstream format' '
357-
git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
358-
test_cmp expected actual
359-
'
360-
361347
test_expect_success 'setup for upstream:track[short]' '
362348
test_commit two
363349
'
364350

365-
cat >expected <<EOF
366-
[ahead 1]
367-
EOF
368-
369-
test_expect_success 'Check upstream:track format' '
370-
git for-each-ref --format="%(upstream:track)" refs/heads >actual &&
371-
test_cmp expected actual
372-
'
373-
374-
cat >expected <<EOF
375-
>
376-
EOF
377-
378-
test_expect_success 'Check upstream:trackshort format' '
379-
git for-each-ref --format="%(upstream:trackshort)" refs/heads >actual &&
380-
test_cmp expected actual
381-
'
351+
test_atom head upstream:track '[ahead 1]'
352+
test_atom head upstream:trackshort '>'
353+
test_atom head push:track '[ahead 1]'
354+
test_atom head push:trackshort '>'
382355

383356
test_expect_success 'Check that :track[short] cannot be used with other atoms' '
384357
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' '
398371
test_cmp expected actual
399372
'
400373

401-
test_expect_success '%(push) supports tracking specifiers, too' '
402-
echo "[ahead 1]" >expected &&
403-
git for-each-ref --format="%(push:track)" refs/heads >actual &&
404-
test_cmp expected actual
405-
'
406-
407-
cat >expected <<EOF
408-
$(git rev-parse --short HEAD)
409-
EOF
410-
411-
test_expect_success 'Check short objectname format' '
412-
git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
413-
test_cmp expected actual
414-
'
415-
416374
test_expect_success 'Check for invalid refname format' '
417375
test_must_fail git for-each-ref --format="%(refname:INVALID)"
418376
'

0 commit comments

Comments
 (0)