1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-26 09:25:23 +00:00
v2fly/testing/scenarios/server_env_coverage.go

35 lines
841 B
Go
Raw Normal View History

2016-08-08 22:55:36 +00:00
// +build coverage
package scenarios
import (
"os"
"os/exec"
2016-08-08 23:16:29 +00:00
"path/filepath"
2016-08-09 20:13:16 +00:00
2016-08-20 18:55:45 +00:00
"v2ray.com/core/common/uuid"
2016-08-08 22:55:36 +00:00
)
func BuildV2Ray() error {
2016-11-17 23:01:37 +00:00
GenTestBinaryPath()
if _, err := os.Stat(testBinaryPath); err == nil {
2016-08-08 22:55:36 +00:00
return nil
}
2016-11-17 23:01:37 +00:00
cmd := exec.Command("go", "test", "-tags", "json coverage coveragemain", "-coverpkg", "v2ray.com/core/...", "-c", "-o", testBinaryPath, GetSourcePath())
2016-08-08 22:55:36 +00:00
return cmd.Run()
}
func RunV2Ray(configFile string) *exec.Cmd {
2016-11-17 23:01:37 +00:00
GenTestBinaryPath()
2016-08-09 20:13:16 +00:00
covDir := filepath.Join(os.Getenv("GOPATH"), "out", "v2ray", "cov")
2016-11-17 23:31:59 +00:00
os.MkdirAll(covDir, os.ModeDir)
2016-08-09 20:13:16 +00:00
profile := uuid.New().String() + ".out"
2016-11-17 23:01:37 +00:00
proc := exec.Command(testBinaryPath, "-config", configFile, "-test.run", "TestRunMainForCoverage", "-test.coverprofile", profile, "-test.outputdir", covDir)
2016-08-08 22:55:36 +00:00
proc.Stderr = os.Stderr
proc.Stdout = os.Stdout
return proc
}