Skip to content

Commit

Permalink
Allow setting path to binary under test (#3410)
Browse files Browse the repository at this point in the history
  • Loading branch information
travisperson authored Oct 8, 2019
1 parent 9126ad8 commit f1d0cc1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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
7 changes: 6 additions & 1 deletion testhelpers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"os"
"sync"
"time"

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

// GetFreePort gets a free port from the kernel
Expand Down Expand Up @@ -36,7 +38,10 @@ func MustGetFilecoinBinary() string {

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

_, err := os.Stat(bin)
if err != nil {
Expand Down

0 comments on commit f1d0cc1

Please sign in to comment.