Skip to content

Commit

Permalink
Allow setting path to binary under test
Browse files Browse the repository at this point in the history
  • Loading branch information
travisperson committed Sep 11, 2019
1 parent 82937c7 commit 1f421fe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
12 changes: 12 additions & 0 deletions testhelpers/testflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ var unitTest = flag.Bool("unit", true, "Run the unit go tests")
var functionalTest = flag.Bool("functional", false, "Run the functional go tests")
var sectorBuilderTest = flag.Bool("sectorbuilder", false, "Run the sector builder tests")
var deploymentTest = flag.String("deployment", "", "Run the deployment tests against a network")
var binaryPath = flag.String("binary-path", "", "Run forked processes tests using provided binary")

// BinaryPath will return the path to the user provided binary. The call is expected to check if
// the return path points to an actual file. If the user did not provide a value an empty string
// will be returned along with a false for the second return value.
func BinaryPath() (string, bool) {
if len(*binaryPath) == 0 {
return "", false
}

return *binaryPath, true
}

// DeploymentTest will run the test its called from iff the `-deployment` flag
// is passed when calling `go test`. Otherwise the test will be skipped. DeploymentTest
Expand Down
16 changes: 11 additions & 5 deletions testhelpers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"time"

"github.com/mitchellh/go-homedir"

"github.com/filecoin-project/go-filecoin/testhelpers/testflags"
)

// GetFreePort gets a free port from the kernel
Expand Down Expand Up @@ -54,13 +56,17 @@ func MustGetFilecoinBinary() string {

// GetFilecoinBinary returns the path where the filecoin binary will be if it has been built
func GetFilecoinBinary() (string, error) {
gopath, err := GetGoPath()
if err != nil {
return "", err
bin, provided := testflags.BinaryPath()
if !provided {
gopath, err := GetGoPath()
if err != nil {
return "", err
}

bin = filepath.Join(gopath, "/src/github.com/filecoin-project/go-filecoin/go-filecoin")
}

bin := filepath.Join(gopath, "/src/github.com/filecoin-project/go-filecoin/go-filecoin")
_, err = os.Stat(bin)
_, err := os.Stat(bin)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 1f421fe

Please sign in to comment.