update coverage

This commit is contained in:
v2ray committed 2016-08-09 22:13:16 +02:00
1 parent 5dc80a2cc5
commit 25b30704a4
4 files changed
+38 -42

No files matched your search

+10 -16
View File
@@ -1,7 +1,6 @@
package scenarios
import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -24,26 +23,20 @@ import (
var (
runningServers = make([]*exec.Cmd, 0, 10)
binaryPath string
)
func GetTestBinaryPath() string {
file := filepath.Join(os.Getenv("GOPATH"), "out", "v2ray", "v2ray.test")
if runtime.GOOS == "windows" {
file += ".exe"
}
return file
}
func GetSourcePath() string {
return filepath.Join("github.com", "v2ray", "v2ray-core", "shell", "point", "main")
}
func FillBinaryPath() error {
dir, err := ioutil.TempDir("", "v2ray")
if err != nil {
return err
}
binaryPath = filepath.Join(dir, "v2ray")
if runtime.GOOS == "windows" {
binaryPath += ".exe"
}
return nil
}
func TestFile(filename string) string {
return filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "v2ray", "v2ray-core", "testing", "scenarios", "data", filename)
}
@@ -89,7 +82,8 @@ func InitializeServer(configFile string) error {
func CloseAllServers() {
log.Info("Closing all servers.")
for _, server := range runningServers {
server.Process.Kill()
server.Process.Signal(os.Interrupt)
server.Process.Wait()
}
runningServers = make([]*exec.Cmd, 0, 10)
log.Info("All server closed.")
+8 -10
View File
@@ -6,28 +6,26 @@ import (
"os"
"os/exec"
"path/filepath"
"github.com/v2ray/v2ray-core/common/uuid"
)
func BuildV2Ray() error {
binaryPath := GetTestBinaryPath()
if _, err := os.Stat(binaryPath); err == nil {
return nil
}
if err := FillBinaryPath(); err != nil {
return err
}
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 {
profile := "coversingle.out"
wd, err := os.Getwd()
if err == nil {
profile = filepath.Join(wd, profile)
}
proc := exec.Command(binaryPath, "-config", configFile, "-test.run", "TestRunMainForCoverage", "-test.coverprofile", profile)
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
+3 -5
View File
@@ -8,20 +8,18 @@ import (
)
func BuildV2Ray() error {
binaryPath := GetTestBinaryPath()
if _, err := os.Stat(binaryPath); err == nil {
return nil
}
if err := FillBinaryPath(); err != nil {
return err
}
cmd := exec.Command("go", "build", "-tags=json", "-o="+binaryPath, GetSourcePath())
return cmd.Run()
}
func RunV2Ray(configFile string) *exec.Cmd {
proc := exec.Command(binaryPath, "-config="+configFile)
binaryPath := GetTestBinaryPath()
proc := exec.Command(binaryPath, "-config", configFile)
proc.Stderr = os.Stderr
proc.Stdout = os.Stdout