mirror of https://github.com/status-im/consul.git
Merge pull request #1014 from hashicorp/sethvargo/control_out
Allow the user to control the output of the test server
This commit is contained in:
commit
89de575439
|
@ -59,6 +59,7 @@ type TestServerConfig struct {
|
|||
Bind string `json:"bind_addr,omitempty"`
|
||||
Addresses *TestAddressConfig `json:"addresses,omitempty"`
|
||||
Ports *TestPortConfig `json:"ports,omitempty"`
|
||||
Stdout, Stderr io.Writer `json:"-"`
|
||||
}
|
||||
|
||||
// ServerConfigCallback is a function interface which can be
|
||||
|
@ -165,10 +166,20 @@ func NewTestServerConfig(t *testing.T, cb ServerConfigCallback) *TestServer {
|
|||
}
|
||||
configFile.Close()
|
||||
|
||||
stdout := io.Writer(os.Stdout)
|
||||
if consulConfig.Stdout != nil {
|
||||
stdout = consulConfig.Stdout
|
||||
}
|
||||
|
||||
stderr := io.Writer(os.Stderr)
|
||||
if consulConfig.Stderr != nil {
|
||||
stderr = consulConfig.Stderr
|
||||
}
|
||||
|
||||
// Start the server
|
||||
cmd := exec.Command("consul", "agent", "-config-file", configFile.Name())
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = stdout
|
||||
cmd.Stderr = stderr
|
||||
if err := cmd.Start(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue