##// END OF EJS Templates
py3: add a missing b'' prefix in test extension for chg...
Martin von Zweigbergk -
r43424:f05d10ef default
parent child Browse files
Show More
@@ -1,331 +1,331 b''
1 #require chg
1 #require chg
2
2
3 $ mkdir log
3 $ mkdir log
4 $ cp $HGRCPATH $HGRCPATH.unconfigured
4 $ cp $HGRCPATH $HGRCPATH.unconfigured
5 $ cat <<'EOF' >> $HGRCPATH
5 $ cat <<'EOF' >> $HGRCPATH
6 > [cmdserver]
6 > [cmdserver]
7 > log = $TESTTMP/log/server.log
7 > log = $TESTTMP/log/server.log
8 > max-log-files = 1
8 > max-log-files = 1
9 > max-log-size = 10 kB
9 > max-log-size = 10 kB
10 > EOF
10 > EOF
11 $ cp $HGRCPATH $HGRCPATH.orig
11 $ cp $HGRCPATH $HGRCPATH.orig
12
12
13 $ filterlog () {
13 $ filterlog () {
14 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \
14 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \
15 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \
15 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \
16 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \
16 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \
17 > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \
17 > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \
18 > -e 's!\(pid\)=[0-9]*!\1=...!g' \
18 > -e 's!\(pid\)=[0-9]*!\1=...!g' \
19 > -e 's!\(/server-\)[0-9a-f]*!\1...!g'
19 > -e 's!\(/server-\)[0-9a-f]*!\1...!g'
20 > }
20 > }
21
21
22 init repo
22 init repo
23
23
24 $ chg init foo
24 $ chg init foo
25 $ cd foo
25 $ cd foo
26
26
27 ill-formed config
27 ill-formed config
28
28
29 $ chg status
29 $ chg status
30 $ echo '=brokenconfig' >> $HGRCPATH
30 $ echo '=brokenconfig' >> $HGRCPATH
31 $ chg status
31 $ chg status
32 hg: parse error at * (glob)
32 hg: parse error at * (glob)
33 [255]
33 [255]
34
34
35 $ cp $HGRCPATH.orig $HGRCPATH
35 $ cp $HGRCPATH.orig $HGRCPATH
36
36
37 long socket path
37 long socket path
38
38
39 $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket
39 $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket
40 $ mkdir -p $sockpath
40 $ mkdir -p $sockpath
41 $ bakchgsockname=$CHGSOCKNAME
41 $ bakchgsockname=$CHGSOCKNAME
42 $ CHGSOCKNAME=$sockpath/server
42 $ CHGSOCKNAME=$sockpath/server
43 $ export CHGSOCKNAME
43 $ export CHGSOCKNAME
44 $ chg root
44 $ chg root
45 $TESTTMP/foo
45 $TESTTMP/foo
46 $ rm -rf $sockpath
46 $ rm -rf $sockpath
47 $ CHGSOCKNAME=$bakchgsockname
47 $ CHGSOCKNAME=$bakchgsockname
48 $ export CHGSOCKNAME
48 $ export CHGSOCKNAME
49
49
50 $ cd ..
50 $ cd ..
51
51
52 editor
52 editor
53 ------
53 ------
54
54
55 $ cat >> pushbuffer.py <<EOF
55 $ cat >> pushbuffer.py <<EOF
56 > def reposetup(ui, repo):
56 > def reposetup(ui, repo):
57 > repo.ui.pushbuffer(subproc=True)
57 > repo.ui.pushbuffer(subproc=True)
58 > EOF
58 > EOF
59
59
60 $ chg init editor
60 $ chg init editor
61 $ cd editor
61 $ cd editor
62
62
63 by default, system() should be redirected to the client:
63 by default, system() should be redirected to the client:
64
64
65 $ touch foo
65 $ touch foo
66 $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \
66 $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \
67 > | egrep "HG:|run 'cat"
67 > | egrep "HG:|run 'cat"
68 chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob)
68 chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob)
69 HG: Enter commit message. Lines beginning with 'HG:' are removed.
69 HG: Enter commit message. Lines beginning with 'HG:' are removed.
70 HG: Leave message empty to abort commit.
70 HG: Leave message empty to abort commit.
71 HG: --
71 HG: --
72 HG: user: test
72 HG: user: test
73 HG: branch 'default'
73 HG: branch 'default'
74 HG: added foo
74 HG: added foo
75
75
76 but no redirection should be made if output is captured:
76 but no redirection should be made if output is captured:
77
77
78 $ touch bar
78 $ touch bar
79 $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \
79 $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \
80 > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \
80 > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \
81 > | egrep "HG:|run 'cat"
81 > | egrep "HG:|run 'cat"
82 [1]
82 [1]
83
83
84 check that commit commands succeeded:
84 check that commit commands succeeded:
85
85
86 $ hg log -T '{rev}:{desc}\n'
86 $ hg log -T '{rev}:{desc}\n'
87 1:bufferred
87 1:bufferred
88 0:channeled
88 0:channeled
89
89
90 $ cd ..
90 $ cd ..
91
91
92 pager
92 pager
93 -----
93 -----
94
94
95 $ cat >> fakepager.py <<EOF
95 $ cat >> fakepager.py <<EOF
96 > import sys
96 > import sys
97 > for line in sys.stdin:
97 > for line in sys.stdin:
98 > sys.stdout.write('paged! %r\n' % line)
98 > sys.stdout.write('paged! %r\n' % line)
99 > EOF
99 > EOF
100
100
101 enable pager extension globally, but spawns the master server with no tty:
101 enable pager extension globally, but spawns the master server with no tty:
102
102
103 $ chg init pager
103 $ chg init pager
104 $ cd pager
104 $ cd pager
105 $ cat >> $HGRCPATH <<EOF
105 $ cat >> $HGRCPATH <<EOF
106 > [extensions]
106 > [extensions]
107 > pager =
107 > pager =
108 > [pager]
108 > [pager]
109 > pager = "$PYTHON" $TESTTMP/fakepager.py
109 > pager = "$PYTHON" $TESTTMP/fakepager.py
110 > EOF
110 > EOF
111 $ chg version > /dev/null
111 $ chg version > /dev/null
112 $ touch foo
112 $ touch foo
113 $ chg ci -qAm foo
113 $ chg ci -qAm foo
114
114
115 pager should be enabled if the attached client has a tty:
115 pager should be enabled if the attached client has a tty:
116
116
117 $ chg log -l1 -q --config ui.formatted=True
117 $ chg log -l1 -q --config ui.formatted=True
118 paged! '0:1f7b0de80e11\n'
118 paged! '0:1f7b0de80e11\n'
119 $ chg log -l1 -q --config ui.formatted=False
119 $ chg log -l1 -q --config ui.formatted=False
120 0:1f7b0de80e11
120 0:1f7b0de80e11
121
121
122 chg waits for pager if runcommand raises
122 chg waits for pager if runcommand raises
123
123
124 $ cat > $TESTTMP/crash.py <<EOF
124 $ cat > $TESTTMP/crash.py <<EOF
125 > from mercurial import registrar
125 > from mercurial import registrar
126 > cmdtable = {}
126 > cmdtable = {}
127 > command = registrar.command(cmdtable)
127 > command = registrar.command(cmdtable)
128 > @command(b'crash')
128 > @command(b'crash')
129 > def pagercrash(ui, repo, *pats, **opts):
129 > def pagercrash(ui, repo, *pats, **opts):
130 > ui.write('going to crash\n')
130 > ui.write(b'going to crash\n')
131 > raise Exception('.')
131 > raise Exception('.')
132 > EOF
132 > EOF
133
133
134 $ cat > $TESTTMP/fakepager.py <<EOF
134 $ cat > $TESTTMP/fakepager.py <<EOF
135 > from __future__ import absolute_import
135 > from __future__ import absolute_import
136 > import sys
136 > import sys
137 > import time
137 > import time
138 > for line in iter(sys.stdin.readline, ''):
138 > for line in iter(sys.stdin.readline, ''):
139 > if 'crash' in line: # only interested in lines containing 'crash'
139 > if 'crash' in line: # only interested in lines containing 'crash'
140 > # if chg exits when pager is sleeping (incorrectly), the output
140 > # if chg exits when pager is sleeping (incorrectly), the output
141 > # will be captured by the next test case
141 > # will be captured by the next test case
142 > time.sleep(1)
142 > time.sleep(1)
143 > sys.stdout.write('crash-pager: %s' % line)
143 > sys.stdout.write('crash-pager: %s' % line)
144 > EOF
144 > EOF
145
145
146 $ cat >> .hg/hgrc <<EOF
146 $ cat >> .hg/hgrc <<EOF
147 > [extensions]
147 > [extensions]
148 > crash = $TESTTMP/crash.py
148 > crash = $TESTTMP/crash.py
149 > EOF
149 > EOF
150
150
151 $ chg crash --pager=on --config ui.formatted=True 2>/dev/null
151 $ chg crash --pager=on --config ui.formatted=True 2>/dev/null
152 crash-pager: going to crash
152 crash-pager: going to crash
153 [255]
153 [255]
154
154
155 $ cd ..
155 $ cd ..
156
156
157 server lifecycle
157 server lifecycle
158 ----------------
158 ----------------
159
159
160 chg server should be restarted on code change, and old server will shut down
160 chg server should be restarted on code change, and old server will shut down
161 automatically. In this test, we use the following time parameters:
161 automatically. In this test, we use the following time parameters:
162
162
163 - "sleep 1" to make mtime different
163 - "sleep 1" to make mtime different
164 - "sleep 2" to notice mtime change (polling interval is 1 sec)
164 - "sleep 2" to notice mtime change (polling interval is 1 sec)
165
165
166 set up repository with an extension:
166 set up repository with an extension:
167
167
168 $ chg init extreload
168 $ chg init extreload
169 $ cd extreload
169 $ cd extreload
170 $ touch dummyext.py
170 $ touch dummyext.py
171 $ cat <<EOF >> .hg/hgrc
171 $ cat <<EOF >> .hg/hgrc
172 > [extensions]
172 > [extensions]
173 > dummyext = dummyext.py
173 > dummyext = dummyext.py
174 > EOF
174 > EOF
175
175
176 isolate socket directory for stable result:
176 isolate socket directory for stable result:
177
177
178 $ OLDCHGSOCKNAME=$CHGSOCKNAME
178 $ OLDCHGSOCKNAME=$CHGSOCKNAME
179 $ mkdir chgsock
179 $ mkdir chgsock
180 $ CHGSOCKNAME=`pwd`/chgsock/server
180 $ CHGSOCKNAME=`pwd`/chgsock/server
181
181
182 warm up server:
182 warm up server:
183
183
184 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
184 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
185 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
185 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
186
186
187 new server should be started if extension modified:
187 new server should be started if extension modified:
188
188
189 $ sleep 1
189 $ sleep 1
190 $ touch dummyext.py
190 $ touch dummyext.py
191 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
191 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
192 chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
192 chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
193 chg: debug: * instruction: reconnect (glob)
193 chg: debug: * instruction: reconnect (glob)
194 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
194 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
195
195
196 old server will shut down, while new server should still be reachable:
196 old server will shut down, while new server should still be reachable:
197
197
198 $ sleep 2
198 $ sleep 2
199 $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true)
199 $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true)
200
200
201 socket file should never be unlinked by old server:
201 socket file should never be unlinked by old server:
202 (simulates unowned socket by updating mtime, which makes sure server exits
202 (simulates unowned socket by updating mtime, which makes sure server exits
203 at polling cycle)
203 at polling cycle)
204
204
205 $ ls chgsock/server-*
205 $ ls chgsock/server-*
206 chgsock/server-* (glob)
206 chgsock/server-* (glob)
207 $ touch chgsock/server-*
207 $ touch chgsock/server-*
208 $ sleep 2
208 $ sleep 2
209 $ ls chgsock/server-*
209 $ ls chgsock/server-*
210 chgsock/server-* (glob)
210 chgsock/server-* (glob)
211
211
212 since no server is reachable from socket file, new server should be started:
212 since no server is reachable from socket file, new server should be started:
213 (this test makes sure that old server shut down automatically)
213 (this test makes sure that old server shut down automatically)
214
214
215 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
215 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
216 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
216 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
217
217
218 shut down servers and restore environment:
218 shut down servers and restore environment:
219
219
220 $ rm -R chgsock
220 $ rm -R chgsock
221 $ sleep 2
221 $ sleep 2
222 $ CHGSOCKNAME=$OLDCHGSOCKNAME
222 $ CHGSOCKNAME=$OLDCHGSOCKNAME
223 $ cd ..
223 $ cd ..
224
224
225 check that server events are recorded:
225 check that server events are recorded:
226
226
227 $ ls log
227 $ ls log
228 server.log
228 server.log
229 server.log.1
229 server.log.1
230
230
231 print only the last 10 lines, since we aren't sure how many records are
231 print only the last 10 lines, since we aren't sure how many records are
232 preserved:
232 preserved:
233
233
234 $ cat log/server.log.1 log/server.log | tail -10 | filterlog
234 $ cat log/server.log.1 log/server.log | tail -10 | filterlog
235 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
235 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
236 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ...
236 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ...
237 YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
237 YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
238 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
238 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
239 YYYY/MM/DD HH:MM:SS (PID)> setumask 18
239 YYYY/MM/DD HH:MM:SS (PID)> setumask 18
240 YYYY/MM/DD HH:MM:SS (PID)> setenv: ...
240 YYYY/MM/DD HH:MM:SS (PID)> setenv: ...
241 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
241 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
242 YYYY/MM/DD HH:MM:SS (PID)> validate: []
242 YYYY/MM/DD HH:MM:SS (PID)> validate: []
243 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
243 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
244 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
244 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
245
245
246 repository cache
246 repository cache
247 ----------------
247 ----------------
248
248
249 $ rm log/server.log*
249 $ rm log/server.log*
250 $ cp $HGRCPATH.unconfigured $HGRCPATH
250 $ cp $HGRCPATH.unconfigured $HGRCPATH
251 $ cat <<'EOF' >> $HGRCPATH
251 $ cat <<'EOF' >> $HGRCPATH
252 > [cmdserver]
252 > [cmdserver]
253 > log = $TESTTMP/log/server.log
253 > log = $TESTTMP/log/server.log
254 > max-repo-cache = 1
254 > max-repo-cache = 1
255 > track-log = command, repocache
255 > track-log = command, repocache
256 > EOF
256 > EOF
257
257
258 isolate socket directory for stable result:
258 isolate socket directory for stable result:
259
259
260 $ OLDCHGSOCKNAME=$CHGSOCKNAME
260 $ OLDCHGSOCKNAME=$CHGSOCKNAME
261 $ mkdir chgsock
261 $ mkdir chgsock
262 $ CHGSOCKNAME=`pwd`/chgsock/server
262 $ CHGSOCKNAME=`pwd`/chgsock/server
263
263
264 create empty repo and cache it:
264 create empty repo and cache it:
265
265
266 $ hg init cached
266 $ hg init cached
267 $ hg id -R cached
267 $ hg id -R cached
268 000000000000 tip
268 000000000000 tip
269 $ sleep 1
269 $ sleep 1
270
270
271 modify repo (and cache will be invalidated):
271 modify repo (and cache will be invalidated):
272
272
273 $ touch cached/a
273 $ touch cached/a
274 $ hg ci -R cached -Am 'add a'
274 $ hg ci -R cached -Am 'add a'
275 adding a
275 adding a
276 $ sleep 1
276 $ sleep 1
277
277
278 read cached repo:
278 read cached repo:
279
279
280 $ hg log -R cached
280 $ hg log -R cached
281 changeset: 0:ac82d8b1f7c4
281 changeset: 0:ac82d8b1f7c4
282 tag: tip
282 tag: tip
283 user: test
283 user: test
284 date: Thu Jan 01 00:00:00 1970 +0000
284 date: Thu Jan 01 00:00:00 1970 +0000
285 summary: add a
285 summary: add a
286
286
287 $ sleep 1
287 $ sleep 1
288
288
289 discard cached from LRU cache:
289 discard cached from LRU cache:
290
290
291 $ hg clone cached cached2
291 $ hg clone cached cached2
292 updating to branch default
292 updating to branch default
293 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
293 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
294 $ hg id -R cached2
294 $ hg id -R cached2
295 ac82d8b1f7c4 tip
295 ac82d8b1f7c4 tip
296 $ sleep 1
296 $ sleep 1
297
297
298 read uncached repo:
298 read uncached repo:
299
299
300 $ hg log -R cached
300 $ hg log -R cached
301 changeset: 0:ac82d8b1f7c4
301 changeset: 0:ac82d8b1f7c4
302 tag: tip
302 tag: tip
303 user: test
303 user: test
304 date: Thu Jan 01 00:00:00 1970 +0000
304 date: Thu Jan 01 00:00:00 1970 +0000
305 summary: add a
305 summary: add a
306
306
307 $ sleep 1
307 $ sleep 1
308
308
309 shut down servers and restore environment:
309 shut down servers and restore environment:
310
310
311 $ rm -R chgsock
311 $ rm -R chgsock
312 $ sleep 2
312 $ sleep 2
313 $ CHGSOCKNAME=$OLDCHGSOCKNAME
313 $ CHGSOCKNAME=$OLDCHGSOCKNAME
314
314
315 check server log:
315 check server log:
316
316
317 $ cat log/server.log | filterlog
317 $ cat log/server.log | filterlog
318 YYYY/MM/DD HH:MM:SS (PID)> init cached
318 YYYY/MM/DD HH:MM:SS (PID)> init cached
319 YYYY/MM/DD HH:MM:SS (PID)> id -R cached
319 YYYY/MM/DD HH:MM:SS (PID)> id -R cached
320 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
320 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
321 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
321 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
322 YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am 'add a'
322 YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am 'add a'
323 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
323 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
324 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
324 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
325 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
325 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
326 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
326 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
327 YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2
327 YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2
328 YYYY/MM/DD HH:MM:SS (PID)> id -R cached2
328 YYYY/MM/DD HH:MM:SS (PID)> id -R cached2
329 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s)
329 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s)
330 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
330 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
331 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
331 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
General Comments 0
You need to be logged in to leave comments. Login now