You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/testing/scenarios/server_env_coverage.go

34 lines
850 B

// +build coverage
package scenarios
import (
"os"
"os/exec"
"path/filepath"
8 years ago
"github.com/v2ray/v2ray-core/common/uuid"
)
func BuildV2Ray() error {
8 years ago
binaryPath := GetTestBinaryPath()
if _, err := os.Stat(binaryPath); err == nil {
return nil
}
cmd := exec.Command("go", "test", "-tags", "json coverage coveragemain", "-coverpkg", "github.com/v2ray/v2ray-core/...", "-c", "-o", binaryPath, GetSourcePath())
return cmd.Run()
}
func RunV2Ray(configFile string) *exec.Cmd {
8 years ago
binaryPath := GetTestBinaryPath()
covDir := filepath.Join(os.Getenv("GOPATH"), "out", "v2ray", "cov")
profile := uuid.New().String() + ".out"
proc := exec.Command(binaryPath, "-config", configFile, "-test.run", "TestRunMainForCoverage", "-test.coverprofile", profile, "-test.outputdir", covDir)
proc.Stderr = os.Stderr
proc.Stdout = os.Stdout
return proc
}