mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
termstatus: flush output before returning OutputRaw() writer
This prevents mangling the output due to delayed messages.
This commit is contained in:
@@ -180,6 +180,7 @@ func (t *Terminal) OutputWriter() io.Writer {
|
|||||||
// other option. Must not be used in combination with Print, Error, SetStatus
|
// other option. Must not be used in combination with Print, Error, SetStatus
|
||||||
// or any other method that writes to the terminal.
|
// or any other method that writes to the terminal.
|
||||||
func (t *Terminal) OutputRaw() io.Writer {
|
func (t *Terminal) OutputRaw() io.Writer {
|
||||||
|
t.Flush()
|
||||||
return t.wr
|
return t.wr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ func TestReadPasswordTerminal(t *testing.T) {
|
|||||||
func TestRawInputOutput(t *testing.T) {
|
func TestRawInputOutput(t *testing.T) {
|
||||||
input := io.NopCloser(strings.NewReader("password"))
|
input := io.NopCloser(strings.NewReader("password"))
|
||||||
var output bytes.Buffer
|
var output bytes.Buffer
|
||||||
term := New(input, &output, io.Discard, false)
|
term, cancel := Setup(input, &output, io.Discard, false)
|
||||||
|
defer cancel()
|
||||||
rtest.Equals(t, input, term.InputRaw())
|
rtest.Equals(t, input, term.InputRaw())
|
||||||
rtest.Equals(t, false, term.InputIsTerminal())
|
rtest.Equals(t, false, term.InputIsTerminal())
|
||||||
rtest.Equals(t, &output, term.OutputRaw())
|
rtest.Equals(t, &output, term.OutputRaw())
|
||||||
|
|||||||
Reference in New Issue
Block a user