Change testserver binary lookup
This commit is contained in:
parent
b8d92e868c
commit
7a958bdfdd
|
@ -24,6 +24,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/go-cleanhttp"
|
"github.com/hashicorp/go-cleanhttp"
|
||||||
|
"github.com/hashicorp/nomad/helper/discover"
|
||||||
)
|
)
|
||||||
|
|
||||||
// offset is used to atomically increment the port numbers.
|
// offset is used to atomically increment the port numbers.
|
||||||
|
@ -126,8 +127,9 @@ type TestServer struct {
|
||||||
// NewTestServer creates a new TestServer, and makes a call to
|
// NewTestServer creates a new TestServer, and makes a call to
|
||||||
// an optional callback function to modify the configuration.
|
// an optional callback function to modify the configuration.
|
||||||
func NewTestServer(t *testing.T, cb ServerConfigCallback) *TestServer {
|
func NewTestServer(t *testing.T, cb ServerConfigCallback) *TestServer {
|
||||||
if path, err := exec.LookPath("nomad"); err != nil || path == "" {
|
path, err := discover.NomadExecutable()
|
||||||
t.Skip("nomad not found on $PATH, skipping")
|
if err != nil {
|
||||||
|
t.Skipf("nomad not found, skipping: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dataDir, err := ioutil.TempDir("", "nomad")
|
dataDir, err := ioutil.TempDir("", "nomad")
|
||||||
|
@ -175,7 +177,7 @@ func NewTestServer(t *testing.T, cb ServerConfigCallback) *TestServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
cmd := exec.Command("nomad", args...)
|
cmd := exec.Command(path, args...)
|
||||||
cmd.Stdout = stdout
|
cmd.Stdout = stdout
|
||||||
cmd.Stderr = stderr
|
cmd.Stderr = stderr
|
||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue