mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
667c6a1274
Summary: Rework the progress. Always move the cursor to the top-left corner of the progress output. So the clear progress instruction is just to erase till the end of the screen. There is no need to track the height of the progress. Update flush logic so we only do flush when crossing the progress/non-progress boundary: When we write progress (to stderr), flush stdout, write progress, then flush stderr. Also, disable progress unconditionally if the current output line is incomplete. Reviewed By: sfilipco Differential Revision: D27109228 fbshipit-source-id: 717345e9c7eaeebeb378ce090f7b2f60957fd150
79 lines
4.0 KiB
Perl
79 lines
4.0 KiB
Perl
#chg-compatible
|
|
|
|
$ enable progress
|
|
$ setconfig extensions.rustprogresstest="$TESTDIR/rustprogresstest.py"
|
|
$ setconfig progress.delay=0 progress.changedelay=2 progress.refresh=1 progress.assume-tty=true
|
|
|
|
Test creating a progress spinner.
|
|
$ hg rustspinnertest 5
|
|
loop 1 [ <=> ] 1.0\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 2 [ <=> ] 2.0\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 3 [ <=> ] 3.0\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 4 [ <=> ] 4.0\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 5 [ <=> ] 5.0\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[J (no-eol) (esc)
|
|
|
|
Test creating a progress bar.
|
|
$ hg rustprogresstest 6 6
|
|
loop 1 [===================> ] 1/3 03s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 2 [========================================> ] 2/3 02s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 3 [=============================================================>] 3/3 01s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 4 [========================================> ] 4/6 03s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 5 [==================================================> ] 5/6 02s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 6 [=============================================================>] 6/6 01s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[J (no-eol) (esc)
|
|
|
|
Test creating an indeterminate (i.e., no total) progress bar.
|
|
$ hg rustprogresstest -- 5 -1
|
|
loop 1 [ <=> ] 1\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 2 [ <=> ] 2\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 3 [ <=> ] 3\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 4 [ <=> ] 4\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 5 [ <=> ] 5\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[J (no-eol) (esc)
|
|
|
|
Test formatting the number as bytes.
|
|
Note that the first iteration is not rendered because the first value is 0.
|
|
$ hg rustbytesprogresstest
|
|
loop 2 [ ] 10 bytes/1.03 GB 3y28w\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 3 [ ] 250 bytes/1.03 GB 14w05d\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 4 [ ] 999 bytes/1.03 GB 5w04d\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 5 [ ] 1000 bytes/1.03 GB 7w03d\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 6 [ ] 1.00 KB/1.03 GB 9w00d\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 7 [ ] 21.5 KB/1.03 GB 3d13h\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 8 [ ] 1.00 MB/1.03 GB 2h04m\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 9 [ ] 1.41 MB/1.03 GB 1h41m\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 10 [====> ] 118 MB/1.03 GB 1m13s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 11 [=======================> ] 530 MB/1.03 GB 11s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 12 [===========================================> ] 954 MB/1.03 GB 02s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[Jloop 13 [================================================>] 1.03 GB/1.03 GB 01s\r (no-eol) (esc)
|
|
\r (no-eol) (esc)
|
|
\x1b[J (no-eol) (esc)
|