mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
e2e: add "spawnWithExpectLines"
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
85533a6305
commit
b62e8291c2
13
e2e/util.go
13
e2e/util.go
@ -42,9 +42,14 @@ func spawnWithExpect(args []string, expected string) error {
|
||||
}
|
||||
|
||||
func spawnWithExpects(args []string, xs ...string) error {
|
||||
_, err := spawnWithExpectLines(args, xs...)
|
||||
return err
|
||||
}
|
||||
|
||||
func spawnWithExpectLines(args []string, xs ...string) ([]string, error) {
|
||||
proc, err := spawnCmd(args)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
// process until either stdout or stderr contains
|
||||
// the expected string
|
||||
@ -57,7 +62,7 @@ func spawnWithExpects(args []string, xs ...string) error {
|
||||
l, lerr := proc.ExpectFunc(lineFunc)
|
||||
if lerr != nil {
|
||||
proc.Close()
|
||||
return fmt.Errorf("%v (expected %q, got %q)", lerr, txt, lines)
|
||||
return nil, fmt.Errorf("%v (expected %q, got %q)", lerr, txt, lines)
|
||||
}
|
||||
lines = append(lines, l)
|
||||
if strings.Contains(l, txt) {
|
||||
@ -67,9 +72,9 @@ func spawnWithExpects(args []string, xs ...string) error {
|
||||
}
|
||||
perr := proc.Close()
|
||||
if len(xs) == 0 && proc.LineCount() != noOutputLineCount { // expect no output
|
||||
return fmt.Errorf("unexpected output (got lines %q, line count %d)", lines, proc.LineCount())
|
||||
return nil, fmt.Errorf("unexpected output (got lines %q, line count %d)", lines, proc.LineCount())
|
||||
}
|
||||
return perr
|
||||
return lines, perr
|
||||
}
|
||||
|
||||
func closeWithTimeout(p *expect.ExpectProcess, d time.Duration) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user