2015-11-04 11:52:59 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-11-04 15:20:06 -05:00
|
|
|
"fmt"
|
2015-11-04 11:52:59 -05:00
|
|
|
"os"
|
2015-11-04 15:20:06 -05:00
|
|
|
"path/filepath"
|
2015-11-04 11:52:59 -05:00
|
|
|
"testing"
|
|
|
|
|
2015-12-02 11:27:55 -05:00
|
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
2015-12-02 09:27:18 -05:00
|
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
2015-11-04 11:52:59 -05:00
|
|
|
)
|
|
|
|
|
2015-11-04 15:20:06 -05:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-11-04 11:52:59 -05:00
|
|
|
func TestBuildMacOS(t *testing.T) {
|
2015-12-02 09:27:18 -05:00
|
|
|
v2testing.Current(t)
|
2015-11-04 15:20:06 -05:00
|
|
|
binPath = filepath.Join(os.Getenv("GOPATH"), "testing")
|
|
|
|
cleanBinPath()
|
2015-11-04 11:52:59 -05:00
|
|
|
|
2015-12-27 17:27:39 -05:00
|
|
|
build("macos", "amd64", true, "test", "metadata.txt")
|
2015-11-04 15:20:06 -05: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 11:52:59 -05:00
|
|
|
|
2015-12-27 17:27:39 -05:00
|
|
|
build("windows", "amd64", true, "test", "metadata.txt")
|
2015-11-04 15:20:06 -05: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 11:52:59 -05:00
|
|
|
|
2015-12-27 17:27:39 -05:00
|
|
|
build("linux", "amd64", true, "test", "metadata.txt")
|
2015-11-04 15:20:06 -05: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 11:52:59 -05:00
|
|
|
}
|