diff --git a/container_option.go b/container_option.go index 77b22f2..5d27d5f 100644 --- a/container_option.go +++ b/container_option.go @@ -86,6 +86,14 @@ } } +// ForceAutoRefresh force auto refresh even if output is not terminal. +// Useful for testing purposes. +func ForceAutoRefresh() ContainerOption { + return func(s *pState) { + s.forceAutoRefresh = true + } +} + // PopCompletedMode will pop completed bars to the top. // To stop rendering bar after it has been popped, use // mpb.BarRemoveOnComplete() option on that bar. diff --git a/progress.go b/progress.go index e58e0ca..416bff5 100644 --- a/progress.go +++ b/progress.go @@ -44,6 +44,7 @@ popPriority int popCompleted bool disableAutoRefresh bool + forceAutoRefresh bool manualRefresh chan interface{} renderDelay <-chan struct{} shutdownNotifier chan<- interface{} @@ -229,7 +230,7 @@ ch := make(chan time.Time) go func() { var autoRefresh <-chan time.Time - if isTerminal && !s.disableAutoRefresh { + if (isTerminal || s.forceAutoRefresh) && !s.disableAutoRefresh { if s.renderDelay != nil { <-s.renderDelay }