changeset 18:feab56c76c92

Add a basic test for cloning.
author Augie Fackler <durin42@gmail.com>
date Sun, 26 Apr 2009 18:27:24 -0700
parents ace0f6ed65a1
children 2be9c0bd88af
files .hgignore DESIGN.txt tests/test-git-clone tests/test-git-clone.out
diffstat 4 files changed, 92 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore
+++ b/.hgignore
@@ -1,3 +1,4 @@
 syntax: glob
 
 *.pyc
+tests/*.err
--- a/DESIGN.txt
+++ b/DESIGN.txt
@@ -47,3 +47,19 @@
   - transfers it, updates local references (bookmarks?)
 
 
+* Tests *
+Tests are implemented in the Mercurial-standard way of small shell scripts.
+The scripts are located in the tests directory, and to run them you should
+change to that directory and then run tests/run-tests.py from the Mercurial
+sources. For example, if you have a copy of the Mercurial source code at
+/Stuff/hg-crew, you would do something like this:
+
+cd tests ; /Stuff/hg-crew/tests/run-tests.py
+
+And you should see output like this:
+.
+# Ran 1 tests, 0 skipped, 0 failed.
+
+Note that due to limitations of Dulwich at the moment, the tests need to
+start a git-daemon process. Right now, they use the default port, so will
+skip if they detect an already-running git-daemon.
new file mode 100644
--- /dev/null
+++ b/tests/test-git-clone
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# Fails for some reason, need to investigate
+# "$TESTDIR/hghave" git || exit 80
+
+# bail early if the user is already running git-daemon
+echo hi | nc localhost 9418 && exit 80
+
+echo "[extensions]" >> $HGRCPATH
+echo "hggit=$(echo $(dirname $(dirname $0)))" >> $HGRCPATH
+echo 'hgext.graphlog =' >> $HGRCPATH
+echo 'hgext.bookmarks =' >> $HGRCPATH
+
+GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
+GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
+GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
+GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
+GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
+GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
+
+count=10
+commit()
+{
+    GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
+    GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+    git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
+    count=`expr $count + 1`
+}
+
+mkdir gitrepo
+cd gitrepo
+git init | python -c "import sys; print sys.stdin.read().replace('$(dirname $(pwd))/', '')"
+echo alpha > alpha
+git add alpha
+commit -m 'add alpha'
+echo beta > beta
+git add beta
+commit -m 'add beta'
+
+# dulwich does not presently support local git repos, workaround
+cd ..
+git-daemon --base-path="$(pwd)"\
+ --listen=127.0.0.1\
+ --export-all\
+  --pid-file=gitdaemon.pid \
+ --detach --reuseaddr
+
+hg gclone git://127.0.0.1/gitrepo hgrepo
+cd hgrepo
+hg log --graph
+
+cd ..
+kill `cat gitdaemon.pid`
new file mode 100644
--- /dev/null
+++ b/tests/test-git-clone.out
@@ -0,0 +1,22 @@
+Initialized empty Git repository in gitrepo/.git/
+
+fetching from : origin
+Counting objects: 6, done.
+Compressing objects:  33% (1/3)   
Compressing objects:  66% (2/3)   
Compressing objects: 100% (3/3)   
Compressing objects: 100% (3/3), done.
+Total 6 (delta 0), reused 0 (delta 0)
+importing Git objects into Hg
+importing: 7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03
+importing: 9497a4ee62e16ee641860d7677cdb2589ea15554
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+@  changeset:   1:7bcd915dc873
+|  tag:         origin/master
+|  tag:         tip
+|  user:        test <test@example.org>
+|  date:        Mon Jan 01 00:00:11 2007 +0000
+|  summary:     add beta
+|
+o  changeset:   0:3442585be8a6
+   user:        test <test@example.org>
+   date:        Mon Jan 01 00:00:10 2007 +0000
+   summary:     add alpha
+