Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit bd5e614

Browse files
author
Takashi Matsuo
authored
testing: add RUNS_PER_TEST environment variable (#230)
This is a change equivalent to: googleapis/google-cloud-cpp-spanner#1360 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/googleapis/google-cloud-cpp-common/230) <!-- Reviewable:end -->
1 parent 1f65342 commit bd5e614

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

ci/kokoro/docker/build-in-docker-bazel.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ echo "Using Bazel in ${BAZEL_BIN}"
4646
echo "================================================================"
4747

4848
bazel_args=("--test_output=errors" "--verbose_failures=true" "--keep_going")
49+
if [[ -n "${RUNS_PER_TEST}" ]]; then
50+
bazel_args+=("--runs_per_test=${RUNS_PER_TEST}")
51+
fi
52+
4953
if [[ -n "${BAZEL_CONFIG}" ]]; then
5054
bazel_args+=("--config" "${BAZEL_CONFIG}")
5155
fi

ci/kokoro/docker/build-in-docker-cmake.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ _EOF_
140140
fi
141141
fi
142142

143+
ctest_args=("--output-on-failure")
144+
if [[ -n "${RUNS_PER_TEST}" ]]; then
145+
ctest_args+=("--repeat-until-fail" "${RUNS_PER_TEST}")
146+
fi
147+
143148
if [[ "${BUILD_TESTING:-}" = "yes" ]]; then
144149
# When the user does a super-build the tests are hidden in a subdirectory.
145150
# We can tell that ${BINARY_DIR} does not have the tests by checking for this
@@ -150,7 +155,7 @@ if [[ "${BUILD_TESTING:-}" = "yes" ]]; then
150155
echo
151156
echo "${COLOR_YELLOW}Running unit tests $(date)${COLOR_RESET}"
152157
echo
153-
(cd "${BINARY_DIR}" && ctest --output-on-failure)
158+
(cd "${BINARY_DIR}" && ctest "${ctest_args[@]}")
154159

155160
echo
156161
echo "${COLOR_YELLOW}Completed unit tests $(date)${COLOR_RESET}"

ci/kokoro/docker/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ docker_flags=(
402402
# produces properly colorized error messages.
403403
"--env" "TERM=${TERM:-dumb}"
404404

405+
# If set, add a flag --runs_per_test=<value> to bazel or --repeat-until-fail
406+
# to ctest.
407+
"--env" "RUNS_PER_TEST=${RUNS_PER_TEST:-}"
408+
405409
# Tells scripts whether they are running as part of a CI or not.
406410
"--env" "RUNNING_CI=${RUNNING_CI:-no}"
407411

0 commit comments

Comments
 (0)