Merge pull request #1352 from halseth/import-path-rpctest
integration/rpctest: make exec path compatible with modules
This commit is contained in:
commit
b6c71b40a8
1 changed files with 3 additions and 14 deletions
|
@ -6,7 +6,6 @@ package rpctest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -44,24 +43,14 @@ func btcdExecutablePath() (string, error) {
|
||||||
return "", err
|
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.
|
// Build btcd and output an executable in a static temp path.
|
||||||
outputPath := filepath.Join(testDir, "btcd")
|
outputPath := filepath.Join(testDir, "btcd")
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
outputPath += ".exe"
|
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()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Failed to build btcd: %v", err)
|
return "", fmt.Errorf("Failed to build btcd: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue