1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00
v2fly/testing/scenarios/server_env_coverage.go

34 lines
824 B
Go
Raw Normal View History

2016-08-08 18:55:36 -04:00
// +build coverage
package scenarios
import (
"os"
"os/exec"
2016-08-08 19:16:29 -04:00
"path/filepath"
2016-08-09 16:13:16 -04:00
2016-08-20 14:55:45 -04:00
"v2ray.com/core/common/uuid"
2016-08-08 18:55:36 -04:00
)
func BuildV2Ray() error {
2016-08-09 16:13:16 -04:00
binaryPath := GetTestBinaryPath()
2016-08-08 18:55:36 -04:00
if _, err := os.Stat(binaryPath); err == nil {
return nil
}
2016-08-20 14:55:45 -04:00
cmd := exec.Command("go", "test", "-tags", "json coverage coveragemain", "-coverpkg", "v2ray.com/core/...", "-c", "-o", binaryPath, GetSourcePath())
2016-08-08 18:55:36 -04:00
return cmd.Run()
}
func RunV2Ray(configFile string) *exec.Cmd {
2016-08-09 16:13:16 -04:00
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)
2016-08-08 18:55:36 -04:00
proc.Stderr = os.Stderr
proc.Stdout = os.Stdout
return proc
}