Add tests for status output
Test: status_test.go Change-Id: If3febd8fdacb0e70716d0520a41c982bd6474720
This commit is contained in:
@@ -29,6 +29,8 @@ func isTerminal(w io.Writer) bool {
|
||||
ioctlGetTermios, uintptr(unsafe.Pointer(&termios)),
|
||||
0, 0, 0)
|
||||
return err == 0
|
||||
} else if _, ok := w.(*fakeSmartTerminal); ok {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -43,6 +45,8 @@ func termWidth(w io.Writer) (int, bool) {
|
||||
syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&winsize)),
|
||||
0, 0, 0)
|
||||
return int(winsize.ws_column), err == 0
|
||||
} else if f, ok := w.(*fakeSmartTerminal); ok {
|
||||
return f.termWidth, true
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
@@ -99,3 +103,8 @@ func stripAnsiEscapes(input []byte) []byte {
|
||||
|
||||
return input
|
||||
}
|
||||
|
||||
type fakeSmartTerminal struct {
|
||||
bytes.Buffer
|
||||
termWidth int
|
||||
}
|
||||
|
Reference in New Issue
Block a user