Skip to content

Commit 2331dcc

Browse files
author
Takashi Matsuo
authored
Run through all the tests even if there's a failure (GoogleCloudPlatform#541)
* Run through all the tests even if there's a failure, create a summary report * Fixed syntax errors * Better summary report, continue when composer fails as well * Move `set -e` after evaluating the test result * Adding intentional failure in datastore/api * Remove the test for intentional failure
1 parent c527ff4 commit 2331dcc

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

testing/run_test_suite.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515

1616
set -ex
1717

18+
# directories known as flaky tests
19+
FLAKES=(
20+
datastore/api
21+
)
22+
23+
TMP_REPORT_DIR=$(mktemp -d)
24+
25+
SUCCEEDED_FILE=${TMP_REPORT_DIR}/succeeded
26+
FAILED_FILE=${TMP_REPORT_DIR}/failed
27+
FAILED_FLAKY_FILE=${TMP_REPORT_DIR}/failed_flaky
28+
1829
# Determine all files changed on this branch
1930
# (will be empty if running from "master").
2031
FILES_CHANGED=$(git diff --name-only HEAD $(git merge-base HEAD master))
@@ -44,19 +55,61 @@ do
4455
fi
4556
fi
4657
pushd ${DIR}
58+
# Temporarily allowing error
59+
set +e
4760
if [ -f "composer.json" ]; then
4861
# install composer dependencies
4962
${COMPOSER_COMMAND}
5063
fi
64+
if [ $? != 0 ]; then
65+
echo "${DIR}: failed" >> "${FAILED_FILE}"
66+
continue
67+
fi
5168
echo "running phpunit in ${DIR}"
5269
if [ -f "vendor/bin/phpunit" ]; then
5370
vendor/bin/phpunit
5471
else
5572
phpunit
5673
fi
74+
if [ $? == 0 ]; then
75+
echo "${DIR}: ok" >> "${SUCCEEDED_FILE}"
76+
else
77+
if [[ "${FLAKES[@]}" =~ "${DIR}" ]]; then
78+
echo "${DIR}: failed" >> "${FAILED_FLAKY_FILE}"
79+
else
80+
echo "${DIR}: failed" >> "${FAILED_FILE}"
81+
fi
82+
fi
83+
set -e
5784
if [ "$RUN_ALL_TESTS" -eq "1" ] && [ -f build/logs/clover.xml ]; then
5885
cp build/logs/clover.xml \
5986
${TEST_BUILD_DIR}/build/logs/clover-${DIR//\//_}.xml
6087
fi
6188
popd
6289
done
90+
91+
# Show the summary report
92+
set +x
93+
94+
if [ -f "${SUCCEEDED_FILE}" ]; then
95+
echo "--------- Succeeded tests -----------"
96+
cat "${SUCCEEDED_FILE}"
97+
echo "-------------------------------------"
98+
fi
99+
100+
if [ -f "${FAILED_FILE}" ]; then
101+
echo "--------- Failed tests --------------"
102+
cat "${FAILED_FILE}"
103+
echo "-------------------------------------"
104+
fi
105+
106+
if [ -f "${FAILED_FLAKY_FILE}" ]; then
107+
echo "-------- Failed flaky tests ---------"
108+
cat "${FAILED_FLAKY_FILE}"
109+
echo "-------------------------------------"
110+
fi
111+
112+
# Finally report failure if any tests failed
113+
if [ -f "${FAILED_FILE}" ]; then
114+
exit 1
115+
fi

0 commit comments

Comments
 (0)