##// END OF EJS Templates
tests: add a test for blackbox with nested alias configurations...
Augie Fackler -
r34299:25e1a887 default
parent child Browse files
Show More
@@ -1,323 +1,334 b''
1 1 setup
2 2 $ cat >> $HGRCPATH <<EOF
3 3 > [extensions]
4 4 > blackbox=
5 5 > mock=$TESTDIR/mockblackbox.py
6 6 > mq=
7 7 > [alias]
8 8 > confuse = log --limit 3
9 > so-confusing = confuse --style compact
9 10 > EOF
10 11 $ hg init blackboxtest
11 12 $ cd blackboxtest
12 13
13 14 command, exit codes, and duration
14 15
15 16 $ echo a > a
16 17 $ hg add a
17 18 $ hg blackbox --config blackbox.dirty=True
18 19 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest exited 0 after * seconds (glob)
19 20 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
20 21 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob)
21 22 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox
22 23
23 24 alias expansion is logged
24 25 $ rm ./.hg/blackbox.log
25 26 $ hg confuse
26 27 $ hg blackbox
27 28 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse
28 29 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3'
29 30 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob)
30 31 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
31 32
33 recursive aliases work correctly
34 $ rm ./.hg/blackbox.log
35 $ hg so-confusing
36 $ hg blackbox
37 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing
38 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'so-confusing' expands to 'confuse --style compact'
39 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3'
40 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing exited 0 after * seconds (glob)
41 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
42
32 43 incoming change tracking
33 44
34 45 create two heads to verify that we only see one change in the log later
35 46 $ hg commit -ma
36 47 $ hg up null
37 48 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
38 49 $ echo b > b
39 50 $ hg commit -Amb
40 51 adding b
41 52 created new head
42 53
43 54 clone, commit, pull
44 55 $ hg clone . ../blackboxtest2
45 56 updating to branch default
46 57 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
47 58 $ echo c > c
48 59 $ hg commit -Amc
49 60 adding c
50 61 $ cd ../blackboxtest2
51 62 $ hg pull
52 63 pulling from $TESTTMP/blackboxtest (glob)
53 64 searching for changes
54 65 adding changesets
55 66 adding manifests
56 67 adding file changes
57 68 added 1 changesets with 1 changes to 1 files
58 69 (run 'hg update' to get a working copy)
59 70 $ hg blackbox -l 6
60 71 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull
61 72 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob)
62 73 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes
63 74 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62
64 75 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob)
65 76 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
66 77
67 78 we must not cause a failure if we cannot write to the log
68 79
69 80 $ hg rollback
70 81 repository tip rolled back to revision 1 (undo pull)
71 82
72 83 $ mv .hg/blackbox.log .hg/blackbox.log-
73 84 $ mkdir .hg/blackbox.log
74 85 $ hg --debug incoming
75 86 warning: cannot write to blackbox.log: * (glob)
76 87 comparing with $TESTTMP/blackboxtest (glob)
77 88 query 1; heads
78 89 searching for changes
79 90 all local heads known remotely
80 91 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
81 92 tag: tip
82 93 phase: draft
83 94 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
84 95 parent: -1:0000000000000000000000000000000000000000
85 96 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
86 97 user: test
87 98 date: Thu Jan 01 00:00:00 1970 +0000
88 99 files+: c
89 100 extra: branch=default
90 101 description:
91 102 c
92 103
93 104
94 105 $ hg pull
95 106 pulling from $TESTTMP/blackboxtest (glob)
96 107 searching for changes
97 108 adding changesets
98 109 adding manifests
99 110 adding file changes
100 111 added 1 changesets with 1 changes to 1 files
101 112 (run 'hg update' to get a working copy)
102 113
103 114 a failure reading from the log is fatal
104 115
105 116 $ hg blackbox -l 3
106 117 abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob)
107 118 [255]
108 119
109 120 $ rmdir .hg/blackbox.log
110 121 $ mv .hg/blackbox.log- .hg/blackbox.log
111 122
112 123 backup bundles get logged
113 124
114 125 $ touch d
115 126 $ hg commit -Amd
116 127 adding d
117 128 created new head
118 129 $ hg strip tip
119 130 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
120 131 saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
121 132 $ hg blackbox -l 6
122 133 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
123 134 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg (glob)
124 135 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob)
125 136 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes
126 137 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob)
127 138 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
128 139
129 140 extension and python hooks - use the eol extension for a pythonhook
130 141
131 142 $ echo '[extensions]' >> .hg/hgrc
132 143 $ echo 'eol=' >> .hg/hgrc
133 144 $ echo '[hooks]' >> .hg/hgrc
134 145 $ echo 'update = echo hooked' >> .hg/hgrc
135 146 $ hg update
136 147 The fsmonitor extension is incompatible with the eol extension and has been disabled. (fsmonitor !)
137 148 hooked
138 149 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
139 150 updated to "d02f48003e62: c"
140 151 1 other heads for branch "default"
141 152 $ cat >> .hg/hgrc <<EOF
142 153 > [extensions]
143 154 > # disable eol, because it is not needed for subsequent tests
144 155 > # (in addition, keeping it requires extra care for fsmonitor)
145 156 > eol=!
146 157 > EOF
147 158 $ hg blackbox -l 6
148 159 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update (no-chg !)
149 160 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> writing .hg/cache/tags2-visible with 0 tags
150 161 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
151 162 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob)
152 163 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob)
153 164 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 'chdir:/' (glob) (chg !)
154 165 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 6
155 166
156 167 log rotation
157 168
158 169 $ echo '[blackbox]' >> .hg/hgrc
159 170 $ echo 'maxsize = 20 b' >> .hg/hgrc
160 171 $ echo 'maxfiles = 3' >> .hg/hgrc
161 172 $ hg status
162 173 $ hg status
163 174 $ hg status
164 175 $ hg tip -q
165 176 2:d02f48003e62
166 177 $ ls .hg/blackbox.log*
167 178 .hg/blackbox.log
168 179 .hg/blackbox.log.1
169 180 .hg/blackbox.log.2
170 181 $ cd ..
171 182
172 183 $ hg init blackboxtest3
173 184 $ cd blackboxtest3
174 185 $ hg blackbox
175 186 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest3 exited 0 after * seconds (glob)
176 187 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
177 188 $ mv .hg/blackbox.log .hg/blackbox.log-
178 189 $ mkdir .hg/blackbox.log
179 190 $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
180 191 > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
181 192 > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
182 193 $ $PYTHON $TESTDIR/blackbox-readonly-dispatch.py
183 194 running: add foo
184 195 result: 0
185 196 running: commit -m commit1 -d 2000-01-01 foo
186 197 result: None
187 198 running: commit -m commit2 -d 2000-01-02 foo
188 199 result: None
189 200 running: log -r 0
190 201 changeset: 0:0e4634943879
191 202 user: test
192 203 date: Sat Jan 01 00:00:00 2000 +0000
193 204 summary: commit1
194 205
195 206 result: None
196 207 running: log -r tip
197 208 changeset: 1:45589e459b2e
198 209 tag: tip
199 210 user: test
200 211 date: Sun Jan 02 00:00:00 2000 +0000
201 212 summary: commit2
202 213
203 214 result: None
204 215 $ hg blackbox
205 216 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> commit -m commit2 -d 2000-01-02 foo
206 217 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated served branch cache in * seconds (glob)
207 218 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote served branch cache with 1 labels and 1 nodes
208 219 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> commit -m commit2 -d 2000-01-02 foo exited 0 after * seconds (glob)
209 220 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0
210 221 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags
211 222 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 exited 0 after * seconds (glob)
212 223 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip
213 224 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob)
214 225 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
215 226
216 227 Test log recursion from dirty status check
217 228
218 229 $ cat > ../r.py <<EOF
219 230 > from mercurial import context, error, extensions
220 231 > x=[False]
221 232 > def status(orig, *args, **opts):
222 233 > args[0].repo().ui.log("broken", "recursion?")
223 234 > return orig(*args, **opts)
224 235 > def reposetup(ui, repo):
225 236 > extensions.wrapfunction(context.basectx, 'status', status)
226 237 > EOF
227 238 $ hg id --config extensions.x=../r.py --config blackbox.dirty=True
228 239 45589e459b2e tip
229 240
230 241 cleanup
231 242 $ cd ..
232 243
233 244 #if chg
234 245
235 246 when using chg, blackbox.log should get rotated correctly
236 247
237 248 $ cat > $TESTTMP/noop.py << EOF
238 249 > from __future__ import absolute_import
239 250 > import time
240 251 > from mercurial import registrar, scmutil
241 252 > cmdtable = {}
242 253 > command = registrar.command(cmdtable)
243 254 > @command('noop')
244 255 > def noop(ui, repo):
245 256 > pass
246 257 > EOF
247 258
248 259 $ hg init blackbox-chg
249 260 $ cd blackbox-chg
250 261
251 262 $ cat > .hg/hgrc << EOF
252 263 > [blackbox]
253 264 > maxsize = 500B
254 265 > [extensions]
255 266 > # extension change forces chg to restart
256 267 > noop=$TESTTMP/noop.py
257 268 > EOF
258 269
259 270 $ $PYTHON -c 'print("a" * 400)' > .hg/blackbox.log
260 271 $ chg noop
261 272 $ chg noop
262 273 $ chg noop
263 274 $ chg noop
264 275 $ chg noop
265 276
266 277 $ cat > showsize.py << 'EOF'
267 278 > import os, sys
268 279 > limit = 500
269 280 > for p in sys.argv[1:]:
270 281 > size = os.stat(p).st_size
271 282 > if size >= limit:
272 283 > desc = '>='
273 284 > else:
274 285 > desc = '<'
275 286 > print('%s: %s %d' % (p, desc, limit))
276 287 > EOF
277 288
278 289 $ $PYTHON showsize.py .hg/blackbox*
279 290 .hg/blackbox.log: < 500
280 291 .hg/blackbox.log.1: >= 500
281 292 .hg/blackbox.log.2: >= 500
282 293
283 294 $ cd ..
284 295
285 296 #endif
286 297
287 298 blackbox should work if repo.ui.log is not called (issue5518)
288 299
289 300 $ cat > $TESTTMP/raise.py << EOF
290 301 > from __future__ import absolute_import
291 302 > from mercurial import registrar, scmutil
292 303 > cmdtable = {}
293 304 > command = registrar.command(cmdtable)
294 305 > @command('raise')
295 306 > def raisecmd(*args):
296 307 > raise RuntimeError('raise')
297 308 > EOF
298 309
299 310 $ cat >> $HGRCPATH << EOF
300 311 > [blackbox]
301 312 > track = commandexception
302 313 > [extensions]
303 314 > raise=$TESTTMP/raise.py
304 315 > EOF
305 316
306 317 $ hg init $TESTTMP/blackbox-exception-only
307 318 $ cd $TESTTMP/blackbox-exception-only
308 319
309 320 #if chg
310 321 (chg exits 255 because it fails to receive an exit code)
311 322 $ hg raise 2>/dev/null
312 323 [255]
313 324 #else
314 325 (hg exits 1 because Python default exit code for uncaught exception is 1)
315 326 $ hg raise 2>/dev/null
316 327 [1]
317 328 #endif
318 329
319 330 $ head -1 .hg/blackbox.log
320 331 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock
321 332 $ tail -2 .hg/blackbox.log
322 333 RuntimeError: raise
323 334
General Comments 0
You need to be logged in to leave comments. Login now