mirror of
https://github.com/restic/restic.git
synced 2025-10-19 07:33:21 +00:00
termstatus: flush output before returning OutputRaw() writer
This prevents mangling the output due to delayed messages.
This commit is contained in:
parent
f17027eeaa
commit
30ed992af9
2 changed files with 3 additions and 1 deletions
|
@ -180,6 +180,7 @@ func (t *Terminal) OutputWriter() io.Writer {
|
|||
// other option. Must not be used in combination with Print, Error, SetStatus
|
||||
// or any other method that writes to the terminal.
|
||||
func (t *Terminal) OutputRaw() io.Writer {
|
||||
t.Flush()
|
||||
return t.wr
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,8 @@ func TestReadPasswordTerminal(t *testing.T) {
|
|||
func TestRawInputOutput(t *testing.T) {
|
||||
input := io.NopCloser(strings.NewReader("password"))
|
||||
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, false, term.InputIsTerminal())
|
||||
rtest.Equals(t, &output, term.OutputRaw())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue