From 8160953fc507e56c040bebe0babe6e102bff446b Mon Sep 17 00:00:00 2001 From: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> Date: Sat, 17 Mar 2018 11:01:51 -0700 Subject: [PATCH] Update PR tests to complete all tests before returning results. (#1065) * Return results of all tests. * Use for loop instead of while. --- .kokoro/tests/diff_tests.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.kokoro/tests/diff_tests.sh b/.kokoro/tests/diff_tests.sh index a300587c78e..0aeced3e33b 100755 --- a/.kokoro/tests/diff_tests.sh +++ b/.kokoro/tests/diff_tests.sh @@ -38,21 +38,21 @@ gcloud auth activate-service-account\ --project=$GOOGLE_CLOUD_PROJECT echo -e "\n******************** TESTING AFFECTED PROJECTS ********************" +set +e # Diff to find out what has changed from master +RESULT=0 cd github/java-docs-samples -find * -name pom.xml -print0 | sort -z | while read -d $'\0' file -do +# For every pom.xml (may break on whitespace) +for file in **/pom.xml; do # Navigate to project file=$(dirname "$file") pushd "$file" > /dev/null - set +e # Only tests changed projects git diff --quiet master.. . CHANGED=$? # Only test leafs to prevent testing twice PARENT=$(grep "" pom.xml -c) - set -e # Check for changes to the current folder if [ "$CHANGED" -eq 1 ] && [ "$PARENT" -eq 0 ]; then @@ -60,15 +60,25 @@ do echo "- testing $file" echo "------------------------------------------------------------" + # Run tests and update RESULT if failed mvn -q --batch-mode --fail-at-end clean verify \ -Dfile.encoding="UTF-8" \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -Dmaven.test.redirectTestOutputToFile=true \ -Dbigtable.projectID="${GOOGLE_CLOUD_PROJECT}" \ -Dbigtable.instanceID=instance - echo -e "\n Tests complete. \n" + EXIT=$? + + if [ $EXIT -ne 0 ]; then + echo -e "\n Tests failed. \n" + RESULT=1 + else + echo -e "\n Tests complete. \n" + fi fi popd > /dev/null done + +exit $RESULT