mirror of
https://github.com/status-im/consul.git
synced 2025-02-19 17:14:37 +00:00
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"`
|
Bind string `json:"bind_addr,omitempty"`
|
||||||
Addresses *TestAddressConfig `json:"addresses,omitempty"`
|
Addresses *TestAddressConfig `json:"addresses,omitempty"`
|
||||||
Ports *TestPortConfig `json:"ports,omitempty"`
|
Ports *TestPortConfig `json:"ports,omitempty"`
|
||||||
|
Stdout, Stderr io.Writer `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerConfigCallback is a function interface which can be
|
// ServerConfigCallback is a function interface which can be
|
||||||
@ -165,10 +166,20 @@ func NewTestServerConfig(t *testing.T, cb ServerConfigCallback) *TestServer {
|
|||||||
}
|
}
|
||||||
configFile.Close()
|
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
|
// Start the server
|
||||||
cmd := exec.Command("consul", "agent", "-config-file", configFile.Name())
|
cmd := exec.Command("consul", "agent", "-config-file", configFile.Name())
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = stderr
|
||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user