server_env_coverage.go 644 B

1234567891011121314151617181920212223242526272829
  1. // +build coverage
  2. package scenarios
  3. import (
  4. "os"
  5. "os/exec"
  6. )
  7. func BuildV2Ray() error {
  8. if _, err := os.Stat(binaryPath); err == nil {
  9. return nil
  10. }
  11. if err := FillBinaryPath(); err != nil {
  12. return err
  13. }
  14. cmd := exec.Command("go", "test", "-tags", "json coverage coveragemain", "-coverpkg", "github.com/v2ray/v2ray-core/...", "-c", "-o", binaryPath, GetSourcePath())
  15. return cmd.Run()
  16. }
  17. func RunV2Ray(configFile string) *exec.Cmd {
  18. proc := exec.Command(binaryPath, "-config="+configFile, "-test.run=TestRunMainForCoverage", "-test.coverprofile=coversingle.out")
  19. proc.Stderr = os.Stderr
  20. proc.Stdout = os.Stdout
  21. return proc
  22. }