Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration/rpctest: make exec path compatible with modules #1352

Merged
merged 1 commit into from
Nov 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions integration/rpctest/btcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package rpctest

import (
"fmt"
"go/build"
"os/exec"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -44,24 +43,14 @@ func btcdExecutablePath() (string, error) {
return "", err
}

// Determine import path of this package. Not necessarily btcsuite/btcd if
// this is a forked repo.
_, rpctestDir, _, ok := runtime.Caller(1)
if !ok {
return "", fmt.Errorf("Cannot get path to btcd source code")
}
btcdPkgPath := filepath.Join(rpctestDir, "..", "..", "..")
btcdPkg, err := build.ImportDir(btcdPkgPath, build.FindOnly)
if err != nil {
return "", fmt.Errorf("Failed to build btcd: %v", err)
}

// Build btcd and output an executable in a static temp path.
outputPath := filepath.Join(testDir, "btcd")
if runtime.GOOS == "windows" {
outputPath += ".exe"
}
cmd := exec.Command("go", "build", "-o", outputPath, btcdPkg.ImportPath)
cmd := exec.Command(
"go", "build", "-o", outputPath, "github.com/btcsuite/btcd",
)
err = cmd.Run()
if err != nil {
return "", fmt.Errorf("Failed to build btcd: %v", err)
Expand Down