1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/tools/build/build_test.go
2015-11-04 21:20:06 +01:00

60 lines
1.4 KiB
Go

package main
import (
"fmt"
"os"
"path/filepath"
"testing"
"github.com/v2ray/v2ray-core/testing/unit"
)
func cleanBinPath() {
os.RemoveAll(binPath)
os.Mkdir(binPath, os.ModeDir|0777)
}
func fileExists(file string) bool {
_, err := os.Stat(file)
return err == nil
}
func allFilesExists(files ...string) bool {
for _, file := range files {
fullPath := filepath.Join(binPath, file)
if !fileExists(fullPath) {
fmt.Println(fullPath + " doesn't exist.")
return false
}
}
return true
}
func TestBuildMacOS(t *testing.T) {
assert := unit.Assert(t)
binPath = filepath.Join(os.Getenv("GOPATH"), "testing")
cleanBinPath()
build("macos", "amd64", true, "test")
assert.Bool(allFilesExists(
"v2ray-macos.zip",
"v2ray-test-macos",
filepath.Join("v2ray-test-macos", "config.json"),
filepath.Join("v2ray-test-macos", "v2ray"))).IsTrue()
build("windows", "amd64", true, "test")
assert.Bool(allFilesExists(
"v2ray-windows-64.zip",
"v2ray-test-windows-64",
filepath.Join("v2ray-test-windows-64", "config.json"),
filepath.Join("v2ray-test-windows-64", "v2ray.exe"))).IsTrue()
build("linux", "amd64", true, "test")
assert.Bool(allFilesExists(
"v2ray-linux-64.zip",
"v2ray-test-linux-64",
filepath.Join("v2ray-test-linux-64", "vpoint_socks_vmess.json"),
filepath.Join("v2ray-test-linux-64", "vpoint_vmess_freedom.json"),
filepath.Join("v2ray-test-linux-64", "v2ray"))).IsTrue()
}