mirror of
https://github.com/hymkor/lispect.git
synced 2026-09-02 15:17:49 -04:00
Fix: expect: When monitoring words were output in succession, the latter was sometimes overlooked
This commit is contained in:
@@ -77,6 +77,9 @@ func (W *Watcher) checkWords(token string, words []string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (W *Watcher) Expect(words ...string) int {
|
func (W *Watcher) Expect(words ...string) int {
|
||||||
|
if found := W.checkWords("", words); found >= 0 {
|
||||||
|
return found
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case token := <-W.ch:
|
case token := <-W.ch:
|
||||||
@@ -90,6 +93,10 @@ func (W *Watcher) Expect(words ...string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (W *Watcher) ExpectWithTimeout(d time.Duration, words ...string) int {
|
func (W *Watcher) ExpectWithTimeout(d time.Duration, words ...string) int {
|
||||||
|
if found := W.checkWords("", words); found >= 0 {
|
||||||
|
return found
|
||||||
|
}
|
||||||
|
|
||||||
timer := time.NewTimer(d)
|
timer := time.NewTimer(d)
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user