Skip to content

Commit 3209627

Browse files
committed
Update crdb binary path to absolute
The teamcity build for cockroachdb repo uses a relative path for setting a custom cockroach binary. This change resolves the relative path to an absolute path. This way updating the command's base directory does not impact the cockroach binary look up while running example-orm tests.
1 parent ddfadd9 commit 3209627

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

testserver/testserver.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ func NewTestServer(opts ...TestServerOpt) (TestServer, error) {
304304
var err error
305305
if serverArgs.cockroachBinary != "" {
306306
log.Printf("Using custom cockroach binary: %s", serverArgs.cockroachBinary)
307+
cockroachBinary, err := filepath.Abs(serverArgs.cockroachBinary)
308+
if err == nil {
309+
// Update path to absolute.
310+
serverArgs.cockroachBinary = cockroachBinary
311+
}
307312
} else {
308313
serverArgs.cockroachBinary, err = downloadBinary(&serverArgs.testConfig, serverArgs.nonStableDB)
309314
if err != nil {

testserver/testserver_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,18 @@ func TestRunServer(t *testing.T) {
189189
}
190190

191191
func TestCockroachBinaryPathOpt(t *testing.T) {
192-
_, err := testserver.NewTestServer(testserver.CockroachBinaryPathOpt("doesnotexist"))
192+
crdbBinary := "doesnotexist"
193+
_, err := testserver.NewTestServer(testserver.CockroachBinaryPathOpt(crdbBinary))
193194
if err == nil {
194195
t.Fatal("expected err, got nil")
195196
}
196-
wantSubstring := "command doesnotexist version failed"
197+
// Confirm that the command is updated to reference the absolute path
198+
// of the custom cockroachdb binary.
199+
cmdPath, fPathErr := filepath.Abs(crdbBinary)
200+
if fPathErr != nil {
201+
cmdPath = crdbBinary
202+
}
203+
wantSubstring := fmt.Sprintf("command %s version failed", cmdPath)
197204
if msg := err.Error(); !strings.Contains(msg, wantSubstring) {
198205
t.Fatalf("error message %q does not contain %q", msg, wantSubstring)
199206
}

0 commit comments

Comments
 (0)