From 90b5ee481b20a9c1d7acd66b2de6caec9c04a94d Mon Sep 17 00:00:00 2001 From: Kurtis Van Gent Date: Wed, 14 Feb 2018 11:12:33 -0800 Subject: [PATCH] Reduce noise in diff tests. --- .kokoro/tests/diff_tests.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.kokoro/tests/diff_tests.sh b/.kokoro/tests/diff_tests.sh index 5e15cf1ba1e..a300587c78e 100755 --- a/.kokoro/tests/diff_tests.sh +++ b/.kokoro/tests/diff_tests.sh @@ -27,7 +27,7 @@ mvn -v echo -e "\n ********** GRADLE INFO *********** " gradle -v -# Setup required enviormental variables +# Setup required environmental variables export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing source ${KOKORO_GFILE_DIR}/aws-secrets.sh @@ -37,35 +37,36 @@ gcloud auth activate-service-account\ --key-file=$GOOGLE_APPLICATION_CREDENTIALS \ --project=$GOOGLE_CLOUD_PROJECT -echo -e "\n******************** CHECKING FOR AFFECTED FOLDERS ********************" +echo -e "\n******************** TESTING AFFECTED PROJECTS ********************" # Diff to find out what has changed from master cd github/java-docs-samples -find ./*/ -name pom.xml -print0 | sort -z | while read -d $'\0' file +find * -name pom.xml -print0 | sort -z | while read -d $'\0' file do + # Navigate to project file=$(dirname "$file") - echo "------------------------------------------------------------" - echo "- checking $file" - echo "------------------------------------------------------------" - - pushd "$file" > /dev/null + set +e + # Only tests changed projects git diff --quiet master.. . - RTN=$? + CHANGED=$? + # Only test leafs to prevent testing twice + PARENT=$(grep "" pom.xml -c) set -e # Check for changes to the current folder - if [ "$RTN" -eq 1 ]; then - echo -e "\n Change detected. Running tests. \n " + if [ "$CHANGED" -eq 1 ] && [ "$PARENT" -eq 0 ]; then + echo "------------------------------------------------------------" + echo "- testing $file" + echo "------------------------------------------------------------" + 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 " Tests complete. \n" - else - echo -e "\n NO change found. \n" + echo -e "\n Tests complete. \n" fi popd > /dev/null