@@ -21,12 +21,23 @@ shopt -s globstar
21
21
22
22
DIFF_FROM=" "
23
23
24
- # `--only-diff-master will only run tests on project changes from the master branch.
24
+ # `--only-diff-master` will only run tests on project changes on the
25
+ # last common commit from the master branch.
25
26
if [[ $* == * --only-diff-master* ]]; then
26
- DIFF_FROM=" origin/master.."
27
+ set +e
28
+ git diff --quiet " origin/master..." .kokoro/tests .kokoro/docker \
29
+ .kokoro/trampoline_v2.sh
30
+ CHANGED=$?
31
+ set -e
32
+ if [[ " ${CHANGED} " -eq 0 ]]; then
33
+ DIFF_FROM=" origin/master..."
34
+ else
35
+ echo " Changes to test driver files detected. Running full tests."
36
+ fi
27
37
fi
28
38
29
- # `--only-diff-master will only run tests on project changes from the previous commit.
39
+ # `--only-diff-head` will only run tests on project changes from the
40
+ # previous commit.
30
41
if [[ $* == * --only-diff-head* ]]; then
31
42
DIFF_FROM=" HEAD~.."
32
43
fi
@@ -83,16 +94,6 @@ set +e
83
94
RTN=0
84
95
ROOT=$( pwd)
85
96
86
- # If some files in .kokoro directory have any changes, we will test everything.
87
- test_all=" true"
88
- if [[ -n " ${DIFF_FROM:- } " ]]; then
89
- git diff --quiet " $DIFF_FROM " .kokoro/docker .kokoro/tests
90
- CHANGED=$?
91
- if [[ " $CHANGED " -eq 0 ]]; then
92
- test_all=" false"
93
- fi
94
- fi
95
-
96
97
# Find all requirements.txt in the repository (may break on whitespace).
97
98
for file in ** /requirements.txt; do
98
99
cd " $ROOT "
@@ -131,7 +132,7 @@ for file in **/requirements.txt; do
131
132
fi
132
133
fi
133
134
# If $DIFF_FROM is set, use it to check for changes in this directory.
134
- if [[ -n " ${DIFF_FROM:- } " ]] && [[ " ${test_all} " == " false " ]] ; then
135
+ if [[ -n " ${DIFF_FROM:- } " ]]; then
135
136
git diff --quiet " $DIFF_FROM " .
136
137
CHANGED=$?
137
138
if [[ " $CHANGED " -eq 0 ]]; then
0 commit comments