v2ray-core/tools/build/build_test.go

58 lines
1.4 KiB
Go
Raw Normal View History

2015-11-04 16:52:59 +00:00
package main
import (
2015-11-04 20:20:06 +00:00
"fmt"
2016-11-17 23:01:37 +00:00
"io/ioutil"
2015-11-04 16:52:59 +00:00
"os"
2015-11-04 20:20:06 +00:00
"path/filepath"
2015-11-04 16:52:59 +00:00
"testing"
2016-08-20 18:55:45 +00:00
"v2ray.com/core/testing/assert"
2015-11-04 16:52:59 +00:00
)
2015-11-04 20:20:06 +00:00
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
}
2015-11-04 16:52:59 +00:00
func TestBuildMacOS(t *testing.T) {
2016-05-24 19:55:46 +00:00
assert := assert.On(t)
2016-11-17 23:01:37 +00:00
tmpPath, err := ioutil.TempDir("", "v2ray")
assert.Error(err).IsNil()
binPath = tmpPath
2015-11-04 16:52:59 +00:00
build("macos", "amd64", true, "test", "metadata.txt")
2015-11-04 20:20:06 +00:00
assert.Bool(allFilesExists(
"v2ray-macos.zip",
"v2ray-test-macos",
filepath.Join("v2ray-test-macos", "config.json"),
filepath.Join("v2ray-test-macos", "v2ray"))).IsTrue()
2015-11-04 16:52:59 +00:00
build("windows", "amd64", true, "test", "metadata.txt")
2015-11-04 20:20:06 +00:00
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()
2015-11-04 16:52:59 +00:00
build("linux", "amd64", true, "test", "metadata.txt")
2015-11-04 20:20:06 +00:00
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()
2015-11-04 16:52:59 +00:00
}