##// END OF EJS Templates
test-extension: fix disabled extension tests for run-tests.py --local...
Brodie Rao -
r10669:181cbb23 stable
parent child Browse files
Show More
@@ -1,179 +1,180
1 1 #!/bin/sh
2 2 # Test basic extension support
3 3
4 4 "$TESTDIR/hghave" no-outer-repo || exit 80
5 5
6 6 cat > foobar.py <<EOF
7 7 import os
8 8 from mercurial import commands
9 9
10 10 def uisetup(ui):
11 11 ui.write("uisetup called\\n")
12 12
13 13 def reposetup(ui, repo):
14 14 ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
15 15 ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
16 16
17 17 def foo(ui, *args, **kwargs):
18 18 ui.write("Foo\\n")
19 19
20 20 def bar(ui, *args, **kwargs):
21 21 ui.write("Bar\\n")
22 22
23 23 cmdtable = {
24 24 "foo": (foo, [], "hg foo"),
25 25 "bar": (bar, [], "hg bar"),
26 26 }
27 27
28 28 commands.norepo += ' bar'
29 29 EOF
30 30 abspath=`pwd`/foobar.py
31 31
32 32 mkdir barfoo
33 33 cp foobar.py barfoo/__init__.py
34 34 barfoopath=`pwd`/barfoo
35 35
36 36 hg init a
37 37 cd a
38 38 echo foo > file
39 39 hg add file
40 40 hg commit -m 'add file'
41 41
42 42 echo '[extensions]' >> $HGRCPATH
43 43 echo "foobar = $abspath" >> $HGRCPATH
44 44 hg foo
45 45
46 46 cd ..
47 47 hg clone a b
48 48
49 49 hg bar
50 50 echo 'foobar = !' >> $HGRCPATH
51 51
52 52 echo '% module/__init__.py-style'
53 53 echo "barfoo = $barfoopath" >> $HGRCPATH
54 54 cd a
55 55 hg foo
56 56 echo 'barfoo = !' >> $HGRCPATH
57 57
58 58 # check that extensions are loaded in phases
59 59 cat > foo.py <<EOF
60 60 import os
61 61 name = os.path.basename(__file__).rsplit('.', 1)[0]
62 62 print "1) %s imported" % name
63 63 def uisetup(ui):
64 64 print "2) %s uisetup" % name
65 65 def extsetup():
66 66 print "3) %s extsetup" % name
67 67 def reposetup(ui, repo):
68 68 print "4) %s reposetup" % name
69 69 EOF
70 70
71 71 cp foo.py bar.py
72 72 echo 'foo = foo.py' >> $HGRCPATH
73 73 echo 'bar = bar.py' >> $HGRCPATH
74 74
75 75 # command with no output, we just want to see the extensions loaded
76 76 hg paths
77 77
78 78 # check hgweb's load order
79 79 echo '% hgweb.cgi'
80 80 cat > hgweb.cgi <<EOF
81 81 #!/usr/bin/env python
82 82 from mercurial import demandimport; demandimport.enable()
83 83 from mercurial.hgweb import hgweb
84 84 from mercurial.hgweb import wsgicgi
85 85
86 86 application = hgweb('.', 'test repo')
87 87 wsgicgi.launch(application)
88 88 EOF
89 89 SCRIPT_NAME='/' SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
90 90 | grep '^[0-9]) ' # ignores HTML output
91 91
92 92 echo 'foo = !' >> $HGRCPATH
93 93 echo 'bar = !' >> $HGRCPATH
94 94
95 95 cd ..
96 96 cat > empty.py <<EOF
97 97 '''empty cmdtable
98 98 '''
99 99 cmdtable = {}
100 100 EOF
101 101 emptypath=`pwd`/empty.py
102 102 echo "empty = $emptypath" >> $HGRCPATH
103 103 hg help empty
104 104 echo 'empty = !' >> $HGRCPATH
105 105
106 106 cat > debugextension.py <<EOF
107 107 '''only debugcommands
108 108 '''
109 109 def debugfoobar(ui, repo, *args, **opts):
110 110 "yet another debug command"
111 111 pass
112 112
113 113 def foo(ui, repo, *args, **opts):
114 114 """yet another foo command
115 115
116 116 This command has been DEPRECATED since forever.
117 117 """
118 118 pass
119 119
120 120 cmdtable = {
121 121 "debugfoobar": (debugfoobar, (), "hg debugfoobar"),
122 122 "foo": (foo, (), "hg foo")
123 123 }
124 124 EOF
125 125 debugpath=`pwd`/debugextension.py
126 126 echo "debugextension = $debugpath" >> $HGRCPATH
127 127 echo "% hg help"
128 128 hg help debugextension
129 129 echo "% hg help --verbose"
130 130 hg --verbose help debugextension
131 131 echo "% hg help --debug"
132 132 hg --debug help debugextension
133 133 echo 'debugextension = !' >> $HGRCPATH
134 134
135 135 echo % issue811
136 136 debugpath=`pwd`/debugissue811.py
137 137 cat > debugissue811.py <<EOF
138 138 '''show all loaded extensions
139 139 '''
140 140 from mercurial import extensions, commands
141 141
142 142 def debugextensions(ui):
143 143 "yet another debug command"
144 144 ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
145 145
146 146 cmdtable = {"debugextensions": (debugextensions, (), "hg debugextensions")}
147 147 commands.norepo += " debugextensions"
148 148 EOF
149 149 echo "debugissue811 = $debugpath" >> $HGRCPATH
150 150 echo "mq=" >> $HGRCPATH
151 151 echo "hgext.mq=" >> $HGRCPATH
152 152 echo "hgext/mq=" >> $HGRCPATH
153 153
154 154 echo % show extensions
155 155 hg debugextensions
156 156
157 157 echo '% disabled extension commands'
158 158 HGRCPATH=
159 159 hg help email
160 160 hg qdel
161 161 hg churn
162 162 echo '% disabled extensions'
163 163 hg help churn
164 164 hg help patchbomb
165 165 echo '% broken disabled extension and command'
166 166 mkdir hgext
167 167 echo > hgext/__init__.py
168 168 cat > hgext/broken.py <<EOF
169 169 "broken extension'
170 170 EOF
171 TMPPYTHONPATH="$PYTHONPATH"
172 PYTHONPATH="`pwd`:$PYTHONPATH"
173 export PYTHONPATH
174 hg help broken
175 hg help foo > /dev/null
176 PYTHONPATH="$TMPPYTHONPATH"
177 export PYTHONPATH
171 cat > path.py <<EOF
172 import os, sys
173 sys.path.insert(0, os.environ['HGEXTPATH'])
174 EOF
175 HGEXTPATH=`pwd`
176 export HGEXTPATH
177 hg --config extensions.path=./path.py help broken
178 hg --config extensions.path=./path.py help foo > /dev/null
178 179
179 180 exit 0
General Comments 0
You need to be logged in to leave comments. Login now