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

[PATCH v3 3/4] fetch-pack: test cases for the new --stdin option

From
Ivan Todoroski <grnch@gmx.net>
Date
Apr 2, 2012, 15:16 UTC
Message-ID
<4F79C2C8.3020009@gmx.net>
In-Reply-To
<4F79C195.6090905@gmx.net>

These test cases focus only on testing the parsing of refs on stdin, without bothering with the rest of the fetch-pack machinery. We pass in the refs using different combinations of command line and stdin and then we watch fetch-pack's stdout to see whether it prints all the refs we specified (but we ignore their order).

Signed-off-by: Ivan Todoroski <grnch@gmx.net>
---
 t/t5500-fetch-pack.sh |   66 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 9bf69e9a0f..feaa222c78 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -248,4 +248,70 @@ test_expect_success 'clone shallow object count' '
 	grep "^count: 52" count.shallow
 '
 
+test_expect_success 'setup tests for the --stdin parameter' '
+	for head in C D E F
+	do
+		add $head
+	done &&
+	for head in A B C D E F
+	do
+		git tag $head $head
+	done
+	cat >input <<EOF
+refs/heads/C
+refs/heads/A
+refs/heads/D
+refs/tags/C
+refs/heads/B
+refs/tags/A
+refs/heads/E
+refs/tags/B
+refs/tags/E
+refs/tags/D
+EOF
+	sort <input >expect
+	(
+	echo refs/heads/E &&
+	echo refs/tags/E &&
+	cat input
+	) >input.dup
+'
+
+test_expect_success 'fetch refs from cmdline, make sure it still works OK' '
+	(
+	cd client &&
+	git fetch-pack --no-progress .. $(cat ../input)
+	) >output &&
+	cut -d " " -f 2 <output | sort >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'fetch refs from stdin' '
+	(
+	cd client &&
+	git fetch-pack --stdin --no-progress .. <../input
+	) >output &&
+	cut -d " " -f 2 <output | sort >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'fetch mixed refs from cmdline and stdin' '
+	(
+	cd client &&
+	tail -n +5 ../input |
+	git fetch-pack --stdin --no-progress .. $(head -n 4 ../input)
+	) >output &&
+	cut -d " " -f 2 <output | sort >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'test duplicate refs from stdin' '
+	(
+	cd client &&
+	test_must_fail git fetch-pack --stdin --no-progress .. <../input.dup
+	) >output &&
+	cut -d " " -f 2 <output | sort >actual &&
+	test_cmp expect actual
+'
+
 test_done
-- 
1.7.9.5.4.g4f508
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 9 in “Clone fails on a repo with too many heads/tags”
  1. 0/4 Clone fails on a repo with too many heads/tagsIvan Todoroski, Apr 2, 2012
  2. 1/4 fetch-pack: new --stdin option to read refs from stdinIvan Todoroski, Apr 2, 2012
  3. Jeff KingApr 2, 2012
  4. 2/4 remote-curl: send the refs to fetch-pack on stdinIvan Todoroski, Apr 2, 2012
  5. Junio C HamanoApr 2, 2012
  6. 3/4 fetch-pack: test cases for the new --stdin optionIvan Todoroski, Apr 2, 2012
  7. Junio C HamanoApr 2, 2012
  8. Ivan TodoroskiApr 3, 2012
  9. 4/4 remote-curl: main test case for the OS command line overflowIvan Todoroski, Apr 2, 2012

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.