Redraw a finished bar below a warning for its last file (closes #102)
check / check (push) Waiting to run
check / check (push) Waiting to run
On a terminal, warnf clears the bar's line before it prints a warning. When the warning is for the last item of a phase, the bar has already drawn its finished frame and the progress library draws nothing more for a finished bar, so the warning took the bar's place for good. warnf now draws the finished bar's last frame again below the warning. Output when stderr is not a terminal does not change. Model: opus-5-5
This commit was merged in pull request #103.
This commit is contained in:
@@ -187,3 +187,25 @@ func TestBarStoppedShortKeepsCount(t *testing.T) {
|
||||
t.Errorf("terminal shows %q, want a count of 2 of 10", shown)
|
||||
}
|
||||
}
|
||||
|
||||
// TestWarningAfterLastItemKeepsBar checks that a warning printed after
|
||||
// a pass's last item, as for a failed read of the last file, leaves the
|
||||
// pass's finished bar on the terminal below the warning.
|
||||
//
|
||||
//nolint:paralleltest // captureStderr replaces the process-wide os.Stderr
|
||||
func TestWarningAfterLastItemKeepsBar(t *testing.T) {
|
||||
stderr := captureStderr(t)
|
||||
p := &progress{
|
||||
label: "hash", total: 2, start: time.Now(),
|
||||
bar: newBar("hash", 2),
|
||||
}
|
||||
|
||||
p.increment()
|
||||
p.increment()
|
||||
p.warnf("warning")
|
||||
p.finish()
|
||||
|
||||
if shown := lastFrame(stderr()); !strings.Contains(shown, "(2/2,") {
|
||||
t.Errorf("terminal shows %q, want a count of 2 of 2", shown)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user