build_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "path/filepath"
  6. "testing"
  7. v2testing "github.com/v2ray/v2ray-core/testing"
  8. "github.com/v2ray/v2ray-core/testing/assert"
  9. )
  10. func cleanBinPath() {
  11. os.RemoveAll(binPath)
  12. os.Mkdir(binPath, os.ModeDir|0777)
  13. }
  14. func fileExists(file string) bool {
  15. _, err := os.Stat(file)
  16. return err == nil
  17. }
  18. func allFilesExists(files ...string) bool {
  19. for _, file := range files {
  20. fullPath := filepath.Join(binPath, file)
  21. if !fileExists(fullPath) {
  22. fmt.Println(fullPath + " doesn't exist.")
  23. return false
  24. }
  25. }
  26. return true
  27. }
  28. func TestBuildMacOS(t *testing.T) {
  29. v2testing.Current(t)
  30. binPath = filepath.Join(os.Getenv("GOPATH"), "testing")
  31. cleanBinPath()
  32. build("macos", "amd64", true, "test")
  33. assert.Bool(allFilesExists(
  34. "v2ray-macos.zip",
  35. "v2ray-test-macos",
  36. filepath.Join("v2ray-test-macos", "config.json"),
  37. filepath.Join("v2ray-test-macos", "v2ray"))).IsTrue()
  38. build("windows", "amd64", true, "test")
  39. assert.Bool(allFilesExists(
  40. "v2ray-windows-64.zip",
  41. "v2ray-test-windows-64",
  42. filepath.Join("v2ray-test-windows-64", "config.json"),
  43. filepath.Join("v2ray-test-windows-64", "v2ray.exe"))).IsTrue()
  44. build("linux", "amd64", true, "test")
  45. assert.Bool(allFilesExists(
  46. "v2ray-linux-64.zip",
  47. "v2ray-test-linux-64",
  48. filepath.Join("v2ray-test-linux-64", "vpoint_socks_vmess.json"),
  49. filepath.Join("v2ray-test-linux-64", "vpoint_vmess_freedom.json"),
  50. filepath.Join("v2ray-test-linux-64", "v2ray"))).IsTrue()
  51. }