git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Mar 22, 2013, 07:52 UTC
Message-ID
<1363938756-13722-4-git-send-email-artagnon@gmail.com>
In-Reply-To
<1363938756-13722-1-git-send-email-artagnon@gmail.com>

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 <artagnon@gmail.com>
---
 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.62.ga35d936.dirty
Previous: Jonathan NiederNext: Jeff King
Message 6 of 24 in “Support triangular workflows”
  1. 0/6 Support triangular workflowsRamkumar Ramachandra, Mar 22, 2013
  2. 1/6 remote.c: simplify a bit of code using git_config_string()Ramkumar Ramachandra, Mar 22, 2013
  3. Jonathan NiederMar 22, 2013
  4. 2/6 t5516 (fetch-push): update test descriptionRamkumar Ramachandra, Mar 22, 2013
  5. Jonathan NiederMar 22, 2013
  6. 3/6 t5516 (fetch-push): introduce mk_test_with_name()Ramkumar Ramachandra, Mar 22, 2013
  7. Jeff KingMar 22, 2013
  8. Junio C HamanoMar 22, 2013
  9. Jeff KingMar 22, 2013
  10. Jonathan NiederMar 22, 2013
  11. Ramkumar RamachandraMar 28, 2013
  12. Junio C HamanoMar 22, 2013
  13. Jeff KingMar 22, 2013
  14. 4/6 remote.c: introduce a way to have different remotes for fetch/pushRamkumar Ramachandra, Mar 22, 2013
  15. Jonathan NiederMar 22, 2013
  16. Junio C HamanoMar 22, 2013
  17. Jonathan NiederMar 22, 2013
  18. Ramkumar RamachandraMar 23, 2013
  19. Ramkumar RamachandraMar 23, 2013
  20. 5/6 remote.c: introduce remote.pushdefaultRamkumar Ramachandra, Mar 22, 2013
  21. Jeff KingMar 22, 2013
  22. Ramkumar RamachandraMar 27, 2013
  23. 6/6 remote.c: introduce branch.<name>.pushremoteRamkumar Ramachandra, Mar 22, 2013
  24. Junio C HamanoMar 22, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.