| 
									
										
										
										
											2015-09-07 21:22:43 +02:00
										 |  |  | #!/bin/bash | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-24 16:59:43 +02:00
										 |  |  | if [ -n "${TRAVIS_TAG}" ]; then | 
					
						
							| 
									
										
										
										
											2016-10-18 10:28:37 +02:00
										 |  |  |   exit 0 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-19 18:55:43 +02:00
										 |  |  | FAIL=0 | 
					
						
							| 
									
										
										
										
											2016-08-09 22:13:16 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | V2RAY_OUT=${GOPATH}/out/v2ray | 
					
						
							|  |  |  | V2RAY_COV=${V2RAY_OUT}/cov | 
					
						
							|  |  |  | COVERAGE_FILE=${V2RAY_COV}/coverage.txt | 
					
						
							| 
									
										
										
										
											2015-09-19 18:55:43 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | function test_package { | 
					
						
							| 
									
										
										
										
											2016-08-20 20:55:45 +02:00
										 |  |  |   DIR="v2ray.com/core/$1" | 
					
						
							| 
									
										
										
										
											2015-09-26 23:33:08 +02:00
										 |  |  |   DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',') | 
					
						
							| 
									
										
										
										
											2015-11-06 13:45:41 +01:00
										 |  |  |   DEP=${DEP}$DIR | 
					
						
							| 
									
										
										
										
											2016-08-09 22:13:16 +02:00
										 |  |  |   RND_NAME=$(openssl rand -hex 16) | 
					
						
							|  |  |  |   COV_PROFILE=${V2RAY_COV}/${RND_NAME}.out | 
					
						
							|  |  |  |   go test -tags "json coverage" -coverprofile=${COV_PROFILE} -coverpkg=$DEP $DIR || FAIL=1 | 
					
						
							| 
									
										
										
										
											2015-09-19 18:55:43 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-09 22:13:16 +02:00
										 |  |  | rm -rf ${V2RAY_OUT} | 
					
						
							|  |  |  | mkdir -p ${V2RAY_COV} | 
					
						
							| 
									
										
										
										
											2016-02-04 17:26:46 +01:00
										 |  |  | touch ${COVERAGE_FILE} | 
					
						
							| 
									
										
										
										
											2015-09-19 18:55:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-01 16:20:16 +02:00
										 |  |  | TEST_FILES=(./*_test.go) | 
					
						
							|  |  |  | if [ -f ${TEST_FILES[0]} ]; then | 
					
						
							|  |  |  |   test_package "" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-26 23:36:25 +02:00
										 |  |  | for DIR in $(find * -type d -not -path "*.git*"); do | 
					
						
							| 
									
										
										
										
											2015-09-26 23:33:08 +02:00
										 |  |  |   TEST_FILES=($DIR/*_test.go) | 
					
						
							|  |  |  |   if [ -f ${TEST_FILES[0]} ]; then | 
					
						
							|  |  |  |     test_package $DIR | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-09 22:13:16 +02:00
										 |  |  | for OUT_FILE in $(find ${V2RAY_COV} -name "*.out"); do | 
					
						
							|  |  |  |   echo "Merging file ${OUT_FILE}" | 
					
						
							|  |  |  |   cat ${OUT_FILE} | grep -v "mode: set" >> ${COVERAGE_FILE} | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | COV_SORTED=${V2RAY_COV}/coverallsorted.out | 
					
						
							| 
									
										
										
										
											2016-08-27 12:00:51 +02:00
										 |  |  | cat ${COVERAGE_FILE} | sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" > ${COV_SORTED} | 
					
						
							| 
									
										
										
										
											2016-08-09 22:13:16 +02:00
										 |  |  | echo "mode: set" | cat - ${COV_SORTED} > ${COVERAGE_FILE} | 
					
						
							| 
									
										
										
										
											2015-09-20 00:43:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-19 18:55:43 +02:00
										 |  |  | if [ "$FAIL" -eq 0 ]; then | 
					
						
							| 
									
										
										
										
											2016-02-04 17:26:46 +01:00
										 |  |  |   bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} || echo "Codecov did not collect coverage reports." | 
					
						
							| 
									
										
										
										
											2015-09-07 21:22:43 +02:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-19 18:55:43 +02:00
										 |  |  | exit $FAIL |