##// END OF EJS Templates
Add test for progress extension
Patrick Mezard -
r10465:5d7e84e7 stable
parent child Browse files
Show More
@@ -0,0 +1,60 b''
1 #!/bin/sh
2
3 cat > loop.py <<EOF
4 from mercurial import commands
5
6 def loop(ui, loops, **opts):
7 loops = int(loops)
8 total = None
9 if loops >= 0:
10 total = loops
11 loops = abs(loops)
12
13 for i in range(loops):
14 ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total)
15 ui.progress('loop', None, 'loop.done', 'loopnum', total)
16
17 commands.norepo += " loop"
18
19 cmdtable = {
20 "loop": (loop, [], 'hg loop LOOPS'),
21 }
22 EOF
23
24 cat > filtercr.py <<EOF
25 import sys, re
26 for line in sys.stdin:
27 line = re.sub(r'\r+[^\n]', lambda m: '\n' + m.group()[-1:], line)
28 sys.stdout.write(line)
29 EOF
30
31 echo "[extensions]" >> $HGRCPATH
32 echo "progress=" >> $HGRCPATH
33 echo "loop=" `pwd`/loop.py >> $HGRCPATH
34 echo "[ui]" >> $HGRCPATH
35 echo "interactive=1" >> $HGRCPATH
36
37 echo '% test default params, display nothing because of delay'
38 hg -y loop 3 | python filtercr.py
39
40 echo "[progress]" >> $HGRCPATH
41 echo "delay=0" >> $HGRCPATH
42 echo "refresh=0" >> $HGRCPATH
43
44 echo '% test with delay=0, refresh=0'
45 hg -y loop 3 | python filtercr.py
46
47 echo '% test refresh is taken in account'
48 hg -y --config progress.refresh=100 loop 3 | python filtercr.py
49
50 echo '% test format options 1'
51 hg -y --config 'progress.format=number topic item+2' loop 2 | python filtercr.py
52
53 echo '% test format options 2'
54 hg -y --config 'progress.format=number item-3 bar' loop 2 | python filtercr.py
55
56 echo '% test format options and indeterminate progress'
57 hg -y --config 'progress.format=number item bar' loop -- -2 | python filtercr.py
58
59 echo '% test immediate progress completion'
60 hg -y loop 0 | python filtercr.py
@@ -0,0 +1,20 b''
1 % test default params, display nothing because of delay
2 % test with delay=0, refresh=0
3
4 loop [ ] 0/3
5 loop [=====================> ] 1/3
6 loop [============================================> ] 2/3
7 % test refresh is taken in account
8 % test format options 1
9
10 0/2 loop lo
11 1/2 loop lo
12 % test format options 2
13
14 0/2 p.0 [ ]
15 1/2 p.1 [=================================> ]
16 % test format options and indeterminate progress
17
18 0 loop.0 [ <=> ]
19 1 loop.1 [ <=> ]
20 % test immediate progress completion
General Comments 0
You need to be logged in to leave comments. Login now