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