private/testcontext: remove version dependency
Change-Id: Ibabf5ec774dcdb1e4fc2f200368281c69b62e6c2
This commit is contained in:
parent
9ed9d3516f
commit
2daf24a1ea
@ -13,6 +13,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -54,7 +55,7 @@ func TestAutoUpdater(t *testing.T) {
|
||||
}
|
||||
|
||||
// build real bin with old version, will be used for both storagenode and updater
|
||||
oldBin := ctx.CompileWithVersion("storj.io/storj/cmd/storagenode-updater", oldInfo)
|
||||
oldBin := CompileWithVersion(ctx, "storj.io/storj/cmd/storagenode-updater", oldInfo)
|
||||
storagenodePath := ctx.File("fake", "storagenode.exe")
|
||||
copyBin(ctx, t, oldBin, storagenodePath)
|
||||
|
||||
@ -68,7 +69,7 @@ func TestAutoUpdater(t *testing.T) {
|
||||
Version: newSemVer,
|
||||
Release: false,
|
||||
}
|
||||
newBin := ctx.CompileWithVersion("storj.io/storj/cmd/storagenode-updater", newInfo)
|
||||
newBin := CompileWithVersion(ctx, "storj.io/storj/cmd/storagenode-updater", newInfo)
|
||||
|
||||
updateBins := map[string]string{
|
||||
"storagenode": newBin,
|
||||
@ -128,6 +129,18 @@ func TestAutoUpdater(t *testing.T) {
|
||||
require.NotZero(t, backupUpdaterInfo.Size())
|
||||
}
|
||||
|
||||
// CompileWithVersion compiles the specified package with the version variables set
|
||||
// to the passed version info values and returns the executable name.
|
||||
func CompileWithVersion(ctx *testcontext.Context, pkg string, info version.Info) string {
|
||||
ldFlagsX := map[string]string{
|
||||
"storj.io/storj/private/version.buildTimestamp": strconv.Itoa(int(info.Timestamp.Unix())),
|
||||
"storj.io/storj/private/version.buildCommitHash": info.CommitHash,
|
||||
"storj.io/storj/private/version.buildVersion": info.Version.String(),
|
||||
"storj.io/storj/private/version.buildRelease": strconv.FormatBool(info.Release),
|
||||
}
|
||||
return ctx.CompileWithLDFlagsX(pkg, ldFlagsX)
|
||||
}
|
||||
|
||||
func move(t *testing.T, src, dst string) {
|
||||
err := os.Rename(src, dst)
|
||||
require.NoError(t, err)
|
||||
|
@ -9,10 +9,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"storj.io/storj/private/version"
|
||||
)
|
||||
|
||||
// CLibMath is the standard C math library (see `man math.h`).
|
||||
@ -63,21 +60,6 @@ func (ctx *Context) Compile(pkg string, preArgs ...string) string {
|
||||
return exe
|
||||
}
|
||||
|
||||
// CompileWithVersion compiles the specified package with the version variables set
|
||||
// to the passed version info values and returns the executable name.
|
||||
func (ctx *Context) CompileWithVersion(pkg string, info version.Info) string {
|
||||
ctx.test.Helper()
|
||||
|
||||
ldFlagsX := map[string]string{
|
||||
"storj.io/storj/private/version.buildTimestamp": strconv.Itoa(int(info.Timestamp.Unix())),
|
||||
"storj.io/storj/private/version.buildCommitHash": info.CommitHash,
|
||||
"storj.io/storj/private/version.buildVersion": info.Version.String(),
|
||||
"storj.io/storj/private/version.buildRelease": strconv.FormatBool(info.Release),
|
||||
}
|
||||
|
||||
return ctx.CompileWithLDFlagsX(pkg, ldFlagsX)
|
||||
}
|
||||
|
||||
// CompileWithLDFlagsX compiles the specified package with the -ldflags flag set to
|
||||
// "-s -w [-X <key>=<value>,...]" given the passed map and returns the executable name.
|
||||
func (ctx *Context) CompileWithLDFlagsX(pkg string, ldFlagsX map[string]string) string {
|
||||
|
Loading…
Reference in New Issue
Block a user