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