[PATCH 2/4] t: remote-hg: add file operation tests

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

 



Inspired by gitifyhg.

Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 contrib/remote-helpers/test-hg.sh | 76 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 33a434d..df09966 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -53,6 +53,17 @@ check_bookmark () {
 	fi
 }
 
+check_files () {
+	git --git-dir=$1/.git ls-files > actual &&
+	if test $# -gt 1
+	then
+		printf "%s\n" "$2" > expected
+	else
+		> expected
+	fi &&
+	test_cmp expected actual
+}
+
 check_push () {
 	expected_ret=$1 ret=0 ref_ret=0
 
@@ -995,4 +1006,69 @@ test_expect_success 'push tag different branch' '
 	test_cmp expected actual
 '
 
+test_expect_success 'cloning a removed file works' '
+	test_when_finished "rm -rf hgrepo gitrepo" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+
+	echo test > test_file &&
+	hg add test_file &&
+	hg commit -m add &&
+
+	hg rm test_file &&
+	hg commit -m remove
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+	check_files gitrepo
+'
+
+test_expect_success 'cloning a file replaced with a directory' '
+	test_when_finished "rm -rf hgrepo gitrepo" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+
+	echo test > dir_or_file &&
+	hg add dir_or_file &&
+	hg commit -m add &&
+
+	hg rm dir_or_file &&
+	mkdir dir_or_file &&
+	echo test > dir_or_file/test_file &&
+	hg add dir_or_file/test_file &&
+	hg commit -m replase
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+	check_files gitrepo "dir_or_file/test_file"
+'
+
+test_expect_success 'clone replace directory with a file' '
+	test_when_finished "rm -rf hgrepo gitrepo" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+
+	mkdir dir_or_file &&
+	echo test > dir_or_file/test_file &&
+	hg add dir_or_file/test_file &&
+	hg commit -m add &&
+
+	hg rm dir_or_file/test_file &&
+	echo test > dir_or_file &&
+	hg add dir_or_file &&
+	hg commit -m add &&
+
+	hg rm dir_or_file
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+	check_files gitrepo "dir_or_file"
+'
+
 test_done
-- 
1.9.2+fc1.20.g204a630

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