mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
expect: EXPECT_DEBUG environment variable
Dump process output to stdout when EXPECT_DEBUG != "".
This commit is contained in:
parent
a42b399f4e
commit
cf382dbe60
@ -17,6 +17,7 @@ package expect
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -39,6 +40,8 @@ type ExpectProcess struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var printDebugLines = os.Getenv("EXPECT_DEBUG") != ""
|
||||||
|
|
||||||
// NewExpect creates a new process for expect testing.
|
// NewExpect creates a new process for expect testing.
|
||||||
func NewExpect(name string, arg ...string) (ep *ExpectProcess, err error) {
|
func NewExpect(name string, arg ...string) (ep *ExpectProcess, err error) {
|
||||||
ep = &ExpectProcess{cmd: exec.Command(name, arg...)}
|
ep = &ExpectProcess{cmd: exec.Command(name, arg...)}
|
||||||
@ -65,6 +68,9 @@ func (ep *ExpectProcess) read() {
|
|||||||
ep.mu.Lock()
|
ep.mu.Lock()
|
||||||
ep.err = rerr
|
ep.err = rerr
|
||||||
if l != "" {
|
if l != "" {
|
||||||
|
if printDebugLines {
|
||||||
|
fmt.Printf("%s-%d: %s", ep.cmd.Path, ep.cmd.Process.Pid, l)
|
||||||
|
}
|
||||||
ep.lines = append(ep.lines, l)
|
ep.lines = append(ep.lines, l)
|
||||||
ep.count++
|
ep.count++
|
||||||
if len(ep.lines) == 1 {
|
if len(ep.lines) == 1 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user