Greg Ward avatar Greg Ward committed 01699f7

Add test-hg for tests that can run and use a real hg.

Comments (0)

Files changed (4)

 # Maximally pessimistic view of header dependencies.
 $(objects): $(headers)
 
-.PHONY: check check-simple check-git
-check: check-simple check-git
+.PHONY: check check-simple check-hg check-git
+check: check-simple check-hg check-git
 
+hgrepo = tests/hg-repo.tar
 gitrepo = tests/git-repo.tar
 
 check-simple: vcprompt
 	cd tests && ./test-simple
 
+check-hg: vcprompt $(hgrepo)
+	cd tests && ./test-hg
+
+$(hgrepo): tests/setup-hg
+	cd tests && ./setup-hg
+
 check-git: vcprompt $(gitrepo)
 	cd tests && ./test-git
 
 vcprompt=""
 tmpdir=""
 
+die()
+{
+    msg=$1
+    echo "error: $msg" >&2
+    exit 1
+}
+
 # Check if some external command is available by running it
 # and ensuring that it prints an expected string.  If not,
 # exit with optional message.
+#!/bin/sh
+
+# Setup the test hg repository that will be used by test-hg.
+#
+# Output is hg-repo.tar, which will be unpacked for each test run.
+
+. ./common.sh
+
+check_available "hg -q version" "Mercurial Distributed SCM"
+set -ex
+cd `dirname $0`
+rm -rf hg-repo
+hg init hg-repo
+cd hg-repo
+
+echo a > a
+echo b > b
+hg commit -ualice -d'2010-01-01 00:00:00 +0000' -A -m"add a, b"
+
+cat > .hgignore <<EOF
+~$
+\.o$
+EOF
+hg commit -ualice -d'2010-01-01 00:00:01 +0000' -A -m"add hgignore"
+
+hg branch stable
+echo fix >> b
+hg commit -ualice -d'2010-01-01 00:00:02 +0000' -m"fix a bug"
+
+hg update default
+
+cd ..
+tar -cf hg-repo.tar hg-repo
+rm -rf hg-repo
+#!/bin/sh
+
+# Tests that require a real hg repository and executable.
+
+. ./common.sh
+
+check_hg()
+{
+    check_available \
+	"hg -q version" \
+	"Mercurial Distributed SCM" \
+	"hg not found: skipping this test script"
+}
+
+find_hgrepo()
+{
+    hgrepo="$testdir/hg-repo.tar"
+    if [ ! -f $hgrepo ]; then
+	echo "$hgrepo not found" >&2
+	exit 1
+    fi
+}
+
+pretest()
+{
+    [ -d "$tmpdir" ] || die "tmpdir ($tmpdir) does not exist"
+    cd $tmpdir
+    if [ ! -d hg-repo -o -f hg-repo/.hg/tainted ]; then
+	rm -rf hg-repo
+	tar -xf $hgrepo
+    fi
+    cd hg-repo
+}
+
+posttest()
+{
+    :
+}
+
+# default prompt format in test repo
+test_basics()
+{
+    pretest
+    assert_vcprompt "show branch 1" "default" "%b"
+    hg -q update stable
+    assert_vcprompt "show branch 2" "stable" "%b"
+
+    # not implemented yet
+    #echo foo >> b
+    #echo junk > junk
+    #assert_vcprompt "show modified" "+" "%m"
+    #assert_vcprompt "show unknown" "?" "%u"
+
+    posttest
+}
+
+check_hg
+find_vcprompt
+find_hgrepo
+setup
+
+test_basics
+
+report
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.