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

[PATCH v3 5/6] tests: add remote-hg tests

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Oct 21, 2012, 17:49 UTC
Message-ID
<1350841744-21564-6-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1350841744-21564-1-git-send-email-felipe.contreras@gmail.com>
>From the original remote-hg.
You need git-remote-hg already in your path to run them.

I'm not proposing to include this patch like this, but should make it easier to test.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t5801-remote-hg.sh | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 143 insertions(+)
 create mode 100755 t/t5801-remote-hg.sh
diff --git a/t/t5801-remote-hg.sh b/t/t5801-remote-hg.sh
new file mode 100755
index 0000000..2e68372
--- /dev/null
+++ b/t/t5801-remote-hg.sh
@@ -0,0 +1,143 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Sverre Rabbelier
+#
+
+test_description='Test remote-helper import and export commands'
+
+. ./test-lib.sh
+
+if test_have_prereq PYTHON && "$PYTHON_PATH" -c '
+import sys
+if sys.hexversion < 0x02040000:
+    sys.exit(1)
+'
+then
+	:
+else
+	skip_all='skipping git remote-hg tests: requires Python 2.4 or newer'
+	test_done
+fi
+
+if ! type hg >/dev/null 2>&1
+then
+	skip_all='skipping git remote-hg tests: requires hg'
+	test_done
+fi
+
+# Call cmp with the arguments -x ".hg" -x ".git" <left> <right>
+
+vcs_cmp () {
+	$DIFF -u -x ".hg" -x ".git" $1 $2
+}
+
+ROOT=$PWD
+
+test_expect_success 'setup repository' '
+	printf "[ui]\nusername = A U Thor <author@example.com>" > \
+		${HOME}/.hgrc &&
+	mkdir server &&
+	hg init server/.hg &&
+	hg clone "$ROOT/server" public &&
+	(cd public &&
+	 echo content >file &&
+	 hg add file &&
+	 hg commit -m one &&
+	 hg push)
+'
+
+test_expect_success 'cloning from local repo' '
+	git clone "hg::file://${ROOT}/server" localclone &&
+	vcs_cmp public localclone
+'
+
+test_expect_success 'cloning from remote repo' '
+	git clone "hg::remote://${ROOT}/server" clone &&
+	vcs_cmp public clone
+'
+
+test_expect_success 'create new commit on remote' '
+	(cd public &&
+	 echo content >>file &&
+	 hg commit -A -m two &&
+	 hg push)
+'
+
+test_expect_success 'pulling from local repo' '
+	(cd localclone && git pull) &&
+	vcs_cmp public localclone
+'
+
+test_expect_success 'pulling from remote remote' '
+	(cd clone && git pull) &&
+	vcs_cmp public clone
+'
+
+test_expect_success 'pushing to local empty repo' '
+	hg init localempty &&
+	(cd localclone &&
+	git push --all "hg::file://${ROOT}/localempty") &&
+	(cd localempty &&
+	hg up tip) &&
+	vcs_cmp localclone localempty
+'
+
+test_expect_success 'pushing to remote empty repo' '
+	hg init empty &&
+	(cd localclone &&
+	git push --all "hg::remote://${ROOT}/empty") &&
+	(cd empty &&
+	hg up tip) &&
+	vcs_cmp localclone empty
+'
+
+test_expect_success 'pushing to local repo' '
+	(cd localclone &&
+	echo content >>file &&
+	git commit -a -m three &&
+	git push) &&
+	(cd server &&
+	hg up tip) &&
+	vcs_cmp localclone server
+'
+
+test_expect_success 'synch with changes from localclone' '
+	(cd clone &&
+	 git pull)
+'
+
+test_expect_success 'pushing remote local repo' '
+	(cd clone &&
+	echo content >>file &&
+	git commit -a -m four &&
+	git push) &&
+	(cd server &&
+	hg up tip) &&
+	vcs_cmp clone server
+'
+
+test_expect_success 'creating new branch' '
+	(cd public &&
+	hg branch different-branch &&
+	echo different >> file &&
+	hg commit -m five &&
+	hg push -f)
+'
+
+test_expect_success 'pull in new branch to local repository' '
+	(cd localclone &&
+	git fetch origin default &&
+	test_must_fail git rev-parse -q --verify refs/remotes/origin/different-branch &&
+	git fetch &&
+	git rev-parse --no-revs --verify refs/remotes/origin/different-branch)
+'
+
+test_expect_success 'pull in new branch to remote repository' '
+	(cd clone &&
+	git fetch origin default &&
+	test_must_fail git rev-parse -q --verify refs/remotes/origin/different-branch &&
+	git fetch &&
+	git rev-parse --no-revs --verify refs/remotes/origin/different-branch)
+'
+
+test_done
-- 
1.8.0.rc2.7.g0961fdf.dirty
Previous: Felipe ContrerasNext: Sverre Rabbelier
Message 6 of 9 in “New remote-hg helper”
  1. 0/6 New remote-hg helperFelipe Contreras, Oct 21, 2012
  2. 1/6 Add new remote-hg transport helperFelipe Contreras, Oct 21, 2012
  3. 2/6 remote-hg: add support for pushingFelipe Contreras, Oct 21, 2012
  4. 3/6 remote-hg: add support for remote pushingFelipe Contreras, Oct 21, 2012
  5. 4/6 remote-hg: add support for trivial featuresFelipe Contreras, Oct 21, 2012
  6. 5/6 tests: add remote-hg testsFelipe Contreras, Oct 21, 2012
  7. Sverre RabbelierOct 21, 2012
  8. Felipe ContrerasOct 24, 2012
  9. 6/6 tests: fix remote-hg warnings for modern gitFelipe Contreras, Oct 21, 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.