@@ -325,6 +325,7 @@ static struct progress *start_progress_delay(const char *title, uint64_t total,
progress->total = total;
progress->last_value = -1;
+ progress->last_update = -1;
progress->last_percent = -1;
progress->delay = delay;
progress->throughput = NULL;
@@ -393,6 +394,13 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
if (!progress)
return;
*p_progress = NULL;
+
+ if (progress->total &&
+ progress->total != progress->last_update)
+ BUG("total progress does not match for \"%*s\": expected: %"PRIuMAX" got: %"PRIuMAX,
+ (int)(progress->status_len_utf8), progress->title.buf,
+ (uintmax_t)progress->total,
+ (uintmax_t)progress->last_update);
if (progress->last_value != -1) {
/* Force the last update */
struct throughput *tp = progress->throughput;
@@ -96,7 +96,8 @@ Working hard.......2.........3.........4.........5.........6.........7:
0% (0/100), stalled.<CR>
1% (1/100) <CR>
50% (50/100)<CR>
- 50% (50/100), done.
+ 100% (100/100)<CR>
+ 100% (100/100), done.
EOF
cat >in <<-\EOF &&
@@ -104,6 +105,7 @@ EOF
signal
progress 1
progress 50
+ progress 100
stop
EOF
test-tool progress <in 2>stderr &&
@@ -423,4 +425,30 @@ test_expect_success 'BUG: start two concurrent progress bars' '
grep -E "^BUG: .*: should have no global_progress in set_progress_signal\(\)$" stderr
'
+test_expect_success 'BUG: display_progress() goes past declared "total"' '
+ cat >in <<-\EOF &&
+ start 3
+ progress 1
+ progress 2
+ progress 4
+ stop
+ EOF
+
+ test_must_fail test-tool progress <in 2>stderr &&
+ grep "BUG:.*total progress does not match" stderr
+'
+
+test_expect_success 'BUG: display_progress() does not reach declared "total"' '
+ cat >in <<-\EOF &&
+ start 5
+ progress 1
+ progress 2
+ progress 4
+ stop
+ EOF
+
+ test_must_fail test-tool progress <in 2>stderr &&
+ grep "BUG:.*total progress does not match" stderr
+'
+
test_done