Mercurial > hg
annotate tests/test-progress.t @ 13141:6cfe17c19ba2
tests: add filtercr.py helper for progress tests
The two tests that used filtercr.py already used a slightly different
version, which explains why test-convert-svn-move.t changed after
switching to using $TESTDIR/filtercr.py.
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Wed, 15 Dec 2010 16:29:46 +0100 |
parents | 05fffd665170 |
children | e9827c85c50b |
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 $ echo "[extensions]" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
27 $ echo "progress=" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
28 $ echo "loop=`pwd`/loop.py" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
29 $ echo "[progress]" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
30 $ echo "assume-tty=1" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
31 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
32 test default params, display nothing because of delay |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
33 |
13141
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
34 $ hg -y loop 3 2>&1 | $TESTDIR/filtercr.py |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
35 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
36 $ echo "delay=0" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
37 $ echo "refresh=0" >> $HGRCPATH |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
38 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
39 test with delay=0, refresh=0 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
40 |
13141
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
41 $ hg -y loop 3 2>&1 | $TESTDIR/filtercr.py |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
42 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
43 loop [ ] 0/3 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
44 loop [=====================> ] 1/3 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
45 loop [============================================> ] 2/3 |
12942
05fffd665170
tests: use (esc) for all non-ASCII test output
Mads Kiilerich <mads@kiilerich.com>
parents:
12479
diff
changeset
|
46 \r (esc) |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
47 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
48 test refresh is taken in account |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
49 |
13141
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
50 $ hg -y --config progress.refresh=100 loop 3 2>&1 | $TESTDIR/filtercr.py |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
51 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
52 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
53 test format options 1 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
54 |
13141
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
55 $ hg -y --config 'progress.format=number topic item+2' loop 2 2>&1 \ |
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
56 > | $TESTDIR/filtercr.py |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
57 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
58 0/2 loop lo |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
59 1/2 loop lo |
12942
05fffd665170
tests: use (esc) for all non-ASCII test output
Mads Kiilerich <mads@kiilerich.com>
parents:
12479
diff
changeset
|
60 \r (esc) |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
61 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
62 test format options 2 |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
63 |
13141
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
64 $ hg -y --config 'progress.format=number item-3 bar' loop 2 2>&1 \ |
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
65 > | $TESTDIR/filtercr.py |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
66 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
67 0/2 p.0 [ ] |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
68 1/2 p.1 [=================================> ] |
12942
05fffd665170
tests: use (esc) for all non-ASCII test output
Mads Kiilerich <mads@kiilerich.com>
parents:
12479
diff
changeset
|
69 \r (esc) |
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 test format options and indeterminate progress |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
72 |
13141
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
73 $ hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 \ |
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
74 > | $TESTDIR/filtercr.py |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
75 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
76 0 loop.0 [ <=> ] |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
77 1 loop.1 [ <=> ] |
12942
05fffd665170
tests: use (esc) for all non-ASCII test output
Mads Kiilerich <mads@kiilerich.com>
parents:
12479
diff
changeset
|
78 \r (esc) |
10465
5d7e84e7ac6d
Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
79 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
80 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
|
81 |
13141
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
82 $ hg -y loop --total 4 6 2>&1 | $TESTDIR/filtercr.py |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
83 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
84 loop [ ] 0/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
85 loop [================> ] 1/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
86 loop [=================================> ] 2/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
87 loop [==================================================> ] 3/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
88 loop [===================================================================>] 4/4 |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
89 loop [ <=> ] 5/4 |
12942
05fffd665170
tests: use (esc) for all non-ASCII test output
Mads Kiilerich <mads@kiilerich.com>
parents:
12479
diff
changeset
|
90 \r (esc) |
10891
83af68e38be3
progress: fall back to indeterminate progress if position is >= total
Augie Fackler <durin42@gmail.com>
parents:
10788
diff
changeset
|
91 |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
92 test immediate progress completion |
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
93 |
13141
6cfe17c19ba2
tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents:
12942
diff
changeset
|
94 $ hg -y loop 0 2>&1 | $TESTDIR/filtercr.py |
12479
2f9ef3657730
tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents:
10891
diff
changeset
|
95 |