tests: Configure coverage binary paths via init
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>dependabot/go_modules/go.uber.org/atomic-1.10.0
parent
d3b9951126
commit
89a1e7978c
|
@ -25,9 +25,13 @@ import (
|
|||
"go.etcd.io/etcd/tests/v3/framework/e2e"
|
||||
)
|
||||
|
||||
func TestCtlV3CompletionBash(t *testing.T) { testShellCompletion(t, e2e.BinPath.Etcdctl, "bash") }
|
||||
func TestCtlV3CompletionBash(t *testing.T) {
|
||||
testShellCompletion(t, e2e.BinPath.Etcdctl, "bash")
|
||||
}
|
||||
|
||||
func TestUtlV3CompletionBash(t *testing.T) { testShellCompletion(t, e2e.BinPath.Etcdutl, "bash") }
|
||||
func TestUtlV3CompletionBash(t *testing.T) {
|
||||
testShellCompletion(t, e2e.BinPath.Etcdutl, "bash")
|
||||
}
|
||||
|
||||
func testShellCompletion(t *testing.T, binPath, shellName string) {
|
||||
e2e.BeforeTest(t)
|
||||
|
|
|
@ -22,6 +22,10 @@ import (
|
|||
"go.etcd.io/etcd/pkg/v3/expect"
|
||||
)
|
||||
|
||||
var (
|
||||
initBinPath func(string) binPath
|
||||
)
|
||||
|
||||
func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
|
||||
return SpawnNamedCmd(strings.Join(args, "_"), args, envVars)
|
||||
}
|
||||
|
@ -29,11 +33,3 @@ func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess,
|
|||
func SpawnNamedCmd(processName string, args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
|
||||
return SpawnCmdWithLogger(zap.NewNop(), args, envVars, processName)
|
||||
}
|
||||
|
||||
func initBinPath(binDir string) binPath {
|
||||
return binPath{
|
||||
Etcd: binDir + "/etcd",
|
||||
Etcdctl: binDir + "/etcdctl",
|
||||
Etcdutl: binDir + "/etcdutl",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package e2e
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
||||
|
@ -35,17 +34,21 @@ var (
|
|||
coverDir = testutils.MustAbsPath(os.Getenv("COVERDIR"))
|
||||
)
|
||||
|
||||
func init() {
|
||||
initBinPath = initBinPathCov
|
||||
}
|
||||
|
||||
func initBinPathCov(binDir string) binPath {
|
||||
return binPath{
|
||||
Etcd: binDir + "/etcd_test",
|
||||
Etcdctl: binDir + "/etcdctl_test",
|
||||
Etcdutl: binDir + "/etcdutl_test",
|
||||
}
|
||||
}
|
||||
|
||||
func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string, name string) (*expect.ExpectProcess, error) {
|
||||
cmd := args[0]
|
||||
env := mergeEnvVariables(envVars)
|
||||
switch {
|
||||
case strings.HasSuffix(cmd, "/etcd"):
|
||||
cmd = cmd + "_test"
|
||||
case strings.HasSuffix(cmd, "/etcdctl"):
|
||||
cmd = cmd + "_test"
|
||||
case strings.HasSuffix(cmd, "/etcdutl"):
|
||||
cmd = cmd + "_test"
|
||||
}
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
|
|
|
@ -18,14 +18,27 @@
|
|||
package e2e
|
||||
|
||||
import (
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.etcd.io/etcd/pkg/v3/expect"
|
||||
)
|
||||
|
||||
const noOutputLineCount = 0 // regular binaries emit no extra lines
|
||||
|
||||
func init() {
|
||||
initBinPath = initBinPathNoCov
|
||||
}
|
||||
|
||||
func initBinPathNoCov(binDir string) binPath {
|
||||
return binPath{
|
||||
Etcd: binDir + "/etcd",
|
||||
Etcdctl: binDir + "/etcdctl",
|
||||
Etcdutl: binDir + "/etcdutl",
|
||||
}
|
||||
}
|
||||
|
||||
func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string, name string) (*expect.ExpectProcess, error) {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue