mirror of https://github.com/v2ray/v2ray-core
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.
37 lines
901 B
37 lines
901 B
8 years ago
|
// +build coverage
|
||
|
|
||
|
package scenarios
|
||
|
|
||
|
import (
|
||
8 years ago
|
"bytes"
|
||
8 years ago
|
"os"
|
||
|
"os/exec"
|
||
8 years ago
|
"path/filepath"
|
||
8 years ago
|
|
||
8 years ago
|
"v2ray.com/core/common/uuid"
|
||
8 years ago
|
)
|
||
|
|
||
|
func BuildV2Ray() error {
|
||
8 years ago
|
genTestBinaryPath()
|
||
8 years ago
|
if _, err := os.Stat(testBinaryPath); err == nil {
|
||
8 years ago
|
return nil
|
||
|
}
|
||
|
|
||
8 years ago
|
cmd := exec.Command("go", "test", "-tags", "json coverage coveragemain", "-coverpkg", "v2ray.com/core/...", "-c", "-o", testBinaryPath, GetSourcePath())
|
||
8 years ago
|
return cmd.Run()
|
||
|
}
|
||
|
|
||
8 years ago
|
func RunV2RayProtobuf(config []byte) *exec.Cmd {
|
||
8 years ago
|
genTestBinaryPath()
|
||
8 years ago
|
|
||
|
covDir := filepath.Join(os.Getenv("GOPATH"), "out", "v2ray", "cov")
|
||
|
os.MkdirAll(covDir, os.ModeDir)
|
||
|
profile := uuid.New().String() + ".out"
|
||
|
proc := exec.Command(testBinaryPath, "-config=stdin:", "-format=pb", "-test.run", "TestRunMainForCoverage", "-test.coverprofile", profile, "-test.outputdir", covDir)
|
||
|
proc.Stdin = bytes.NewBuffer(config)
|
||
|
proc.Stderr = os.Stderr
|
||
|
proc.Stdout = os.Stdout
|
||
|
|
||
|
return proc
|
||
|
}
|