[PATCHv2 5/5] t6300 (for-each-ref): modernize style

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- Guard setup with test_expect_success
- Unwound one loop to stay within the test_expect_success guard

Signed-off-by: Tom Grennan <tmgrennan@xxxxxxxxx>
---
 t/t6300-for-each-ref.sh |  186 +++++++++++++++++++++++------------------------
 1 files changed, 92 insertions(+), 94 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
-'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' '
+	'"
+	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
+	"'
 	(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
-'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' '
+	'"
+	cat >expected <<-EOF
+		'refs/heads/master' '2006-07-03' '2006-07-03'
+		'refs/tags/testtag' '2006-07-03'
+	EOF
+	"'
 	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
-'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 &&
+	'"
+	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
+	"'
+	(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
-'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' '
+	'"
+	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
+	"'
 	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
-'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' '
+	'"
+	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
+	"'
 	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
-refs/heads/master
-refs/remotes/origin/master
-refs/tags/testtag
-EOF
-
 test_expect_success 'Verify ascending sort' '
+	cat >expected <<-EOF
+		refs/heads/master
+		refs/remotes/origin/master
+		refs/tags/testtag
+	EOF
 	git for-each-ref --format="%(refname)" --sort=refname >actual &&
 	test_cmp expected actual
 '
 
-
-cat >expected <<\EOF
-refs/tags/testtag
-refs/remotes/origin/master
-refs/heads/master
-EOF
-
 test_expect_success 'Verify descending sort' '
+	cat >expected <<-EOF
+		refs/tags/testtag
+		refs/remotes/origin/master
+		refs/heads/master
+	EOF
 	git for-each-ref --format="%(refname)" --sort=-refname >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-'refs/heads/master'
-'refs/remotes/origin/master'
-'refs/tags/testtag'
-EOF
-
 test_expect_success 'Quoting style: shell' '
+	'"
+	cat >expected <<-EOF
+		'refs/heads/master'
+		'refs/remotes/origin/master'
+		'refs/tags/testtag'
+	EOF
+	"'
 	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
-"refs/heads/master"
-"refs/remotes/origin/master"
-"refs/tags/testtag"
-EOF
-
 test_expect_success 'Quoting style: tcl' '
+	cat >expected <<-EOF
+		"refs/heads/master"
+		"refs/remotes/origin/master"
+		"refs/tags/testtag"
+	EOF
 	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
-master
-testtag
-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
 	(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' '
+	cat >expected <<-EOF
+		origin/master
+	EOF
 	git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
 	test_cmp expected actual
 '
 
-cat >expected <<EOF
-67a36f1
-EOF
-
 test_expect_success 'Check short objectname format' '
+	cat >expected <<-EOF
+		67a36f1
+	EOF
 	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
-heads/master
-tags/master
-EOF
-
 test_expect_success 'Check ambiguous head and tag refs (strict)' '
+	cat >expected <<-EOF
+		heads/master
+		tags/master
+	EOF
 	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
-heads/master
-master
-EOF
-
 test_expect_success 'Check ambiguous head and tag refs (loose)' '
+	cat >expected <<-EOF
+		heads/master
+		master
+	EOF
 	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
-heads/ambiguous
-ambiguous
-EOF
-
 test_expect_success 'Check ambiguous head and tag refs II (loose)' '
+	cat >expected <<-EOF
+		heads/ambiguous
+		ambiguous
+	EOF
 	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
@@ -417,9 +415,9 @@ test_expect_success GPG 'create signed tags' '
 	git tag -s -m "" signed-empty &&
 	git tag -s -m "subject line" signed-short &&
 	cat >msg <<-\EOF &&
-	subject line
+		subject line
 
-	body contents
+		body contents
 	EOF
 	git tag -s -F msg signed-long
 '
-- 
1.7.8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]