3 test_description='progress display'
8 tr '\015' Q | sed -e "s/Q/<CR>\\$LF/g"
11 test_expect_success 'simple progress display' '
12 cat >expect <<-\EOF &&
16 Working hard: 5, done.
29 test-tool progress "Working hard" <in 2>stderr &&
31 show_cr <stderr >out &&
32 test_i18ncmp expect out
35 test_expect_success 'progress display with total' '
36 cat >expect <<-\EOF &&
37 Working hard: 33% (1/3)<CR>
38 Working hard: 66% (2/3)<CR>
39 Working hard: 100% (3/3)<CR>
40 Working hard: 100% (3/3), done.
48 test-tool progress --total=3 "Working hard" <in 2>stderr &&
50 show_cr <stderr >out &&
51 test_i18ncmp expect out
54 test_expect_success 'progress display breaks long lines #1' '
55 sed -e "s/Z$//" >expect <<\EOF &&
56 Working hard.......2.........3.........4.........5.........6: 0% (100/100000)<CR>
57 Working hard.......2.........3.........4.........5.........6: 1% (1000/100000)<CR>
58 Working hard.......2.........3.........4.........5.........6: Z
59 10% (10000/100000)<CR>
60 100% (100000/100000)<CR>
61 100% (100000/100000), done.
70 test-tool progress --total=100000 \
71 "Working hard.......2.........3.........4.........5.........6" \
74 show_cr <stderr >out &&
75 test_i18ncmp expect out
78 test_expect_success 'progress display breaks long lines #2' '
79 # Note: we do not need that many spaces after the title to cover up
80 # the last line before breaking the progress line.
81 sed -e "s/Z$//" >expect <<\EOF &&
82 Working hard.......2.........3.........4.........5.........6: 0% (1/100000)<CR>
83 Working hard.......2.........3.........4.........5.........6: 0% (2/100000)<CR>
84 Working hard.......2.........3.........4.........5.........6: Z
85 10% (10000/100000)<CR>
86 100% (100000/100000)<CR>
87 100% (100000/100000), done.
98 test-tool progress --total=100000 \
99 "Working hard.......2.........3.........4.........5.........6" \
102 show_cr <stderr >out &&
103 test_i18ncmp expect out
106 test_expect_success 'progress display breaks long lines #3 - even the first is too long' '
107 # Note: we do not actually need any spaces at the end of the title
108 # line, because there is no previous progress line to cover up.
109 sed -e "s/Z$//" >expect <<\EOF &&
110 Working hard.......2.........3.........4.........5.........6: Z
111 25% (25000/100000)<CR>
112 50% (50000/100000)<CR>
113 75% (75000/100000)<CR>
114 100% (100000/100000)<CR>
115 100% (100000/100000), done.
124 test-tool progress --total=100000 \
125 "Working hard.......2.........3.........4.........5.........6" \
128 show_cr <stderr >out &&
129 test_i18ncmp expect out
132 test_expect_success 'progress display breaks long lines #4 - title line matches terminal width' '
133 cat >expect <<\EOF &&
134 Working hard.......2.........3.........4.........5.........6.........7.........:
135 25% (25000/100000)<CR>
136 50% (50000/100000)<CR>
137 75% (75000/100000)<CR>
138 100% (100000/100000)<CR>
139 100% (100000/100000), done.
148 test-tool progress --total=100000 \
149 "Working hard.......2.........3.........4.........5.........6.........7........." \
152 show_cr <stderr >out &&
153 test_i18ncmp expect out
156 # Progress counter goes backwards, this should not happen in practice.
157 test_expect_success 'progress shortens - crazy caller' '
158 cat >expect <<-\EOF &&
159 Working hard: 10% (100/1000)<CR>
160 Working hard: 20% (200/1000)<CR>
161 Working hard: 0% (1/1000) <CR>
162 Working hard: 100% (1000/1000)<CR>
163 Working hard: 100% (1000/1000), done.
172 test-tool progress --total=1000 "Working hard" <in 2>stderr &&
174 show_cr <stderr >out &&
175 test_i18ncmp expect out
178 test_expect_success 'progress display with throughput' '
179 cat >expect <<-\EOF &&
181 Working hard: 20, 200.00 KiB | 100.00 KiB/s<CR>
182 Working hard: 30, 300.00 KiB | 100.00 KiB/s<CR>
183 Working hard: 40, 400.00 KiB | 100.00 KiB/s<CR>
184 Working hard: 40, 400.00 KiB | 100.00 KiB/s, done.
188 throughput 102400 1000
191 throughput 204800 2000
194 throughput 307200 3000
197 throughput 409600 4000
201 test-tool progress "Working hard" <in 2>stderr &&
203 show_cr <stderr >out &&
204 test_i18ncmp expect out
207 test_expect_success 'progress display with throughput and total' '
208 cat >expect <<-\EOF &&
209 Working hard: 25% (10/40)<CR>
210 Working hard: 50% (20/40), 200.00 KiB | 100.00 KiB/s<CR>
211 Working hard: 75% (30/40), 300.00 KiB | 100.00 KiB/s<CR>
212 Working hard: 100% (40/40), 400.00 KiB | 100.00 KiB/s<CR>
213 Working hard: 100% (40/40), 400.00 KiB | 100.00 KiB/s, done.
217 throughput 102400 1000
219 throughput 204800 2000
221 throughput 307200 3000
223 throughput 409600 4000
226 test-tool progress --total=40 "Working hard" <in 2>stderr &&
228 show_cr <stderr >out &&
229 test_i18ncmp expect out
232 test_expect_success 'cover up after throughput shortens' '
233 cat >expect <<-\EOF &&
235 Working hard: 2, 800.00 KiB | 400.00 KiB/s<CR>
236 Working hard: 3, 1.17 MiB | 400.00 KiB/s <CR>
237 Working hard: 4, 1.56 MiB | 400.00 KiB/s<CR>
238 Working hard: 4, 1.56 MiB | 400.00 KiB/s, done.
242 throughput 409600 1000
245 throughput 819200 2000
248 throughput 1228800 3000
251 throughput 1638400 4000
255 test-tool progress "Working hard" <in 2>stderr &&
257 show_cr <stderr >out &&
258 test_i18ncmp expect out
261 test_expect_success 'cover up after throughput shortens a lot' '
262 cat >expect <<-\EOF &&
264 Working hard: 2, 1000.00 KiB | 1000.00 KiB/s<CR>
265 Working hard: 3, 3.00 MiB | 1.50 MiB/s <CR>
266 Working hard: 3, 3.00 MiB | 1024.00 KiB/s, done.
273 throughput 1024000 2000
276 throughput 3145728 3000
280 test-tool progress "Working hard" <in 2>stderr &&
282 show_cr <stderr >out &&
283 test_i18ncmp expect out