Mercurial > hg
comparison tests/test-progress @ 10465:5d7e84e7ac6d stable
Add test for progress extension
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 14 Feb 2010 15:45:12 +0100 |
parents | |
children | c52057614c72 |
comparison
equal
deleted
inserted
replaced
10464:149ad0a3ec91 | 10465:5d7e84e7ac6d |
---|---|
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 |