Mercurial > hg
annotate tests/test-progress.t @ 12515:b6a784e39ad4
tests: unify test-convert-bzr-ghosts
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Sep 2010 14:36:49 -0500 |
parents | 2f9ef3657730 |
children | 05fffd665170 |
rev | line source |
---|---|
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
2 $ cat > loop.py <<EOF |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
3 > from mercurial import commands |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
4 > |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
5 > def loop(ui, loops, **opts): |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
6 > loops = int(loops) |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
7 > total = None |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
8 > if loops >= 0: |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
9 > total = loops |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
10 > if opts.get('total', None): |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
11 > total = int(opts.get('total')) |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
12 > loops = abs(loops) |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
13 > |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
14 > for i in range(loops): |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
15 > ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total) |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
16 > ui.progress('loop', None, 'loop.done', 'loopnum', total) |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
17 > |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
18 > commands.norepo += " loop" |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
19 > |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
20 > cmdtable = { |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
21 > "loop": (loop, [('', 'total', '', 'override for total')], |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
22 > 'hg loop LOOPS'), |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
23 > } |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
24 > EOF |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
25 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
26 $ cat > filtercr.py <<EOF |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
27 > import sys, re |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
28 > for line in sys.stdin: |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
29 > line = re.sub(r'\r+[^\n]', lambda m: '\n' + m.group()[-1:], line) |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
30 > sys.stdout.write(line) |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
31 > print |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
32 > EOF |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
34 $ echo "[extensions]" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
35 $ echo "progress=" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
36 $ echo "loop=`pwd`/loop.py" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
37 $ echo "[progress]" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
38 $ echo "assume-tty=1" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
39 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
40 test default params, display nothing because of delay |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
41 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
42 $ hg -y loop 3 2>&1 | python filtercr.py |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
43 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
44 $ echo "delay=0" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
45 $ echo "refresh=0" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
46 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
47 test with delay=0, refresh=0 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
48 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
49 $ hg -y loop 3 2>&1 | python filtercr.py |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
50 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
51 loop [ ] 0/3 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
52 loop [=====================> ] 1/3 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
53 loop [============================================> ] 2/3 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
54 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
55 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
56 test refresh is taken in account |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
57 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
58 $ hg -y --config progress.refresh=100 loop 3 2>&1 | python filtercr.py |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
59 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
60 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
61 test format options 1 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
62 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
63 $ hg -y --config 'progress.format=number topic item+2' loop 2 2>&1 | python filtercr.py |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
64 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
65 0/2 loop lo |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
66 1/2 loop lo |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
67 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
68 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
69 test format options 2 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
70 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
71 $ hg -y --config 'progress.format=number item-3 bar' loop 2 2>&1 | python filtercr.py |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
72 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
73 0/2 p.0 [ ] |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
74 1/2 p.1 [=================================> ] |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
75 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
76 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
77 test format options and indeterminate progress |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
78 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
79 $ hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 | python filtercr.py |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
80 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
81 0 loop.0 [ <=> ] |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
82 1 loop.1 [ <=> ] |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
83 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
84 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
85 make sure things don't fall over if count > total |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
86 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
87 $ hg -y loop --total 4 6 2>&1 | python filtercr.py |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
88 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
89 loop [ ] 0/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
90 loop [================> ] 1/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
91 loop [=================================> ] 2/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
92 loop [==================================================> ] 3/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
93 loop [===================================================================>] 4/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
94 loop [ <=> ] 5/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
95 |
10891
83af68e38be3
progress: fall back to indeterminate progress if position is >= total
Augie Fackler <durin42@gmail.com>
parents:
10788
diff
changeset
|
96 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
97 test immediate progress completion |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
98 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
99 $ hg -y loop 0 2>&1 | python filtercr.py |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
100 |