diff --git a/bar.go b/bar.go index 56718be..0fd9522 100644 --- a/bar.go +++ b/bar.go @@ -332,6 +332,11 @@ } } +// Wait blocks until bar is completed or aborted. +func (b *Bar) Wait() { + <-b.done +} + func (b *Bar) serve(ctx context.Context, bs *bState) { defer b.container.bwg.Done() if bs.afterBar != nil && bs.sync { diff --git a/progress_test.go b/progress_test.go index c17ce66..90ed3c4 100644 --- a/progress_test.go +++ b/progress_test.go @@ -30,6 +30,8 @@ } b.SetTotal(100, true) + + b.Wait() if count := p.BarCount(); count != 0 { t.Errorf("BarCount want: %d, got: %d\n", 0, count)