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