[PATCHv2-w 105/105] t6300 (for-each-ref): modernize style
- Guard setup with test_expect_success
- Unwound one loop to stay within the test_expect_success guard
Signed-off-by: Tom Grennan <tmgrennan@gmail.com>
---
t/t6300-for-each-ref.sh | 118 +++++++++++++++++++++++------------------------
1 files changed, 58 insertions(+), 60 deletions(-)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 1721784..ebba7d1 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -138,12 +138,13 @@ test_expect_success 'Check invalid format specifiers are errors' '
test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
'
-cat >expected <<\EOF
+test_expect_success 'Check unformatted date fields output' '
+ '"
+ cat >expected <<-EOF &&
'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
EOF
-
-test_expect_success 'Check unformatted date fields output' '
+ "'
(git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
test_cmp expected actual
@@ -171,84 +172,85 @@ test_expect_success 'Check format "relative" date fields output' '
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
'
-cat >expected <<\EOF
+test_expect_success 'Check format "short" date fields output' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master' '2006-07-03' '2006-07-03'
'refs/tags/testtag' '2006-07-03'
EOF
-
-test_expect_success 'Check format "short" date fields output' '
+ "'
f=short &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check format "local" date fields output' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
EOF
-
-test_expect_success 'Check format "local" date fields output' '
- f=local &&
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
+ "'
+ (git for-each-ref --shell --format="%(refname) %(committerdate:local) %(authordate:local)" refs/heads &&
+ git for-each-ref --shell --format="%(refname) %(taggerdate:local)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check format "iso8601" date fields output' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
EOF
-
-test_expect_success 'Check format "iso8601" date fields output' '
+ "'
f=iso8601 &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check format "rfc2822" date fields output' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
EOF
-
-test_expect_success 'Check format "rfc2822" date fields output' '
+ "'
f=rfc2822 &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Verify ascending sort' '
+ cat >expected <<-EOF
refs/heads/master
refs/remotes/origin/master
refs/tags/testtag
EOF
-
-test_expect_success 'Verify ascending sort' '
git for-each-ref --format="%(refname)" --sort=refname >actual &&
test_cmp expected actual
'
-
-cat >expected <<\EOF
+test_expect_success 'Verify descending sort' '
+ cat >expected <<-EOF
refs/tags/testtag
refs/remotes/origin/master
refs/heads/master
EOF
-
-test_expect_success 'Verify descending sort' '
git for-each-ref --format="%(refname)" --sort=-refname >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Quoting style: shell' '
+ '"
+ cat >expected <<-EOF
'refs/heads/master'
'refs/remotes/origin/master'
'refs/tags/testtag'
EOF
-
-test_expect_success 'Quoting style: shell' '
+ "'
git for-each-ref --shell --format="%(refname)" >actual &&
test_cmp expected actual
'
@@ -263,52 +265,51 @@ test_expect_success 'Quoting style: python' '
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Quoting style: tcl' '
+ cat >expected <<-EOF
"refs/heads/master"
"refs/remotes/origin/master"
"refs/tags/testtag"
EOF
-
-test_expect_success 'Quoting style: tcl' '
git for-each-ref --tcl --format="%(refname)" >actual &&
test_cmp expected actual
'
-for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
- test_expect_success "more than one quoting style: $i" "
- git for-each-ref $i 2>&1 | (read line &&
- case \$line in
- \"error: more than one quoting style\"*) : happy;;
- *) false
- esac)
- "
-done
-
-cat >expected <<\EOF
+test_expect_success 'more than one quoting styles' '
+ cat >expected <<-EOF
+ error: more than one quoting style?
+ EOF
+ git for-each-ref --perl --shell 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref -s --python 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref --python --tcl 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual &&
+ git for-each-ref --tcl --perl 2>&1 | head -n 1 >actual &&
+ test_cmp expected actual
+'
+test_expect_success 'Check short refname format' '
+ 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
+test_expect_success 'Check short upstream format' '
+ 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
'
-cat >expected <<EOF
+test_expect_success 'Check short objectname format' '
+ cat >expected <<-EOF
67a36f1
EOF
-
-test_expect_success 'Check short objectname format' '
git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
test_cmp expected actual
'
@@ -317,12 +318,11 @@ test_expect_success 'Check for invalid refname format' '
test_must_fail git for-each-ref --format="%(refname:INVALID)"
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs (strict)' '
+ cat >expected <<-EOF
heads/master
tags/master
EOF
-
-test_expect_success 'Check ambiguous head and tag refs (strict)' '
git config --bool core.warnambiguousrefs true &&
git checkout -b newtag &&
echo "Using $datestamp" > one &&
@@ -334,23 +334,21 @@ test_expect_success 'Check ambiguous head and tag refs (strict)' '
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs (loose)' '
+ cat >expected <<-EOF
heads/master
master
EOF
-
-test_expect_success 'Check ambiguous head and tag refs (loose)' '
git config --bool core.warnambiguousrefs false &&
git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
test_cmp expected actual
'
-cat >expected <<\EOF
+test_expect_success 'Check ambiguous head and tag refs II (loose)' '
+ cat >expected <<-EOF
heads/ambiguous
ambiguous
EOF
-
-test_expect_success 'Check ambiguous head and tag refs II (loose)' '
git checkout master &&
git tag ambiguous testtag^0 &&
git branch ambiguous testtag^0 &&
@@ -369,7 +367,7 @@ test_expect_success 'an unusual tag with an incomplete line' '
'
test_expect_success 'create tag with subject and body content' '
- cat >>msg <<-\EOF &&
+ cat >msg <<-\EOF &&
the subject line
first body line
--
1.7.8