github.com/xtls/xray-core@v1.8.12-0.20240518155711-3168d27b0bdb/testing/scenarios/common_regular.go (about) 1 //go:build !coverage 2 // +build !coverage 3 4 package scenarios 5 6 import ( 7 "bytes" 8 "fmt" 9 "os" 10 "os/exec" 11 ) 12 13 func BuildXray() error { 14 genTestBinaryPath() 15 if _, err := os.Stat(testBinaryPath); err == nil { 16 return nil 17 } 18 19 fmt.Printf("Building Xray into path (%s)\n", testBinaryPath) 20 cmd := exec.Command("go", "build", "-o="+testBinaryPath, GetSourcePath()) 21 cmd.Stdout = os.Stdout 22 cmd.Stderr = os.Stderr 23 return cmd.Run() 24 } 25 26 func RunXrayProtobuf(config []byte) *exec.Cmd { 27 genTestBinaryPath() 28 proc := exec.Command(testBinaryPath, "-config=stdin:", "-format=pb") 29 proc.Stdin = bytes.NewBuffer(config) 30 proc.Stderr = os.Stderr 31 proc.Stdout = os.Stdout 32 33 return proc 34 }