3 test_description
='progress display'
5 TEST_PASSES_SANITIZE_LEAK
=true
9 tr '\015' Q |
sed -e "s/Q/<CR>\\$LF/g"
12 test_expect_success
'simple progress display' '
13 cat >expect <<-\EOF &&
17 Working hard: 5, done.
32 test-tool progress <in 2>stderr &&
34 show_cr <stderr >out &&
38 test_expect_success
'progress display with total' '
39 cat >expect <<-\EOF &&
40 Working hard: 33% (1/3)<CR>
41 Working hard: 66% (2/3)<CR>
42 Working hard: 100% (3/3)<CR>
43 Working hard: 100% (3/3), done.
53 test-tool progress <in 2>stderr &&
55 show_cr <stderr >out &&
59 test_expect_success
'progress display breaks long lines #1' '
60 sed -e "s/Z$//" >expect <<\EOF &&
61 Working hard.......2.........3.........4.........5.........6: 0% (100/100000)<CR>
62 Working hard.......2.........3.........4.........5.........6: 1% (1000/100000)<CR>
63 Working hard.......2.........3.........4.........5.........6: Z
64 10% (10000/100000)<CR>
65 100% (100000/100000)<CR>
66 100% (100000/100000), done.
70 start 100000 Working hard.......2.........3.........4.........5.........6
77 test-tool progress <in 2>stderr &&
79 show_cr <stderr >out &&
83 test_expect_success
'progress display breaks long lines #2' '
84 # Note: we do not need that many spaces after the title to cover up
85 # the last line before breaking the progress line.
86 sed -e "s/Z$//" >expect <<\EOF &&
87 Working hard.......2.........3.........4.........5.........6: 0% (1/100000)<CR>
88 Working hard.......2.........3.........4.........5.........6: 0% (2/100000)<CR>
89 Working hard.......2.........3.........4.........5.........6: Z
90 10% (10000/100000)<CR>
91 100% (100000/100000)<CR>
92 100% (100000/100000), done.
96 start 100000 Working hard.......2.........3.........4.........5.........6
105 test-tool progress <in 2>stderr &&
107 show_cr <stderr >out &&
111 test_expect_success
'progress display breaks long lines #3 - even the first is too long' '
112 # Note: we do not actually need any spaces at the end of the title
113 # line, because there is no previous progress line to cover up.
114 sed -e "s/Z$//" >expect <<\EOF &&
115 Working hard.......2.........3.........4.........5.........6: Z
116 25% (25000/100000)<CR>
117 50% (50000/100000)<CR>
118 75% (75000/100000)<CR>
119 100% (100000/100000)<CR>
120 100% (100000/100000), done.
124 start 100000 Working hard.......2.........3.........4.........5.........6
131 test-tool progress <in 2>stderr &&
133 show_cr <stderr >out &&
137 test_expect_success
'progress display breaks long lines #4 - title line matches terminal width' '
138 cat >expect <<\EOF &&
139 Working hard.......2.........3.........4.........5.........6.........7.........:
140 25% (25000/100000)<CR>
141 50% (50000/100000)<CR>
142 75% (75000/100000)<CR>
143 100% (100000/100000)<CR>
144 100% (100000/100000), done.
148 start 100000 Working hard.......2.........3.........4.........5.........6.........7.........
155 test-tool progress <in 2>stderr &&
157 show_cr <stderr >out &&
161 # Progress counter goes backwards, this should not happen in practice.
162 test_expect_success
'progress shortens - crazy caller' '
163 cat >expect <<-\EOF &&
164 Working hard: 10% (100/1000)<CR>
165 Working hard: 20% (200/1000)<CR>
166 Working hard: 0% (1/1000) <CR>
167 Working hard: 100% (1000/1000)<CR>
168 Working hard: 100% (1000/1000), done.
179 test-tool progress <in 2>stderr &&
181 show_cr <stderr >out &&
185 test_expect_success
'progress display with throughput' '
186 cat >expect <<-\EOF &&
188 Working hard: 20, 200.00 KiB | 100.00 KiB/s<CR>
189 Working hard: 30, 300.00 KiB | 100.00 KiB/s<CR>
190 Working hard: 40, 400.00 KiB | 100.00 KiB/s<CR>
191 Working hard: 40, 400.00 KiB | 100.00 KiB/s, done.
196 throughput 102400 1000
199 throughput 204800 2000
202 throughput 307200 3000
205 throughput 409600 4000
210 test-tool progress <in 2>stderr &&
212 show_cr <stderr >out &&
216 test_expect_success
'progress display with throughput and total' '
217 cat >expect <<-\EOF &&
218 Working hard: 25% (10/40)<CR>
219 Working hard: 50% (20/40), 200.00 KiB | 100.00 KiB/s<CR>
220 Working hard: 75% (30/40), 300.00 KiB | 100.00 KiB/s<CR>
221 Working hard: 100% (40/40), 400.00 KiB | 100.00 KiB/s<CR>
222 Working hard: 100% (40/40), 400.00 KiB | 100.00 KiB/s, done.
227 throughput 102400 1000
229 throughput 204800 2000
231 throughput 307200 3000
233 throughput 409600 4000
237 test-tool progress <in 2>stderr &&
239 show_cr <stderr >out &&
243 test_expect_success
'cover up after throughput shortens' '
244 cat >expect <<-\EOF &&
246 Working hard: 2, 800.00 KiB | 400.00 KiB/s<CR>
247 Working hard: 3, 1.17 MiB | 400.00 KiB/s <CR>
248 Working hard: 4, 1.56 MiB | 400.00 KiB/s<CR>
249 Working hard: 4, 1.56 MiB | 400.00 KiB/s, done.
254 throughput 409600 1000
257 throughput 819200 2000
260 throughput 1228800 3000
263 throughput 1638400 4000
268 test-tool progress <in 2>stderr &&
270 show_cr <stderr >out &&
274 test_expect_success
'cover up after throughput shortens a lot' '
275 cat >expect <<-\EOF &&
277 Working hard: 2, 1000.00 KiB | 1000.00 KiB/s<CR>
278 Working hard: 3, 3.00 MiB | 1.50 MiB/s <CR>
279 Working hard: 3, 3.00 MiB | 1024.00 KiB/s, done.
287 throughput 1024000 2000
290 throughput 3145728 3000
295 test-tool progress <in 2>stderr &&
297 show_cr <stderr >out &&
301 test_expect_success
'progress generates traces' '
304 throughput 102400 1000
307 throughput 204800 2000
310 throughput 307200 3000
313 throughput 409600 4000
319 GIT_TRACE2_EVENT="$(pwd)/trace.event" test-tool progress \
322 # t0212/parse_events.perl intentionally omits regions and data.
323 test_region progress "Working hard" trace.event &&
324 grep "\"key\":\"total_objects\",\"value\":\"40\"" trace.event &&
325 grep "\"key\":\"total_bytes\",\"value\":\"409600\"" trace.event
328 test_expect_success
'progress generates traces: stop / start' '
334 GIT_TRACE2_EVENT="$PWD/trace-startstop.event" test-tool progress \
336 test_region progress "Working hard" trace-startstop.event
339 test_expect_success
'progress generates traces: start without stop' '
344 GIT_TRACE2_EVENT="$PWD/trace-start.event" \
345 LSAN_OPTIONS=detect_leaks=0 \
348 grep region_enter.*progress trace-start.event &&
349 ! grep region_leave.*progress trace-start.event
352 test_expect_success
'progress generates traces: stop without start' '
357 GIT_TRACE2_EVENT="$PWD/trace-stop.event" test-tool progress \
359 ! grep region_enter.*progress trace-stop.event &&
360 ! grep region_leave.*progress trace-stop.event
363 test_expect_success
'progress generates traces: start with active progress bar (no stops)' '
369 GIT_TRACE2_EVENT="$PWD/trace-2start.event" \
370 LSAN_OPTIONS=detect_leaks=0 \
373 grep region_enter.*progress.*One trace-2start.event &&
374 grep region_enter.*progress.*Two trace-2start.event &&
375 ! grep region_leave trace-2start.event