Skip to content

Commit 16c3ae1

Browse files
authored
Reduce noise in diff tests. (GoogleCloudPlatform#1030)
1 parent 6196418 commit 16c3ae1

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

.kokoro/tests/diff_tests.sh

+15-14
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mvn -v
2727
echo -e "\n ********** GRADLE INFO *********** "
2828
gradle -v
2929

30-
# Setup required enviormental variables
30+
# Setup required environmental variables
3131
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json
3232
export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing
3333
source ${KOKORO_GFILE_DIR}/aws-secrets.sh
@@ -37,35 +37,36 @@ gcloud auth activate-service-account\
3737
--key-file=$GOOGLE_APPLICATION_CREDENTIALS \
3838
--project=$GOOGLE_CLOUD_PROJECT
3939

40-
echo -e "\n******************** CHECKING FOR AFFECTED FOLDERS ********************"
40+
echo -e "\n******************** TESTING AFFECTED PROJECTS ********************"
4141
# Diff to find out what has changed from master
4242
cd github/java-docs-samples
43-
find ./*/ -name pom.xml -print0 | sort -z | while read -d $'\0' file
43+
find * -name pom.xml -print0 | sort -z | while read -d $'\0' file
4444
do
45+
# Navigate to project
4546
file=$(dirname "$file")
46-
echo "------------------------------------------------------------"
47-
echo "- checking $file"
48-
echo "------------------------------------------------------------"
49-
50-
5147
pushd "$file" > /dev/null
48+
5249
set +e
50+
# Only tests changed projects
5351
git diff --quiet master.. .
54-
RTN=$?
52+
CHANGED=$?
53+
# Only test leafs to prevent testing twice
54+
PARENT=$(grep "<modules>" pom.xml -c)
5555
set -e
5656

5757
# Check for changes to the current folder
58-
if [ "$RTN" -eq 1 ]; then
59-
echo -e "\n Change detected. Running tests. \n "
58+
if [ "$CHANGED" -eq 1 ] && [ "$PARENT" -eq 0 ]; then
59+
echo "------------------------------------------------------------"
60+
echo "- testing $file"
61+
echo "------------------------------------------------------------"
62+
6063
mvn -q --batch-mode --fail-at-end clean verify \
6164
-Dfile.encoding="UTF-8" \
6265
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
6366
-Dmaven.test.redirectTestOutputToFile=true \
6467
-Dbigtable.projectID="${GOOGLE_CLOUD_PROJECT}" \
6568
-Dbigtable.instanceID=instance
66-
echo -e " Tests complete. \n"
67-
else
68-
echo -e "\n NO change found. \n"
69+
echo -e "\n Tests complete. \n"
6970
fi
7071

7172
popd > /dev/null

0 commit comments

Comments
 (0)