Skip to content

Commit

Permalink
Update PR tests to complete all tests before returning results. (#1065)
Browse files Browse the repository at this point in the history
* Return results of all tests.

* Use for loop instead of while.
  • Loading branch information
kurtisvg authored and lesv committed Mar 17, 2018
1 parent 5559f18 commit 8160953
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions .kokoro/tests/diff_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,47 @@ 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 "<modules>" pom.xml -c)
set -e

# Check for changes to the current folder
if [ "$CHANGED" -eq 1 ] && [ "$PARENT" -eq 0 ]; then
echo "------------------------------------------------------------"
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

0 comments on commit 8160953

Please sign in to comment.