Loading get.go +15 −11 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ const ( type Expect struct { // bytes.Buffer // mb.MutexBuffer stdin *mb.MutexBuffer stdout *mb.MutexBuffer stderr *mb.MutexBuffer stdin io.Reader stdout io.Writer stderr io.Writer matchStream chan struct { c Channel m Match Loading Loading @@ -91,9 +91,13 @@ func (x *Expect) Wait(c Channel, match, text string) error { func (x *Expect) worker(started chan<- bool) { var wg sync.WaitGroup x.stdin = &mb.MutexBuffer{} x.stdout = &mb.MutexBuffer{} x.stderr = &mb.MutexBuffer{} stdin := &mb.MutexBuffer{} stdout := &mb.MutexBuffer{} stderr := &mb.MutexBuffer{} x.stdin = stdin x.stdout = stdout x.stderr = stderr matchOutStream := make(chan Match) startedOutStream := make(chan bool) Loading @@ -116,7 +120,7 @@ func (x *Expect) worker(started chan<- bool) { go func() { defer wg.Done() process( x.stdout, x.stdin, stdout, startedOutStream, matchOutStream, stringStream, Loading @@ -125,7 +129,7 @@ func (x *Expect) worker(started chan<- bool) { go func() { defer wg.Done() process( x.stderr, x.stdin, stderr, startedErrStream, matchErrStream, stringStream, Loading Loading @@ -153,9 +157,11 @@ func (x *Expect) worker(started chan<- bool) { if !valid { continue } //stdin.Reset() stdin.Write([]byte(s)) //x.stdin.Reset() //x.stdin.Write([]byte(s)) io.WriteString(x.stdin, s) //io.WriteString(stdin, s) //fmt.Fprintln(x.stdin, s) case terminate, valid := <-x.terminateStream: if !valid { Loading Loading @@ -205,7 +211,6 @@ func (x *Expect) worker(started chan<- bool) { func process( in io.Reader, out io.Writer, startedStream chan<- bool, matchStream <-chan Match, stringStream chan<- string, Loading Loading @@ -245,7 +250,6 @@ func process( if !strings.Contains(s, m.p) { continue } //io.WriteString(out, m.v) go func(s string) { stringStream <- s }(m.v) Loading Loading
get.go +15 −11 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ const ( type Expect struct { // bytes.Buffer // mb.MutexBuffer stdin *mb.MutexBuffer stdout *mb.MutexBuffer stderr *mb.MutexBuffer stdin io.Reader stdout io.Writer stderr io.Writer matchStream chan struct { c Channel m Match Loading Loading @@ -91,9 +91,13 @@ func (x *Expect) Wait(c Channel, match, text string) error { func (x *Expect) worker(started chan<- bool) { var wg sync.WaitGroup x.stdin = &mb.MutexBuffer{} x.stdout = &mb.MutexBuffer{} x.stderr = &mb.MutexBuffer{} stdin := &mb.MutexBuffer{} stdout := &mb.MutexBuffer{} stderr := &mb.MutexBuffer{} x.stdin = stdin x.stdout = stdout x.stderr = stderr matchOutStream := make(chan Match) startedOutStream := make(chan bool) Loading @@ -116,7 +120,7 @@ func (x *Expect) worker(started chan<- bool) { go func() { defer wg.Done() process( x.stdout, x.stdin, stdout, startedOutStream, matchOutStream, stringStream, Loading @@ -125,7 +129,7 @@ func (x *Expect) worker(started chan<- bool) { go func() { defer wg.Done() process( x.stderr, x.stdin, stderr, startedErrStream, matchErrStream, stringStream, Loading Loading @@ -153,9 +157,11 @@ func (x *Expect) worker(started chan<- bool) { if !valid { continue } //stdin.Reset() stdin.Write([]byte(s)) //x.stdin.Reset() //x.stdin.Write([]byte(s)) io.WriteString(x.stdin, s) //io.WriteString(stdin, s) //fmt.Fprintln(x.stdin, s) case terminate, valid := <-x.terminateStream: if !valid { Loading Loading @@ -205,7 +211,6 @@ func (x *Expect) worker(started chan<- bool) { func process( in io.Reader, out io.Writer, startedStream chan<- bool, matchStream <-chan Match, stringStream chan<- string, Loading Loading @@ -245,7 +250,6 @@ func process( if !strings.Contains(s, m.p) { continue } //io.WriteString(out, m.v) go func(s string) { stringStream <- s }(m.v) Loading