tests/test-progress.t
author A. S. Budden <abudden@gmail.com>
Fri, 30 Mar 2012 22:08:46 +0100
changeset 16324 46b991a1f428
parent 15372 695ac6aca77f
child 16350 4f795f5fbb0b
permissions -rw-r--r--
record: allow splitting of hunks by manually editing patches It is possible that unrelated changes in a file are on sequential lines. The current record extension does not allow these to be committed independently. An example use case for this is in software development for deeply embedded real-time systems. In these environments, it is not always possible to use a debugger (due to time-constraints) and hence inline UART-based printing is often used. When fixing a bug in a module, it is often convenient to add a large number of 'printf's (linked to the UART via a custom fputc) to the module in order to work out what is going wrong. printf is a very slow function (and also variadic so somewhat frowned upon by the MISRA standard) and hence it is highly undesirable to commit these lines to the repository. If only a partial fix is implemented, however, it is desirable to commit the fix without deleting all of the printf lines. This is also simplifies removal of the printf lines as once the final fix is committed, 'hg revert' does the rest. It is likely that the printf lines will be very near the actual fix, so being able to split the hunk is very useful in this case. There were two alternatives I considered for the user interface. One was to manually edit the patch, the other to allow a hunk to be split into individual lines for consideration. The latter option would require a significant refactor of the record module and is less flexible. While the former is potentially more complicated to use, this is a feature that is likely to only be used in certain exceptional cases (such as the use case proposed above) and hence I felt that the complexity would not be a considerable issue. I've also written a follow-up patch that refactors the 'prompt' code to base everything on the choices variable. This tidies up and clarifies the code a bit (removes constructs like 'if ret == 7' and removes the 'e' option from the file scope options as it's not relevant there. It's not really a necessity, so I've excluded it from this submission for now, but I can send it separately if there's a desire and it's on bitbucket (see below) in the meantime. Possible future improvements include: * Tidying up the 'prompt' code to base everything on the choices variable. This would allow entries to be removed from the prompt as currently 'e' is offered even for entire file patches, which is currently unsupported. * Allowing the entire file (or even multi-file) patch to be edited manually: this would require quite a large refactor without much benefit, so I decided to exclude it from the initial submission. * Allow the option to retry if a patch fails to apply (this is what Git does). This would require quite a bit of refactoring given the current 'hg record' implementation, so it's debatable whether it's worth it. Output is similar to existing record user interface except that an additional option ('e') exists to allow manual editing of the patch. This opens the user's configured editor with the patch. A comment is added to the bottom of the patch explaining what to do (based on Git's one). A large proportion of the changeset is test-case changes to update the options reported by record (Ynesfdaq? instead of Ynsfdaq?). Functional changes are in record.py and there are some new test cases in test-record.t.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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'))
14838
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    12
  >     nested = False
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    13
  >     if opts.get('nested', None):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    14
  >         nested = True
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    15
  >     loops = abs(loops)
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    16
  > 
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    17
  >     for i in range(loops):
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    18
  >         ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total)
14838
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    19
  >         if opts.get('parallel'):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    20
  >             ui.progress('other', i, 'other.%d' % i, 'othernum', total)
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    21
  >         if nested:
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    22
  >             for j in range(2):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    23
  >                 ui.progress('nested', j, 'nested.%d' % j, 'nestnum', 2)
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    24
  >             ui.progress('nested', None, 'nested.done', 'nestnum', 2)
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    25
  >     ui.progress('loop', None, 'loop.done', 'loopnum', total)
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    26
  > 
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    27
  > commands.norepo += " loop"
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    28
  > 
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    29
  > cmdtable = {
14838
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    30
  >     "loop": (loop, [('', 'total', '', 'override for total'),
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    31
  >                     ('', 'nested', False, 'show nested results'),
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    32
  >                     ('', 'parallel', False, 'show parallel sets of results'),
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    33
  >                    ],
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    34
  >              'hg loop LOOPS'),
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
  > EOF
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    37
15372
695ac6aca77f check-code: fix issues with finding patterns in unified tests, fix tests
Matt Mackall <mpm@selenic.com>
parents: 14838
diff changeset
    38
  $ cp $HGRCPATH $HGRCPATH.orig
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    39
  $ echo "[extensions]" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    40
  $ echo "progress=" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    41
  $ echo "loop=`pwd`/loop.py" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    42
  $ echo "[progress]" >> $HGRCPATH
13149
735dd8e8a208 progress using tests: disable time estimates to avoid flakiness
Augie Fackler <durin42@gmail.com>
parents: 13145
diff changeset
    43
  $ echo  "format = topic bar number" >> $HGRCPATH
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    44
  $ echo "assume-tty=1" >> $HGRCPATH
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    45
  $ echo "width=60" >> $HGRCPATH
12479
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 default params, display nothing because of delay
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    48
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
    49
  $ hg -y loop 3 2>&1 | $TESTDIR/filtercr.py
12479
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
  $ echo "delay=0" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    52
  $ echo "refresh=0" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    53
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    54
test with delay=0, refresh=0
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    55
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
    56
  $ hg -y loop 3 2>&1 | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    57
  
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    58
  loop [                                                ] 0/3
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    59
  loop [===============>                                ] 1/3
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    60
  loop [===============================>                ] 2/3
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    61
                                                              \r (esc)
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    62
14838
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    63
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    64
test nested short-lived topics (which shouldn't display with nestdelay):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    65
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    66
  $ hg -y loop 3 --nested 2>&1 | \
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    67
  > python $TESTDIR/filtercr.py
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    68
  
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    69
  loop [                                                ] 0/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    70
  loop [===============>                                ] 1/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    71
  loop [===============================>                ] 2/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    72
                                                              \r (esc)
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    73
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    74
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    75
  $ hg --config progress.changedelay=0 -y loop 3 --nested 2>&1 | \
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    76
  > python $TESTDIR/filtercr.py
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    77
  
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    78
  loop [                                                ] 0/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    79
  nested [                                              ] 0/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    80
  nested [======================>                       ] 1/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    81
  loop [===============>                                ] 1/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    82
  nested [                                              ] 0/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    83
  nested [======================>                       ] 1/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    84
  loop [===============================>                ] 2/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    85
  nested [                                              ] 0/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    86
  nested [======================>                       ] 1/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    87
                                                              \r (esc)
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    88
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    89
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    90
test two topics being printed in parallel (as when we're doing a local
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    91
--pull clone, where you get the unbundle and bundle progress at the
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    92
same time):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    93
  $ hg loop 3 --parallel 2>&1 | python $TESTDIR/filtercr.py
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    94
  
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    95
  loop [                                                ] 0/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    96
  loop [===============>                                ] 1/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    97
  loop [===============================>                ] 2/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    98
                                                              \r (esc)
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    99
test refresh is taken in account
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   100
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   101
  $ 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
   102
  
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   103
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   104
test format options 1
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   105
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   106
  $ 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
   107
  > | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   108
  
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   109
  0/2 loop lo
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   110
  1/2 loop lo
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   111
                                                              \r (esc)
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   112
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   113
test format options 2
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   114
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   115
  $ 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
   116
  > | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   117
  
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   118
  0/2 p.0 [                                                 ]
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   119
  1/2 p.1 [=======================>                         ]
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   120
                                                              \r (esc)
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   121
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   122
test format options and indeterminate progress
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   123
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   124
  $ 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
   125
  > | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   126
  
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   127
  0 loop.0               [ <=>                              ]
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   128
  1 loop.1               [  <=>                             ]
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   129
                                                              \r (esc)
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   130
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   131
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
   132
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   133
  $ 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
   134
  
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   135
  loop [                                                ] 0/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   136
  loop [===========>                                    ] 1/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   137
  loop [=======================>                        ] 2/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   138
  loop [===================================>            ] 3/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   139
  loop [===============================================>] 4/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   140
  loop [ <=>                                            ] 5/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   141
                                                              \r (esc)
10891
83af68e38be3 progress: fall back to indeterminate progress if position is >= total
Augie Fackler <durin42@gmail.com>
parents: 10788
diff changeset
   142
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   143
test immediate progress completion
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   144
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   145
  $ hg -y loop 0 2>&1 | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   146
  
13145
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   147
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   148
test delay time estimates
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   149
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   150
  $ cat > mocktime.py <<EOF
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   151
  > import os
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   152
  > import time
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   153
  > 
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   154
  > class mocktime(object):
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   155
  >     def __init__(self, increment):
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   156
  >         self.time = 0
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   157
  >         self.increment = increment
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   158
  >     def __call__(self):
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   159
  >         self.time += self.increment
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   160
  >         return self.time
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   161
  > 
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   162
  > def uisetup(ui):
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   163
  >     time.time = mocktime(int(os.environ.get('MOCKTIME', '11')))
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   164
  > EOF
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   165
15372
695ac6aca77f check-code: fix issues with finding patterns in unified tests, fix tests
Matt Mackall <mpm@selenic.com>
parents: 14838
diff changeset
   166
  $ cp $HGRCPATH.orig $HGRCPATH
695ac6aca77f check-code: fix issues with finding patterns in unified tests, fix tests
Matt Mackall <mpm@selenic.com>
parents: 14838
diff changeset
   167
  $ echo "[extensions]" >> $HGRCPATH
13145
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   168
  $ echo "mocktime=`pwd`/mocktime.py" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   169
  $ echo "progress=" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   170
  $ echo "loop=`pwd`/loop.py" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   171
  $ echo "[progress]" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   172
  $ echo "assume-tty=1" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   173
  $ echo "delay=25" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   174
  $ echo "width=60" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   175
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   176
  $ hg -y loop 8 2>&1 | python $TESTDIR/filtercr.py
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   177
  
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   178
  loop [=========>                                ] 2/8 1m07s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   179
  loop [===============>                            ] 3/8 56s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   180
  loop [=====================>                      ] 4/8 45s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   181
  loop [==========================>                 ] 5/8 34s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   182
  loop [================================>           ] 6/8 23s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   183
  loop [=====================================>      ] 7/8 12s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   184
                                                              \r (esc)
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   185
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   186
  $ MOCKTIME=10000 hg -y loop 4 2>&1 | python $TESTDIR/filtercr.py
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   187
  
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   188
  loop [                                                ] 0/4
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   189
  loop [=========>                                ] 1/4 8h21m
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   190
  loop [====================>                     ] 2/4 5h34m
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   191
  loop [==============================>           ] 3/4 2h47m
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   192
                                                              \r (esc)
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   193
13236
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   194
  $ MOCKTIME=1000000 hg -y loop 4 2>&1 | python $TESTDIR/filtercr.py
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   195
  
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   196
  loop [                                                ] 0/4
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   197
  loop [=========>                                ] 1/4 5w00d
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   198
  loop [====================>                     ] 2/4 3w03d
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   199
  loop [=============================>           ] 3/4 11d14h
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   200
                                                              \r (esc)
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   201
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   202
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   203
  $ MOCKTIME=14000000 hg -y loop 4 2>&1 | python $TESTDIR/filtercr.py
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   204
  
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   205
  loop [                                                ] 0/4
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   206
  loop [=========>                                ] 1/4 1y18w
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   207
  loop [===================>                     ] 2/4 46w03d
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   208
  loop [=============================>           ] 3/4 23w02d
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   209
                                                              \r (esc)
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   210
13154
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   211
Time estimates should not fail when there's no end point:
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   212
  $ hg -y loop -- -4 2>&1 | python $TESTDIR/filtercr.py
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   213
  
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   214
  loop [ <=>                                              ] 2
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   215
  loop [  <=>                                             ] 3
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   216
                                                              \r (esc)