[RFC PATCH 09/15] Add tests for communication dealing with sparse repositories

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

 



Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
---
 t/t5721-sparse-repository-communication.sh |  106 ++++++++++++++++++++++++++++
 1 files changed, 106 insertions(+), 0 deletions(-)
 create mode 100755 t/t5721-sparse-repository-communication.sh

diff --git a/t/t5721-sparse-repository-communication.sh b/t/t5721-sparse-repository-communication.sh
new file mode 100755
index 0000000..35cb6a2
--- /dev/null
+++ b/t/t5721-sparse-repository-communication.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+
+test_description='sparse repository communication'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/sparse-lib.sh
+
+test_expect_success 'setup' '
+	rm -fr .git &&
+	test_create_repo src &&
+	(
+		cd src &&
+
+		mkdir -p sub/{a,b} &&
+		> sub/a/file &&
+		git add sub/a/file &&
+		test_tick &&
+		git commit -q -m initial &&
+
+		> sub/b/file &&
+		git add sub/b/file &&
+		test_tick &&
+		git commit -q -m two &&
+
+		echo unique > sub/file &&
+		git add sub/file &&
+		test_tick &&
+		git commit -q -m three &&
+
+		echo content > sub/b/file &&
+		test_tick &&
+		git commit -q -m subbfile sub/b/file &&
+
+		cp -a sub/b sub/bcopy &&
+		git add sub/bcopy &&
+		test_tick &&
+		git commit -q -m subbcopy &&
+
+		echo stuff > sub/a/file &&
+		test_tick &&
+		git commit -q -m subafile sub/a/file
+	)
+'
+
+test_expect_success 'make comparison sparse repository' '
+	git clone -q "file://$(pwd)/src" compare_dst &&
+	(
+		cd compare_dst &&
+		test 25 = "$(git rev-list --objects master | wc -l)" &&
+		make_sparse sub/b/ &&
+		test 0 = $(find .git/objects/pack -type f | wc -l) &&
+		test 22 = $(find .git/objects -type f | wc -l)
+	)
+'
+
+test_expect_failure 'basic sparse clone succeeds' '
+	rm -fr dst &&
+	git clone "file://$(pwd)/src" dst -- sub/b/ &&
+	(
+		cd dst &&
+		git rev-parse master^{tree} &&
+		git rev-parse master:sub &&
+		git rev-parse master:sub/b &&
+		git rev-parse master:sub/b/file &&
+		git rev-parse master:sub/bcopy &&
+		git rev-parse master:sub/bcopy/file &&
+		git rev-parse master:sub/a &&
+		git rev-parse master:sub/file &&
+
+		git cat-file -p master:sub &&
+		git cat-file -p master:sub/b &&
+		git cat-file -p master:sub/b/file &&
+		git cat-file -p master:sub/bcopy &&
+		git cat-file -p master:sub/bcopy/file &&
+		test_must_fail git cat-file -p master:sub/file &&
+		test_must_fail git cat-file -p master:sub/a &&
+		test_must_fail git rev-parse master:sub/a/file &&
+
+		test -f sub/b/file &&
+		! test -d sub/a &&
+		! test -d sub/bcopy &&
+		! test -f sub/file
+	)
+'
+
+test_expect_failure 'basic sparse clone guts match expectations' '
+	(
+		# Loose objects only, to facilitate comparison
+		cd dst &&
+		mv .git/objects/pack/* . &&
+		for i in $(ls *.pack); do
+			git unpack-objects -q < $i
+		done &&
+		rm -f *.pack *.idx
+	) &&
+	(
+		# Get the names of all loose objects
+		cd dst &&
+		find .git/objects -type f > ../dst-objects &&
+		cd ../compare_dst &&
+		find .git/objects -type f > ../compare_dst-objects
+	) &&
+	test_cmp dst-objects compare_dst-objects &&
+	test_cmp dst/.git/sparse-limits compare_dst/.git/sparse-limits
+'
+
+test_done
-- 
1.7.2.2.140.gd06af

--
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]