remote-hg: add basic tests
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Jeff King <peff@peff.net>
Felipe Contreras committed
Nov 4, 2012 at 03:13 UTC
7ee719e18074a47e41dd315fcf8ced777a71adbd
2 files changed
+125
contrib/remote-helpers/Makefile
new
+13
@@ -0,0 +1,13 @@
1
+TESTS := $(wildcard test*.sh)
2
+
3
+export T := $(addprefix $(CURDIR)/,$(TESTS))
4
+export MAKE := $(MAKE) -e
5
+export PATH := $(CURDIR):$(PATH)
6
+
7
+test:
8
+ $(MAKE) -C ../../t $@
9
+
10
+$(TESTS):
11
+ $(MAKE) -C ../../t $(CURDIR)/$@
12
+
13
+.PHONY: $(TESTS)
contrib/remote-helpers/test-hg.sh
new
+112
@@ -0,0 +1,112 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2012 Felipe Contreras
4
+#
5
+# Base commands from hg-git tests:
6
+# https://bitbucket.org/durin42/hg-git/src
7
+#
8
+
9
+test_description='Test remote-hg'
10
+
11
+. ./test-lib.sh
12
+
13
+if ! test_have_prereq PYTHON; then
14
+ skip_all='skipping remote-hg tests; python not available'
15
+ test_done
16
+fi
17
+
18
+if ! "$PYTHON_PATH" -c 'import mercurial'; then
19
+ skip_all='skipping remote-hg tests; mercurial not available'
20
+ test_done
21
+fi
22
+
23
+check () {
24
+ (cd $1 &&
25
+ git log --format='%s' -1 &&
26
+ git symbolic-ref HEAD) > actual &&
27
+ (echo $2 &&
28
+ echo "refs/heads/$3") > expected &&
29
+ test_cmp expected actual
30
+}
31
+
32
+test_expect_success 'cloning' '
33
+ test_when_finished "rm -rf gitrepo*" &&
34
+
35
+ (
36
+ hg init hgrepo &&
37
+ cd hgrepo &&
38
+ echo zero > content &&
39
+ hg add content &&
40
+ hg commit -m zero
41
+ ) &&
42
+
43
+ git clone "hg::$PWD/hgrepo" gitrepo &&
44
+ check gitrepo zero master
45
+'
46
+
47
+test_expect_success 'cloning with branches' '
48
+ test_when_finished "rm -rf gitrepo*" &&
49
+
50
+ (
51
+ cd hgrepo &&
52
+ hg branch next &&
53
+ echo next > content &&
54
+ hg commit -m next
55
+ ) &&
56
+
57
+ git clone "hg::$PWD/hgrepo" gitrepo &&
58
+ check gitrepo next next &&
59
+
60
+ (cd hgrepo && hg checkout default) &&
61
+
62
+ git clone "hg::$PWD/hgrepo" gitrepo2 &&
63
+ check gitrepo2 zero master
64
+'
65
+
66
+test_expect_success 'cloning with bookmarks' '
67
+ test_when_finished "rm -rf gitrepo*" &&
68
+
69
+ (
70
+ cd hgrepo &&
71
+ hg bookmark feature-a &&
72
+ echo feature-a > content &&
73
+ hg commit -m feature-a
74
+ ) &&
75
+
76
+ git clone "hg::$PWD/hgrepo" gitrepo &&
77
+ check gitrepo feature-a feature-a
78
+'
79
+
80
+test_expect_success 'cloning with detached head' '
81
+ test_when_finished "rm -rf gitrepo*" &&
82
+
83
+ (
84
+ cd hgrepo &&
85
+ hg update -r 0
86
+ ) &&
87
+
88
+ git clone "hg::$PWD/hgrepo" gitrepo &&
89
+ check gitrepo zero master
90
+'
91
+
92
+test_expect_success 'update bookmark' '
93
+ test_when_finished "rm -rf gitrepo*" &&
94
+
95
+ (
96
+ cd hgrepo &&
97
+ hg bookmark devel
98
+ ) &&
99
+
100
+ (
101
+ git clone "hg::$PWD/hgrepo" gitrepo &&
102
+ cd gitrepo &&
103
+ git checkout devel &&
104
+ echo devel > content &&
105
+ git commit -a -m devel &&
106
+ git push
107
+ ) &&
108
+
109
+ hg -R hgrepo bookmarks | grep "devel\s\+3:"
110
+'
111
+
112
+test_done