Mercurial > hg
comparison tests/test-progress.t @ 34316:12b355964de8
test-patchbomb: use mocktime
The test was using system time for displaying ETAs, which could be flaky if
the sysload is high. This patch extracts mocktime.py from test-progress.t to
make sure test-patchbomb.t is unaffected by system time.
Differential Revision: https://phab.mercurial-scm.org/D844
author | Jun Wu <quark@fb.com> |
---|---|
date | Fri, 29 Sep 2017 11:41:24 -0700 |
parents | a667f0ca1d5f |
children | 34592dd3bfa2 |
comparison
equal
deleted
inserted
replaced
34315:98b359216915 | 34316:12b355964de8 |
---|---|
183 | 183 |
184 test delay time estimates | 184 test delay time estimates |
185 | 185 |
186 #if no-chg | 186 #if no-chg |
187 | 187 |
188 $ cat > mocktime.py <<EOF | |
189 > import os | |
190 > import time | |
191 > | |
192 > class mocktime(object): | |
193 > def __init__(self, increment): | |
194 > self.time = 0 | |
195 > self.increment = [int(s) for s in increment.split()] | |
196 > self.pos = 0 | |
197 > def __call__(self): | |
198 > self.time += self.increment[self.pos % len(self.increment)] | |
199 > self.pos += 1 | |
200 > return self.time | |
201 > | |
202 > def uisetup(ui): | |
203 > time.time = mocktime(os.environ.get('MOCKTIME', '11')) | |
204 > EOF | |
205 | |
206 $ cp $HGRCPATH.orig $HGRCPATH | 188 $ cp $HGRCPATH.orig $HGRCPATH |
207 $ echo "[extensions]" >> $HGRCPATH | 189 $ echo "[extensions]" >> $HGRCPATH |
208 $ echo "mocktime=`pwd`/mocktime.py" >> $HGRCPATH | 190 $ echo "mocktime=$TESTDIR/mocktime.py" >> $HGRCPATH |
209 $ echo "progress=" >> $HGRCPATH | 191 $ echo "progress=" >> $HGRCPATH |
210 $ echo "loop=`pwd`/loop.py" >> $HGRCPATH | 192 $ echo "loop=`pwd`/loop.py" >> $HGRCPATH |
211 $ echo "[progress]" >> $HGRCPATH | 193 $ echo "[progress]" >> $HGRCPATH |
212 $ echo "assume-tty=1" >> $HGRCPATH | 194 $ echo "assume-tty=1" >> $HGRCPATH |
213 $ echo "delay=25" >> $HGRCPATH | 195 $ echo "delay=25" >> $HGRCPATH |
214 $ echo "width=60" >> $HGRCPATH | 196 $ echo "width=60" >> $HGRCPATH |
215 | 197 |
216 $ hg -y loop 8 | 198 $ MOCKTIME=11 hg -y loop 8 |
217 \r (no-eol) (esc) | 199 \r (no-eol) (esc) |
218 loop [=========> ] 2/8 1m07s\r (no-eol) (esc) | 200 loop [=========> ] 2/8 1m07s\r (no-eol) (esc) |
219 loop [===============> ] 3/8 56s\r (no-eol) (esc) | 201 loop [===============> ] 3/8 56s\r (no-eol) (esc) |
220 loop [=====================> ] 4/8 45s\r (no-eol) (esc) | 202 loop [=====================> ] 4/8 45s\r (no-eol) (esc) |
221 loop [==========================> ] 5/8 34s\r (no-eol) (esc) | 203 loop [==========================> ] 5/8 34s\r (no-eol) (esc) |
272 loop [====================================> ] 18/20 52s\r (no-eol) (esc) | 254 loop [====================================> ] 18/20 52s\r (no-eol) (esc) |
273 loop [======================================> ] 19/20 25s\r (no-eol) (esc) | 255 loop [======================================> ] 19/20 25s\r (no-eol) (esc) |
274 \r (no-eol) (esc) | 256 \r (no-eol) (esc) |
275 | 257 |
276 Time estimates should not fail when there's no end point: | 258 Time estimates should not fail when there's no end point: |
277 $ hg -y loop -- -4 | 259 $ MOCKTIME=11 hg -y loop -- -4 |
278 \r (no-eol) (esc) | 260 \r (no-eol) (esc) |
279 loop [ <=> ] 2\r (no-eol) (esc) | 261 loop [ <=> ] 2\r (no-eol) (esc) |
280 loop [ <=> ] 3\r (no-eol) (esc) | 262 loop [ <=> ] 3\r (no-eol) (esc) |
281 \r (no-eol) (esc) | 263 \r (no-eol) (esc) |
282 | 264 |