ui/progress: don't print progress on non-interactive terminals

This reverts to the old behavior of not printing progress updates on
non-interactive terminals. It was accidentally changed in #3058.
This commit is contained in:
Michael Eischer
2020-12-29 16:03:43 +01:00
parent a488d4c847
commit c2ef049f1b
4 changed files with 37 additions and 11 deletions
+19
View File
@@ -53,3 +53,22 @@ func TestCounterNil(t *testing.T) {
c.Add(1)
c.Done()
}
func TestCounterNoTick(t *testing.T) {
finalSeen := false
otherSeen := false
report := func(value uint64, d time.Duration, final bool) {
if final {
finalSeen = true
} else {
otherSeen = true
}
}
c := progress.New(0, report)
time.Sleep(time.Millisecond)
c.Done()
test.Assert(t, finalSeen, "final call did not happen")
test.Assert(t, !otherSeen, "unexpected status update")
}