MCPcopy
hub / github.com/docker/compose / TestPrintWithDimensions_MultipleRendersFit

Function TestPrintWithDimensions_MultipleRendersFit

cmd/display/tty_test.go:644–670  ·  cmd/display/tty_test.go::TestPrintWithDimensions_MultipleRendersFit

TestPrintWithDimensions_MultipleRendersFit verifies the cross-render aspect of docker/compose#13595: even a single overflowing line desyncs the cursor on the following tick because aec.Up(numLines) counts logical lines while the terminal wraps visual lines. Use many concurrent parent tasks with wide

(t *testing.T)

Source from the content-addressed store, hash-verified

642// loop can't bring every line under terminalWidth without dropping size
643// info from progress.
644func TestPrintWithDimensions_MultipleRendersFit(t *testing.T) {
645 w, buf := newTestWriter()
646 // Two parents so the truncation loop must walk multiple lines; 30 children
647 // per parent makes each progress bar wide enough that taskID truncation
648 // alone can't bring the line under terminalWidth.
649 for i := range 2 {
650 addParentWithDownloadingChildren(w,
651 "Image very-long-name-image-"+string(rune('a'+i))+":v1.2.3",
652 30, 100_000_000)
653 }
654
655 terminalWidth := 60
656 for tick := range 10 {
657 for _, t := range w.tasks {
658 if t.status == api.Working && t.total > 0 {
659 t.current = min(t.current+t.total/10, t.total)
660 }
661 }
662 buf.Reset()
663 w.printWithDimensions(terminalWidth, 24)
664 for i, line := range extractLines(buf) {
665 assert.Assert(t, lenAnsi(line) <= terminalWidth,
666 "tick %d line %d has length %d > terminalWidth %d: %q",
667 tick, i, lenAnsi(line), terminalWidth, line)
668 }
669 }
670}

Callers

nothing calls this directly

Calls 5

newTestWriterFunction · 0.85
extractLinesFunction · 0.85
printWithDimensionsMethod · 0.80
lenAnsiFunction · 0.70

Tested by

no test coverage detected