internal/kokoro: don't use GOPATH, send logs to Build Cop Bot (#98)
diff --git a/internal/kokoro/test.sh b/internal/kokoro/test.sh
index c3d5c11..14d8a58 100755
--- a/internal/kokoro/test.sh
+++ b/internal/kokoro/test.sh
@@ -13,22 +13,39 @@
# Set $GOPATH
export GOPATH="$HOME/go"
-export GAX_HOME=$GOPATH/src/github.com/googleapis/gax-go
export PATH="$GOPATH/bin:$PATH"
export GO111MODULE=on
-mkdir -p $GAX_HOME
-
-# Move code into $GOPATH and get dependencies
-git clone . $GAX_HOME
-cd $GAX_HOME
try3() { eval "$*" || eval "$*" || eval "$*"; }
# All packages, including +build tools, are fetched.
try3 go mod download
./internal/kokoro/vet.sh
-go test -race -v . 2>&1 | tee $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt
+
+go get github.com/jstemmer/go-junit-report
+
+set +e
+
+go test -race -v . 2>&1 | tee sponge_log.log
+cat sponge_log.log | go-junit-report -set-exit-code > sponge_log.xml
+exit_code=$?
cd v2
+set -e
try3 go mod download
-go test -race -v . 2>&1 | tee $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt
+set +e
+
+go test -race -v . 2>&1 | tee sponge_log.log
+cat sponge_log.log | go-junit-report -set-exit-code > sponge_log.xml
+exit_code=$(($exit_code+$?))
+
+# Send logs to the Build Cop Bot for continuous builds.
+# TODO: uncomment when this works for the PR.
+# if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
+ cd ..
+ chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
+ $KOKORO_GFILE_DIR/linux_amd64/buildcop \
+ -repo=googleapis/gax-go # TODO delete after PR.
+# fi
+
+exit $exit_code