Commit f0fd0aafb69cafd7c84dd294cffda4b3c1d6144a

Stefan Sperling 2021-09-14T19:21:59

make 'got send' regression tests run 'git fsck' on all involved repositories

diff --git a/regress/cmdline/common.sh b/regress/cmdline/common.sh
index fbd40bc..260f640 100644
--- a/regress/cmdline/common.sh
+++ b/regress/cmdline/common.sh
@@ -119,6 +119,24 @@ git_commit_tree()
 	maybe_pack_repo $repo
 }
 
+git_fsck()
+{
+	local testroot="$1"
+	local repo="$2"
+
+	(cd $repo && git fsck --strict \
+		> $testroot/fsck.stdout 2> $testroot/fsck.stderr)
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		echo -n "git fsck: "
+		cat $testroot/fsck.stderr
+		echo "git fsck failed; leaving test data in $testroot"
+		return 1
+	fi
+
+	return 0
+}
+
 make_test_tree()
 {
 	repo="$1"
@@ -186,14 +204,10 @@ test_cleanup()
 {
 	local testroot="$1"
 
-	(cd $testroot/repo && git fsck --strict \
-		> $testroot/fsck.stdout 2> $testroot/fsck.stderr)
+	git_fsck $testroot $testroot/repo
 	ret="$?"
 	if [ "$ret" != "0" ]; then
-		echo -n "git fsck: "
-		cat $testroot/fsck.stderr
-		echo "git fsck failed; leaving test data in $testroot"
-		return 1
+		return $ret
 	fi
 
 	rm -rf "$testroot"
diff --git a/regress/cmdline/send.sh b/regress/cmdline/send.sh
index eb88e75..5fdd09a 100755
--- a/regress/cmdline/send.sh
+++ b/regress/cmdline/send.sh
@@ -117,7 +117,12 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -171,7 +176,12 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stderr.expected $testroot/stderr
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -282,7 +292,12 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -456,7 +471,12 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -537,7 +557,12 @@ test_send_clone_and_send() {
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -759,7 +784,10 @@ EOF
 		test_done "$testroot" "1"
 		return 1
 	fi
-	test_done "$testroot" "0"
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
+	test_done "$testroot" "$ret"
 }
 
 test_send_tag_of_deleted_branch() {
@@ -876,7 +904,12 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -962,7 +995,12 @@ test_send_new_branch() {
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -1094,7 +1132,12 @@ test_send_all_branches() {
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -1194,7 +1237,12 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo2"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -1310,8 +1358,12 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
 
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }
 
@@ -1387,7 +1439,12 @@ EOF
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
 	fi
+
+	git_fsck "$testroot" "$testroot/repo-clone"
+	ret="$?"
 	test_done "$testroot" "$ret"
 }