Thread (26 messages) flat view 26 messages, 5 authors, 2016-06-15
STALE3717d

Revision v2 of 4 in this series.

Revisions (4)
  1. v1 [diff vs current]
  2. v2 current
  3. v3 [diff vs current]
  4. v4 [diff vs current]

[PATCH 3/6] t5516 (fetch-push): introduce mk_test_with_name()

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:56:27
Subsystem: the rest · Maintainer: Linus Torvalds

mk_test() creates a repository with the constant name "testrepo", and
this may be limiting for tests that need to create more than one
repository for testing.  To fix this, create a new mk_test_with_name()
which accepts the repository name as $1.  Reimplement mk_test() as a
special case of this function, making sure that no tests need to be
rewritten.  Do the same thing for check_push_result().

Signed-off-by: Ramkumar Ramachandra <redacted>
---
 t/t5516-fetch-push.sh | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index bfeec60..a546c2c 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -7,27 +7,32 @@ test_description='fetching and pushing'
 D=`pwd`
 
 mk_empty () {
-	rm -fr testrepo &&
-	mkdir testrepo &&
+	repo_name="$1"
+	test -z "$repo_name" && repo_name=testrepo
+	rm -fr $repo_name &&
+	mkdir $repo_name &&
 	(
-		cd testrepo &&
+		cd $repo_name &&
 		git init &&
 		git config receive.denyCurrentBranch warn &&
 		mv .git/hooks .git/hooks-disabled
 	)
 }
 
-mk_test () {
-	mk_empty &&
+mk_test_with_name () {
+	repo_name="$1"
+	shift
+
+	mk_empty $repo_name &&
 	(
 		for ref in "$@"
 		do
-			git push testrepo $the_first_commit:refs/$ref || {
+			git push $repo_name $the_first_commit:refs/$ref || {
 				echo "Oops, push refs/$ref failure"
 				exit 1
 			}
 		done &&
-		cd testrepo &&
+		cd $repo_name &&
 		for ref in "$@"
 		do
 			r=$(git show-ref -s --verify refs/$ref) &&
@@ -40,6 +45,10 @@ mk_test () {
 	)
 }
 
+mk_test () {
+	mk_test_with_name testrepo "$@"
+}
+
 mk_test_with_hooks() {
 	mk_test "$@" &&
 	(
@@ -79,9 +88,12 @@ mk_child() {
 	git clone testrepo "$1"
 }
 
-check_push_result () {
+check_push_result_with_name () {
+	repo_name="$1"
+	shift
+
 	(
-		cd testrepo &&
+		cd $repo_name &&
 		it="$1" &&
 		shift
 		for ref in "$@"
@@ -96,6 +108,10 @@ check_push_result () {
 	)
 }
 
+check_push_result () {
+	check_push_result_with_name testrepo "$@"
+}
+
 test_expect_success setup '
 
 	>path1 &&
-- 
1.8.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help