Stop FIFO reader after terminal errors
This commit is contained in:
committed by
Brandon McGinty
parent
6aeab4fd5c
commit
41759b95f6
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.stormux.org/storm/barnard/gumble/gumble"
|
||||
@@ -15,6 +17,23 @@ func TestEscRemovesTerminalControlSequences(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type testReadCloser struct{ io.Reader }
|
||||
|
||||
func (testReadCloser) Close() error { return nil }
|
||||
|
||||
// Regression: an EOF from the FIFO was ignored and caused an unbounded busy
|
||||
// loop. The reader must deliver a final command then close its output.
|
||||
func TestReadFIFOStopsOnEOF(t *testing.T) {
|
||||
out := make(chan string)
|
||||
go readFIFO(testReadCloser{strings.NewReader("command\n")}, out)
|
||||
if got := <-out; got != "command" {
|
||||
t.Fatalf("got %q", got)
|
||||
}
|
||||
if _, ok := <-out; ok {
|
||||
t.Fatal("FIFO output remained open after EOF")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserChangeNotification(t *testing.T) {
|
||||
current := &gumble.Channel{ID: 1, Name: "Current"}
|
||||
other := &gumble.Channel{ID: 2, Name: "Other"}
|
||||
|
||||
Reference in New Issue
Block a user