mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests: Backport RunUtilCompletion
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
parent
00e1e5db21
commit
2eeb26083f
@ -149,6 +149,11 @@ func (ep *ExpectProcess) Signal(sig os.Signal) error {
|
||||
return ep.cmd.Process.Signal(sig)
|
||||
}
|
||||
|
||||
// Wait waits for the process to finish.
|
||||
func (ep *ExpectProcess) Wait() {
|
||||
ep.wg.Wait()
|
||||
}
|
||||
|
||||
// Close waits for the expect process to exit.
|
||||
// Close currently does not return error if process exited with !=0 status.
|
||||
// TODO: Close should expose underlying proces failure by default.
|
||||
|
@ -78,6 +78,21 @@ func spawnWithExpectLines(args []string, envVars map[string]string, xs ...string
|
||||
return lines, perr
|
||||
}
|
||||
|
||||
func runUtilCompletion(args []string, envVars map[string]string) ([]string, error) {
|
||||
proc, err := spawnCmd(args, envVars)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to spawn command %v with error: %w", args, err)
|
||||
}
|
||||
|
||||
proc.Wait()
|
||||
err = proc.Close()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to close command %v with error: %w", args, err)
|
||||
}
|
||||
|
||||
return proc.Lines(), nil
|
||||
}
|
||||
|
||||
func randomLeaseID() int64 {
|
||||
return rand.New(rand.NewSource(time.Now().UnixNano())).Int63()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user