Skip to content

Commit

Permalink
Make rpctest exec path compatible with modules
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacia committed Aug 21, 2019
1 parent 7f4ad12 commit 25c2c60
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/gcash/bchd
go 1.12

require (
github.com/OpenBazaar/jsonpb v0.0.0-20171123000858-37d32ddf4eef // indirect
github.com/aead/siphash v1.0.1 // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd
github.com/btcsuite/goleveldb v1.0.0
Expand All @@ -26,7 +25,7 @@ require (
github.com/stretchr/testify v1.3.0 // indirect
github.com/zquestz/grab v0.0.0-20190224022517-abcee96e61b1
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect
golang.org/x/sys v0.0.0-20190412213103-97732733099d // indirect
golang.org/x/text v0.3.0
google.golang.org/appengine v1.4.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OpenBazaar/jsonpb v0.0.0-20171123000858-37d32ddf4eef h1:+aqKrHtCJTRp8ziyrjfHbTF5puPQZfgRt65+iM7FD2w=
github.com/OpenBazaar/jsonpb v0.0.0-20171123000858-37d32ddf4eef/go.mod h1:55mCznBcN9WQgrtgaAkv+p2LxeW/tQRdidyyE9D0I5k=
github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw=
Expand Down
18 changes: 2 additions & 16 deletions integration/rpctest/bchd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package rpctest

import (
"fmt"
"go/build"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -45,29 +44,16 @@ func bchdExecutablePath() (string, error) {
return "", err
}

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

// Build bchd and output an executable in a static temp path.
outputPath := filepath.Join(testDir, "bchd")
if runtime.GOOS == "windows" {
outputPath += ".exe"
}

cmd := exec.Command("go", "build", "-o", outputPath, bchdPkg.ImportPath)
cmd := exec.Command("go", "build", "-o", outputPath, "github.com/gcash/bchd")
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
err = cmd.Run()
if err != nil {
return "", fmt.Errorf("Failed to build bchd: %v", err)
return "", fmt.Errorf("failed to build bchd: %v", err)
}

// Save executable path so future calls do not recompile.
Expand Down
2 changes: 1 addition & 1 deletion integration/rpctest/rpc_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func generateListeningAddresses() (string, string) {

// baseDir is the directory path of the temp directory for all rpctest files.
func baseDir() (string, error) {
dirPath := filepath.Join(os.TempDir())
dirPath := filepath.Join(os.TempDir(), "bchd", "rpctest")
err := os.MkdirAll(dirPath, os.ModePerm)
return dirPath, err
}

0 comments on commit 25c2c60

Please sign in to comment.