| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | #!/bin/bashif [ -n "${TRAVIS_TAG}" ]; then  exit 0fiFAIL=0V2RAY_OUT=${GOPATH}/out/v2rayV2RAY_COV=${V2RAY_OUT}/covCOVERAGE_FILE=${V2RAY_COV}/coverage.txtfunction test_package {  DIR="v2ray.com/core/$1"  DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',')  DEP=${DEP}$DIR  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}rm -rf ${V2RAY_OUT}mkdir -p ${V2RAY_COV}touch ${COVERAGE_FILE}TEST_FILES=(./*_test.go)if [ -f ${TEST_FILES[0]} ]; then  test_package ""fifor DIR in $(find * -type d -not -path "*.git*"); do  TEST_FILES=($DIR/*_test.go)  if [ -f ${TEST_FILES[0]} ]; then    test_package $DIR  fidonefor OUT_FILE in $(find ${V2RAY_COV} -name "*.out"); do  echo "Merging file ${OUT_FILE}"  cat ${OUT_FILE} | grep -v "mode: set" >> ${COVERAGE_FILE}doneCOV_SORTED=${V2RAY_COV}/coverallsorted.outcat ${COVERAGE_FILE} | sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" | grep -vw "vendor" > ${COV_SORTED}echo "mode: set" | cat - ${COV_SORTED} > ${COVERAGE_FILE}if [ "$FAIL" -eq 0 ]; then  echo "Uploading coverage datea to codecov."  bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} -v || echo "Codecov did not collect coverage reports."fiexit $FAIL
 |